bankCard-edit.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="page-container">
  3. <u-navbar title="" :autoBack="true" :placeholder="true"></u-navbar>
  4. <view class="header-tips">
  5. <view class="name">添加银行卡</view>
  6. <view class="desc">请填写本人的银行卡信息</view>
  7. </view>
  8. <view class="form-section">
  9. <u-form :model="form" :rules="rules" ref="formRef" labelPosition="left" labelWidth="160"
  10. :labelStyle="{
  11. fontWeight: '500',
  12. fontSize: '28rpx',
  13. color: '#333333',
  14. }"
  15. >
  16. <u-form-item label="存管银行" prop="bankName" @click="selectBank">
  17. <u-input v-model="form.bankName" placeholder="请选择"></u-input>
  18. <u-icon slot="right" name="arrow-right"></u-icon>
  19. </u-form-item>
  20. <u-form-item label="银行账号" prop="cardNumber">
  21. <u-input v-model="form.cardNumber" type="number" placeholder="请输入银行卡号"></u-input>
  22. </u-form-item>
  23. <u-form-item label="开户行" prop="branchName">
  24. <u-input v-model="form.branchName" placeholder="请输入开户行名称"></u-input>
  25. </u-form-item>
  26. <u-form-item label="姓名" prop="name">
  27. <u-input v-model="form.name" placeholder="请输入姓名"></u-input>
  28. </u-form-item>
  29. <u-form-item label="手机号" prop="phone">
  30. <u-input v-model="form.phone" type="number" placeholder="请输入手机号"></u-input>
  31. </u-form-item>
  32. <u-form-item label="短信验证码" prop="verificationCode">
  33. <u-input v-model="form.verificationCode" type="number" placeholder="6位数字"></u-input>
  34. <u-button slot="right" type="primary" size="mini" shape="circle" plain @click="getCode">{{tips}}</u-button>
  35. </u-form-item>
  36. </u-form>
  37. </view>
  38. <view class="agreement-section">
  39. <u-checkbox-group v-model="isAgreed">
  40. <u-checkbox name="agree" shape="circle" v-model="isAgreed">
  41. <text class="agreement-text">我已阅读并同意《用户服务协议》</text>
  42. </u-checkbox>
  43. </u-checkbox-group>
  44. </view>
  45. <view class="footer-bar">
  46. <u-button type="primary" @click="submit">确认绑定</u-button>
  47. </view>
  48. <u-verification-code seconds="60" ref="uCode" @change="codeChange" />
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. form: {
  56. bankName: '',
  57. cardNumber: '',
  58. branchName: '',
  59. name: '',
  60. phone: '',
  61. verificationCode: '',
  62. },
  63. rules: {
  64. bankName: [{ required: true, message: '请选择存管银行', trigger: ['blur', 'change'] }],
  65. cardNumber: [{ required: true, message: '请输入银行卡号', trigger: ['blur', 'change'] }],
  66. branchName: [{ required: true, message: '请输入开户行名称', trigger: ['blur', 'change'] }],
  67. name: [{ required: true, message: '请输入姓名', trigger: ['blur', 'change'] }],
  68. phone: [{ required: true, message: '请输入手机号', trigger: ['blur', 'change'] }, { validator: (rule, value, callback) => uni.$u.test.mobile(value), message: '手机号码不正确' }],
  69. verificationCode: [{ required: true, message: '请输入验证码', trigger: ['blur', 'change'] }, { len: 6, message: '验证码必须为6位' }],
  70. },
  71. tips: '',
  72. isAgreed: false,
  73. };
  74. },
  75. mounted() {
  76. this.$nextTick(() => {
  77. this.$refs.formRef.setRules(this.rules);
  78. });
  79. },
  80. methods: {
  81. selectBank() {
  82. // 模拟跳转到银行选择页面
  83. uni.showToast({ title: '跳转到银行选择页', icon: 'none' });
  84. },
  85. codeChange(text) {
  86. this.tips = text;
  87. },
  88. getCode() {
  89. if (this.$refs.uCode.canGetCode) {
  90. // 模拟向后端请求验证码
  91. uni.showLoading({ title: '正在获取验证码' });
  92. setTimeout(() => {
  93. uni.hideLoading();
  94. uni.showToast({ title: '验证码已发送', icon: 'none' });
  95. this.$refs.uCode.start();
  96. }, 1000);
  97. } else {
  98. uni.$u.toast('倒计时结束后再发送');
  99. }
  100. },
  101. submit() {
  102. if(this.isAgreed.length === 0) {
  103. uni.showToast({ title: '请先同意用户协议', icon: 'none' });
  104. return;
  105. }
  106. this.$refs.formRef.validate().then(res => {
  107. console.log('表单校验成功', this.form);
  108. // uni.showToast({ title: '绑定成功', icon: 'success' });
  109. // setTimeout(() => {
  110. // uni.navigateBack();
  111. // }, 1500);
  112. }).catch(errors => {
  113. });
  114. }
  115. }
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. .page-container {
  120. min-height: 100vh;
  121. background-color: #F7F8FC;
  122. .header-tips {
  123. color: #333333;
  124. padding: 20rpx 30rpx;
  125. text-align: center;
  126. .name {
  127. font-weight: 500;
  128. font-size: 40rpx;
  129. }
  130. .desc {
  131. font-weight: 400;
  132. font-size: 28rpx;
  133. }
  134. }
  135. .form-section {
  136. margin: 0 24rpx;
  137. padding: 20rpx 24rpx;
  138. background-color: #fff;
  139. ::v-deep .u-form-item {
  140. padding: 6rpx 0;
  141. line-height: 1;
  142. .u-form-item--left__content {
  143. flex: none;
  144. .u-form-item--left__content--required {
  145. color: #fa3534;
  146. left: auto;
  147. right: 0;
  148. }
  149. }
  150. }
  151. }
  152. .agreement-section {
  153. display: flex;
  154. align-items: center;
  155. padding: 20rpx 30rpx;
  156. .agreement-text {
  157. font-size: 24rpx;
  158. color: #606266;
  159. margin-left: 10rpx;
  160. }
  161. }
  162. }
  163. .footer-bar {
  164. ::v-deep .u-btn {
  165. width: 100%;
  166. height: 76rpx;
  167. border-radius: 54rpx;
  168. background: linear-gradient(90deg, #77B6FF 0%, #449AFF 100%);
  169. &.u-btn--primary--disabled {
  170. background: #a0cfff;
  171. }
  172. }
  173. }
  174. </style>