mobileCode.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="container-mobile">
  3. <navbar ref="navbar" :config="config" backColor="#666"></navbar>
  4. <view class="mobile-box">
  5. <view class="tip">
  6. 请输入银行预留手机号发送的短信验证,切记他人索取拒绝提供。
  7. </view>
  8. <view class="sms">
  9. <u-input v-model="sms_code" type="number" maxlength="6" :clearable="false" placeholder="请输入预留手机号验证码" />
  10. <!-- <view class="retry-gary" :class="{'retry': count > 0}" v-if="type == 'pay'" @click="retrySms"><text
  11. v-if="count > 0">{{count}}S后</text>重发</view> -->
  12. </view>
  13. </view>
  14. <view class="footer">
  15. <!-- <view class="btn" v-if="type == 'pay'" @click="submit('pay')">确认支付</view> -->
  16. <view class="btn" @click="submit('add')">提交</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. let timer
  22. export default {
  23. data() {
  24. return {
  25. config: {
  26. back: true, //false是tolbar页面 是则不写
  27. title: '新增银行卡',
  28. color: '#1a1a1a',
  29. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  30. backgroundColor: [1, '#fff'],
  31. statusBarFontColor: '#FFFFFF'
  32. },
  33. sms_code: '',
  34. type: '',
  35. cardid: '',
  36. count: 10,
  37. payment_id: ''
  38. }
  39. },
  40. onLoad(options) {
  41. if (options && options.type) {
  42. this.type = options.type
  43. // if (options.type == 'add') {
  44. this.cardid = options.id
  45. // this.$set(this.config, 'title', '新增银行卡');
  46. // }
  47. // else if (options.type == 'pay') {
  48. // this.payment_id = options.payment_id
  49. // this.$set(this.config, 'title', '确认付款');
  50. // timer = setInterval(() => {
  51. // this.count--
  52. // if (this.count == 0) {
  53. // clearInterval(timer)
  54. // }
  55. // }, 1000)
  56. // }
  57. // this.$nextTick(() => {
  58. // this.$refs.navbar.init();
  59. // })
  60. }
  61. },
  62. onUnload() {
  63. // clearInterval(timer)
  64. },
  65. methods: {
  66. retrySms() {
  67. if (count > 0) return this.$mUtil.toast('请稍后');
  68. uni.showLoading({
  69. title: '重发中...'
  70. })
  71. this.$http.post('/pay/order/kjRepeatSendSms', {
  72. payment_id: this.payment_id
  73. }).then(res => {
  74. uni.hideLoading()
  75. if (res.code == 200) {
  76. this.$mUtil.toast('短信验证码重发成功');
  77. } else {
  78. this.$mUtil.toast('服务异常! 请重试');
  79. }
  80. }).catch(err => {
  81. uni.hideLoading()
  82. this.$mUtil.toast('服务异常!');
  83. })
  84. },
  85. submit(type) {
  86. if (!this.sms_code) {
  87. return this.$mUtil.toast('短信验证码不能为空');
  88. }
  89. uni.showLoading({
  90. title: '提交中...'
  91. })
  92. let url
  93. let data = {}
  94. // if (type == 'pay') {
  95. // url = '/pay/order/kjPayConfirm'
  96. // data.payment_id = this.payment_id
  97. // data.sms_code = this.sms_code
  98. // } else if (type == 'add') {
  99. url = '/usercard/createCardConfirm'
  100. data.sms_code = this.sms_code
  101. data.id = this.cardid
  102. // }
  103. this.$http.post(url, data).then(res => {
  104. uni.hideLoading()
  105. if (res.code == 200) {
  106. // if (type == 'add') {
  107. this.$mUtil.toast("验证成功")
  108. setTimeout(() => {
  109. uni.navigateBack()
  110. // uni.redirectTo({
  111. // url: '/pages/order/banks/list'
  112. // })
  113. }, 500)
  114. // }else if (type == 'pay') {
  115. // this.$mUtil.toast("支付成功")
  116. // setTimeout(() => {
  117. // uni.redirectTo({
  118. // url: '/pages/order/orderList/orderList?keys=-1'
  119. // })
  120. // }, 500)
  121. // }
  122. }
  123. }).catch(err => {
  124. uni.hideLoading()
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss" scoped>
  131. .container-mobile {
  132. .mobile-box {
  133. padding: 40rpx;
  134. .tip {
  135. margin-bottom: 40rpx;
  136. font-size: 28rpx;
  137. font-weight: 700;
  138. }
  139. .sms {
  140. display: flex;
  141. justify-content: space-between;
  142. align-items: center;
  143. .retry-gary {
  144. display: flex;
  145. align-items: center;
  146. justify-content: center;
  147. width: 180rpx;
  148. margin-left: 40rpx;
  149. padding: 20rpx 10rpx;
  150. background-color: #FA6138;
  151. border-radius: 10rpx;
  152. color: #fff;
  153. }
  154. .retry {
  155. background-color: gray;
  156. }
  157. }
  158. /deep/ .u-input {
  159. border-bottom: 2rpx solid #dcdfe6;
  160. }
  161. }
  162. .footer {
  163. width: 100%;
  164. padding: 30rpx 60rpx;
  165. position: fixed;
  166. bottom: 0;
  167. display: flex;
  168. align-items: center;
  169. justify-content: space-between;
  170. background-color: #fff;
  171. z-index: 9;
  172. .btn {
  173. width: 100%;
  174. color: #fff;
  175. text-align: center;
  176. line-height: 85rpx;
  177. border: 1rpx solid #3775F6;
  178. border-radius: 44rpx;
  179. background-color: #FA6138;
  180. font-size: 28rpx;
  181. font-family: PingFang SC, PingFang SC-Regular;
  182. font-weight: 400;
  183. text-align: center;
  184. }
  185. }
  186. }
  187. </style>