bind-alipay.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="body">
  3. <view class="header-bg">
  4. </view>
  5. <view class="header">
  6. <view class="title">
  7. 绑定支付宝
  8. </view>
  9. </view>
  10. <view class="main">
  11. <view class="input-item inline-form">
  12. <label class="label" for="">姓名</label>
  13. <input class="input" type="text" placeholder="输入支付宝收款人姓名">
  14. </view>
  15. <view class="input-item inline-form">
  16. <label class="label" for="">支付宝号</label>
  17. <input class="input" type="text" placeholder="支付宝账户">
  18. </view>
  19. <view class="input-item inline-form">
  20. <label class="label" for="">手机号码</label>
  21. <input class="input" type="text" placeholder="" v-model="form.mobile" disabled="true">
  22. <button class="send-vcode" @tap="sendSms()"
  23. :disabled="!sendable">{{sendable?'获取验证码':countdown+'秒'}}</button>
  24. </view>
  25. <view class="input-item inline-form">
  26. <label class="label" for="">验证码</label>
  27. <input class="input" type="text" placeholder="请输入验证码">
  28. </view>
  29. </view>
  30. <view class="submit-btn-wrapper">
  31. <button class="btn submit-btn" type="default">确认修改</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. let timeInterval = null;
  37. const time = 120;
  38. export default {
  39. data() {
  40. return {
  41. sendable: true,
  42. countdown: time,
  43. form: {
  44. mobile: ""
  45. }
  46. }
  47. },
  48. onLoad() {
  49. this.form.mobile = this.$store.state.user.mobile
  50. },
  51. methods: {
  52. sendSms() {
  53. if (this.sendable && this.$verified.mobile(this.form.mobile)) {
  54. this.sendable = false;
  55. this.$http.get({
  56. url: '/sms/send',
  57. data: {
  58. mobile: this.form.mobile,
  59. event: "bind-alipay"
  60. },
  61. success: (res) => {
  62. uni.showToast({
  63. title: res.data.msg,
  64. icon: "none"
  65. })
  66. timeInterval = setInterval(() => {
  67. if (this.countdown-- === 0) {
  68. clearInterval(timeInterval)
  69. this.countdown = time;
  70. this.sendable = true;
  71. }
  72. }, 1000)
  73. },
  74. fail: () => {
  75. this.sendable = true;
  76. }
  77. })
  78. }
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss" scoped>
  84. .body {
  85. position: relative;
  86. overflow: hidden;
  87. }
  88. .header-bg {
  89. background: $primary-color;
  90. height: 100upx;
  91. position: absolute;
  92. top: 0;
  93. width: 100%;
  94. }
  95. .header {
  96. margin: 20upx;
  97. background: white;
  98. text-align: center;
  99. border-radius: 20upx;
  100. position: relative;
  101. z-index: 1;
  102. .title {
  103. height: 100upx;
  104. font-size: 32upx;
  105. line-height: 100upx;
  106. // font-weight: bold;
  107. }
  108. }
  109. .main {
  110. margin: 20upx;
  111. background: white;
  112. border-radius: 10upx;
  113. }
  114. .input-item.inline-form {
  115. display: flex;
  116. align-items: center;
  117. height: 80upx;
  118. font-size: 28upx;
  119. padding: 0 20upx;
  120. position: relative;
  121. color: #999999;
  122. .label {
  123. width: 160upx;
  124. // flex: 1 1 160upx;
  125. }
  126. .input {
  127. flex-grow: 1;
  128. font-size: 28upx;
  129. }
  130. }
  131. .send-vcode {
  132. background: $primary-color;
  133. color: white;
  134. font-size: 24upx;
  135. position: absolute;
  136. padding: 5upx 0;
  137. width: 160upx;
  138. line-height: normal;
  139. right: 0upx;
  140. top: 20upx;
  141. }
  142. .submit-btn-wrapper {
  143. margin-top: 80upx;
  144. .submit-btn {
  145. font-size: 30upx;
  146. line-height: 60upx;
  147. width: 250upx;
  148. background: $primary-color;
  149. color: white;
  150. }
  151. }
  152. </style>