bind-alipay.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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="输入支付宝收款人姓名" v-model="form.alipay_name">
  14. </view>
  15. <view class="input-item inline-form">
  16. <label class="label" for="">支付宝号</label>
  17. <input class="input" type="text" placeholder="支付宝账户" v-model="form.alipay">
  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="请输入验证码" v-model="form.captcha">
  28. </view>
  29. </view>
  30. <view class="submit-btn-wrapper">
  31. <button class="btn submit-btn" type="default" @tap="submit()">确认修改</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. type: "mobile",
  45. mobile: "",
  46. alipay:"",
  47. alipay_name:"",
  48. captcha:""
  49. }
  50. }
  51. },
  52. onLoad() {
  53. this.form.mobile = this.$store.state.user.mobile
  54. this.form.alipay = this.$store.state.user.alipay
  55. this.form.alipay_name = this.$store.state.user.alipay_name
  56. },
  57. methods: {
  58. sendSms() {
  59. if (this.sendable && this.$verified.mobile(this.form.mobile)) {
  60. this.sendable = false;
  61. this.$http.get({
  62. url: '/sms/send',
  63. data: {
  64. mobile: this.form.mobile,
  65. event: "bind-alipay"
  66. },
  67. success: (res) => {
  68. uni.showToast({
  69. title: res.data.msg,
  70. icon: "none"
  71. })
  72. timeInterval = setInterval(() => {
  73. if (this.countdown-- === 0) {
  74. clearInterval(timeInterval)
  75. this.countdown = time;
  76. this.sendable = true;
  77. }
  78. }, 1000)
  79. },
  80. fail: () => {
  81. this.sendable = true;
  82. }
  83. })
  84. }
  85. },
  86. submit(){
  87. if (this.$verified.required(this.form.alipay_name, "请输入收款人姓名")
  88. &&this.$verified.required(this.form.alipay, "请输入支付宝账户")
  89. && this.$verified.required(this.form.captcha, "请输入验证码")) {
  90. this.$http.post({
  91. url: "/user/bindalipay",
  92. data: this.form,
  93. success: (res) => {
  94. uni.showToast({
  95. title: "支付宝绑定成功",
  96. icon: "none",
  97. success() {
  98. setTimeout(uni.navigateBack(), 1000)
  99. }
  100. })
  101. }
  102. })
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .body {
  110. position: relative;
  111. overflow: hidden;
  112. }
  113. .header-bg {
  114. background: $primary-color;
  115. height: 100upx;
  116. position: absolute;
  117. top: 0;
  118. width: 100%;
  119. }
  120. .header {
  121. margin: 20upx;
  122. background: white;
  123. text-align: center;
  124. border-radius: 20upx;
  125. position: relative;
  126. z-index: 1;
  127. .title {
  128. height: 100upx;
  129. font-size: 32upx;
  130. line-height: 100upx;
  131. // font-weight: bold;
  132. }
  133. }
  134. .main {
  135. margin: 20upx;
  136. background: white;
  137. border-radius: 10upx;
  138. }
  139. .input-item.inline-form {
  140. display: flex;
  141. align-items: center;
  142. height: 80upx;
  143. font-size: 28upx;
  144. padding: 0 20upx;
  145. position: relative;
  146. color: #999999;
  147. .label {
  148. width: 160upx;
  149. // flex: 1 1 160upx;
  150. }
  151. .input {
  152. flex-grow: 1;
  153. font-size: 28upx;
  154. }
  155. }
  156. .send-vcode {
  157. background: $primary-color;
  158. color: white;
  159. font-size: 24upx;
  160. position: absolute;
  161. padding: 5upx 0;
  162. width: 160upx;
  163. line-height: normal;
  164. right: 0upx;
  165. top: 20upx;
  166. }
  167. .submit-btn-wrapper {
  168. margin-top: 80upx;
  169. .submit-btn {
  170. font-size: 30upx;
  171. line-height: 60upx;
  172. width: 250upx;
  173. background: $primary-color;
  174. color: white;
  175. }
  176. }
  177. </style>