card-comfirm-sub.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <view class="container card clearfix">
  3. <view class="card-content">
  4. <view class="card-title" v-if="subType === 2">
  5. <view class="card-pay-text">¥{{ payMoney }}</view>
  6. </view>
  7. <view class="card-mains">
  8. <view class="card-form-text">已发送至手机号 {{ phoneNumbe }}</view>
  9. <view class="card-form">
  10. <input
  11. class="card-input"
  12. v-model="params.code"
  13. @input="handleInput"
  14. type="number"
  15. maxlength="6"
  16. placeholder="请输入短信验证码"
  17. />
  18. <view class="card-form-code" @click.stop="handleMobileCode"> {{ mobileCodeText }} </view>
  19. </view>
  20. </view>
  21. <view class="card-mains-btn">
  22. <button
  23. class="add-btn"
  24. :disabled="disabled"
  25. :class="[disabled ? 'disabled' : '']"
  26. @click="handleAddCard"
  27. >
  28. {{ suBbtnText }}
  29. </button>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. params: {
  39. code: '',
  40. mobile: '15817887257',
  41. payMoney: '1000'
  42. },
  43. payMoney: '1000',
  44. subType: 2, // 1直接绑卡 2//首次绑卡并支付 3//确认支付
  45. isMobileDisabled: false, //手机验证码按钮控制
  46. mobilCount: '', //倒计时
  47. mobileCodeText: '获取验证码',
  48. mobilTime: null
  49. }
  50. },
  51. onLoad() {
  52. // this.GetAccountInitData()
  53. },
  54. filters: {
  55. NumFormat(value) {
  56. //处理金额
  57. if (value) {
  58. return Number(value).toFixed(2)
  59. } else {
  60. return '0.00'
  61. }
  62. }
  63. },
  64. computed: {
  65. phoneNumbe() {
  66. // 手机号仅显示前三位及后四位数字,隐藏信息用*代替
  67. return this.params.mobile.substr(0, 3) + '****' + this.params.mobile.substring(7)
  68. },
  69. disabled() {
  70. if (this.params.code.length > 6) {
  71. return false
  72. } else {
  73. return true
  74. }
  75. },
  76. suBbtnText() {
  77. const textMap = {
  78. 1: '确认绑定',
  79. 2: '确认绑定支付',
  80. 3: '确认支付'
  81. }
  82. return textMap[this.subType]
  83. }
  84. },
  85. methods: {
  86. handleAddCard() {
  87. //提交卡号
  88. },
  89. handleClearInput() {
  90. //清空银行卡
  91. this.params.cardNumber = this.showCardNumber = ''
  92. },
  93. handleInput(e) {
  94. this.params.cardNumber = e.detail.value
  95. this.showCardNumber = this.formatAccNo(e.detail.value)
  96. },
  97. handleMobileCode() {
  98. // 获取短信验证码
  99. if (this.smsCodeParams.mobile == '') {
  100. this.$util.msg('请输入手机号', 2000)
  101. return
  102. }
  103. if (!this.$reg.isMobile(this.smsCodeParams.mobile)) {
  104. this.$util.msg('请输入正确的手机号', 2000)
  105. return
  106. }
  107. this.isMobileDisabled = true
  108. this.userLoginCode(this.smsCodeParams)
  109. },
  110. userLoginCode(params) {
  111. // 获取登录短息验证码
  112. this.UserService.userLoginCode(params)
  113. .then(response => {
  114. this.$util.msg('获取验证码成功', 2000)
  115. const TIME_COUNT = 60
  116. if (!this.mobilTime) {
  117. this.mobilCount = TIME_COUNT
  118. this.isMobileDisabled = true
  119. this.mobilTime = setInterval(() => {
  120. if (this.mobilCount > 1 && this.mobilCount <= TIME_COUNT) {
  121. this.mobilCount--
  122. this.mobileCodeText = this.mobilCount + 's'
  123. } else {
  124. this.isMobileDisabled = false
  125. clearInterval(this.mobilTime)
  126. this.mobilTime = null
  127. this.mobileCodeText = '获取验证码'
  128. }
  129. }, 1000)
  130. }
  131. })
  132. .catch(error => {
  133. this.$util.msg(error.msg, 2000)
  134. this.isMobileDisabled = false
  135. })
  136. },
  137. handleGoSusList() {
  138. // 跳转支持银行
  139. this.$api.navigateTo(`/pages/user/pay/card-sus-list`)
  140. },
  141. formatAccNo(value) {
  142. const newValue = value.replace(/([^0-9])/g, '') // 只允许输入数字
  143. const formatValue = newValue.replace(/(\d{4})(?=\d)/g, '$1 ') // 每4个数字后面加一个空格
  144. const inputLen = this.getOriginValue().length
  145. if (inputLen > this.maxLen) {
  146. // 如果输入的字符大于最大输入长度则禁止继续输入
  147. // this.inputRef.inputRef.value = this.state.recharge_phone
  148. return
  149. }
  150. // const end = () => {
  151. // setTimeout(() => {
  152. // this.end()
  153. // }, 10)
  154. // }
  155. // if (inputLen >= this.minLen) {
  156. // this.setState({ isValidNo: true, recharge_phone: formatValue }, end)
  157. // } else {
  158. // this.setState({ isValidNo: false, recharge_phone: formatValue, activeItem: -1 }, end)
  159. // }
  160. return formatValue
  161. },
  162. getOriginValue() {
  163. //获取input的原始值
  164. return this.showCardNumber.split(' ').join('')
  165. }
  166. },
  167. onShow() {
  168. // this.beansList = []
  169. }
  170. }
  171. </script>
  172. <style lang="scss">
  173. page,
  174. .container {
  175. background: #ffffff;
  176. height: 100%;
  177. }
  178. .card-content {
  179. width: 100%;
  180. height: auto;
  181. box-sizing: border-box;
  182. padding-top: 70rpx;
  183. }
  184. .card-title {
  185. width: 100%;
  186. height: auto;
  187. box-sizing: border-box;
  188. padding: 0 0 70rpx 0;
  189. .card-pay-text {
  190. width: 100%;
  191. height: 90rpx;
  192. line-height: 90rpx;
  193. text-align: center;
  194. font-size: 56rpx;
  195. color: #333;
  196. font-weight: bold;
  197. box-sizing: border-box;
  198. }
  199. }
  200. .card-mains {
  201. width: 100%;
  202. height: 100rpx;
  203. box-sizing: border-box;
  204. padding: 0 50rpx 0 32rpx;
  205. .card-form-text {
  206. width: 100%;
  207. height: 40rpx;
  208. line-height: 40rpx;
  209. text-align: left;
  210. font-size: $font-size-28;
  211. color: #333;
  212. box-sizing: border-box;
  213. margin-bottom: 16rpx;
  214. }
  215. .card-form {
  216. width: 100%;
  217. height: 100%;
  218. box-sizing: border-box;
  219. border: 1px solid #cccccc;
  220. padding: 14rpx 0;
  221. border-radius: 16rpx;
  222. position: relative;
  223. .card-input {
  224. width: 460rpx;
  225. height: 100%;
  226. line-height: 96rpx;
  227. padding-left: 32rpx;
  228. box-sizing: border-box;
  229. font-size: $font-size-30;
  230. color: #333;
  231. border-right: 1px solid #e1e1e1;
  232. float: left;
  233. }
  234. .card-form-code {
  235. width: 204rpx;
  236. height: 72rpx;
  237. line-height: 72rpx;
  238. text-align: center;
  239. color: $color-system;
  240. font-size: $font-size-26;
  241. float: left;
  242. }
  243. }
  244. }
  245. .card-mains-btn {
  246. width: 100%;
  247. height: auto;
  248. box-sizing: border-box;
  249. padding: 0 75rpx;
  250. margin-top: 180rpx;
  251. .add-btn {
  252. width: 100%;
  253. height: 90rpx;
  254. font-size: $font-size-30;
  255. line-height: 90rpx;
  256. color: #ffffff;
  257. text-align: center;
  258. background: $btn-confirm;
  259. border-radius: 45rpx;
  260. border-radius: 44rpx;
  261. margin-top: 80rpx;
  262. &.disabled {
  263. background: #e1e1e1;
  264. border-radius: 44rpx;
  265. }
  266. }
  267. }
  268. </style>