card-add.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="container card clearfix">
  3. <view class="card-title">输入卡号添加</view>
  4. <view class="card-mains">
  5. <view class="card-form">
  6. <input
  7. class="card-input"
  8. v-model="showCardNumber"
  9. @input="handleInput"
  10. type="number"
  11. :maxlength="maxLen"
  12. placeholder="请输入本人的银行卡号"
  13. />
  14. <view class="card-clear" v-if="!disabled" @click="handleClearInput"
  15. ><text class="iconfont icon-shanchu1"></text
  16. ></view>
  17. </view>
  18. </view>
  19. <view class="card-mains-text" @click="handleGoSusList">查看支持银行 ></view>
  20. <view class="card-mains-btn">
  21. <button class="add-btn" :disabled="disabled" :class="[disabled ? 'disabled' : '']" @click="handleAddCard">
  22. 提交卡号
  23. </button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. params: {
  32. clubId: 0,
  33. cardNumber: ''
  34. },
  35. showCardNumber: '',
  36. maxLen:30,
  37. subType: 2, // 1直接绑卡 2//首次绑卡并支付 3//确认支付
  38. }
  39. },
  40. onLoad() {
  41. // this.GetAccountInitData()
  42. },
  43. filters: {},
  44. computed: {
  45. disabled: function() {
  46. if (this.params.cardNumber.length > 12) {
  47. return false
  48. } else {
  49. return true
  50. }
  51. }
  52. },
  53. methods: {
  54. handleAddCard() {
  55. //提交卡号
  56. },
  57. handleClearInput() {
  58. //清空银行卡
  59. this.params.cardNumber = this.showCardNumber = ''
  60. },
  61. handleInput(e) {
  62. this.params.cardNumber = e.detail.value
  63. this.showCardNumber = this.formatAccNo(e.detail.value)
  64. },
  65. handleGoSusList(){
  66. // 跳转支持银行
  67. this.$api.navigateTo(`/pages/user/pay/card-sus-list`)
  68. },
  69. formatAccNo(value) {
  70. const newValue = value.replace(/([^0-9])/g, '') // 只允许输入数字
  71. const formatValue = newValue.replace(/(\d{4})(?=\d)/g, '$1 ') // 每4个数字后面加一个空格
  72. const inputLen = this.getOriginValue().length
  73. if (inputLen > this.maxLen) {
  74. // 如果输入的字符大于最大输入长度则禁止继续输入
  75. // this.inputRef.inputRef.value = this.state.recharge_phone
  76. return
  77. }
  78. // const end = () => {
  79. // setTimeout(() => {
  80. // this.end()
  81. // }, 10)
  82. // }
  83. // if (inputLen >= this.minLen) {
  84. // this.setState({ isValidNo: true, recharge_phone: formatValue }, end)
  85. // } else {
  86. // this.setState({ isValidNo: false, recharge_phone: formatValue, activeItem: -1 }, end)
  87. // }
  88. return formatValue
  89. },
  90. getOriginValue() {
  91. //获取input的原始值
  92. return this.showCardNumber.split(' ').join('');
  93. }
  94. },
  95. onShow() {
  96. // this.beansList = []
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. page,
  102. .container {
  103. background: #ffffff;
  104. height: 100%;
  105. }
  106. .card-title {
  107. width: 100%;
  108. height: 100rpx;
  109. line-height: 100rpx;
  110. font-size: $font-size-32;
  111. color: #333;
  112. font-weight: bold;
  113. box-sizing: border-box;
  114. padding: 0 32rpx;
  115. }
  116. .card-mains {
  117. width: 100%;
  118. height: 100rpx;
  119. box-sizing: border-box;
  120. padding: 0 50rpx 0 32rpx;
  121. .card-form {
  122. width: 100%;
  123. height: 100%;
  124. box-sizing: border-box;
  125. border: 1px solid #cccccc;
  126. padding-right: 96rpx;
  127. border-radius: 16rpx;
  128. position: relative;
  129. .card-input {
  130. width: 568rpx;
  131. height: 100%;
  132. line-height: 96rpx;
  133. padding-left: 20rpx;
  134. box-sizing: border-box;
  135. font-size: $font-size-30;
  136. color: #333;
  137. }
  138. .card-clear {
  139. width: 96rpx;
  140. height: 96rpx;
  141. position: absolute;
  142. right: 0;
  143. top: 0;
  144. line-height: 96rpx;
  145. text-align: center;
  146. .icon-shanchu1 {
  147. font-size: $font-size-32;
  148. color: #d5d5d5;
  149. }
  150. }
  151. }
  152. }
  153. .card-mains-text {
  154. width: 100%;
  155. line-height: 88rpx;
  156. box-sizing: border-box;
  157. padding: 0 56rpx;
  158. font-size: $font-size-28;
  159. color: #1890f9;
  160. }
  161. .card-mains-btn {
  162. width: 100%;
  163. height: auto;
  164. box-sizing: border-box;
  165. padding: 0 75rpx;
  166. margin-top: 180rpx;
  167. .add-btn {
  168. width: 100%;
  169. height: 90rpx;
  170. font-size: $font-size-30;
  171. line-height: 90rpx;
  172. color: #ffffff;
  173. text-align: center;
  174. background: $btn-confirm;
  175. border-radius: 45rpx;
  176. border-radius: 44rpx;
  177. margin-top: 80rpx;
  178. &.disabled {
  179. background: #e1e1e1;
  180. border-radius: 44rpx;
  181. }
  182. }
  183. }
  184. </style>