You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

bank-card-add.vue 4.2KB

2 年之前
1 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
2 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="container">
  3. <u-form label-width='200' :model="state.form" ref="uForm">
  4. <u-form-item label="对公用户名">
  5. <u-input v-model="state.form.name" placeholder='请输入对公用户名' />
  6. </u-form-item>
  7. <u-form-item label="银行卡号">
  8. <u-input v-model="state.form.card" placeholder='请输入银行卡号' />
  9. </u-form-item>
  10. <u-form-item label="开户银行">
  11. <u-input v-model="state.form.bank" placeholder='请输入开户银行' />
  12. </u-form-item>
  13. <!-- <u-form-item label="身份证">
  14. <u-input v-model="state.form.agentgender" />
  15. </u-form-item> -->
  16. <!-- <u-form-item label="开户银行">
  17. <u-input v-model="state.form.begindate" type="select" />
  18. </u-form-item> -->
  19. <!-- <u-form-item label="银行预留手机号">
  20. <u-input v-model="state.form.phone" />
  21. </u-form-item> -->
  22. <u-form-item label="银行预留手机号">
  23. <u-input v-model="state.form.phone" placeholder='请输入银行预留手机号' />
  24. <u-button type="success" size="mini" @click="getCode" v-if="waitTime==0">获取验证码</u-button>
  25. <text class="btn" v-else>{{waitTime}}后重试</text>
  26. </u-form-item>
  27. <u-form-item label="验证码" placeholder='请输入验证码'>
  28. <u-input v-model="state.form.code" />
  29. </u-form-item>
  30. </u-form>
  31. <!-- <view class="uni-list" style='font-size:32rpx'>
  32. <view class="uni-list-cell uni-list-cell-pd">
  33. <view class="uni-list-cell-db">是否默认</view>
  34. <switch style="transform:scale(0.7)" @change="switchChange"/>
  35. </view>
  36. </view> -->
  37. <view style='margin-top: 40rpx;'>
  38. <submit-button title="提交绑定" @submit="submit"></submit-button>
  39. </view>
  40. </view>
  41. </template>
  42. <script setup lang="ts">
  43. import { reactive, ref } from "vue";
  44. import { request } from "@/utils/network/request.js";
  45. import { addBankCard, sendCode } from "@/utils/network/api.js";
  46. import { stringToJson } from "@/utils/network/encryption.js";
  47. import { msg } from "@/utils/utils";
  48. let waitTime = ref(0);
  49. const state = reactive({
  50. form: {
  51. name: '',
  52. card: '',
  53. bank: '',
  54. phone: '',
  55. code: '',
  56. },
  57. // isDefault:0, //是否默认
  58. })
  59. const submit = () => {
  60. for (var i in state.form) {
  61. if (!state.form[i]) {
  62. msg('请将信息填写完整!');
  63. return;
  64. }
  65. }
  66. const options = {
  67. type: 2,
  68. data: {
  69. 'accountId': state.form.name,
  70. 'bankCardId': state.form.card,
  71. 'bankAddress': state.form.bank,
  72. 'code': state.form.code,
  73. },
  74. method: "POST",
  75. showLoading: true,
  76. };
  77. request(addBankCard, options).then((res) => {
  78. const data = stringToJson(res.bizContent)
  79. msg('银行卡新增成功')
  80. setTimeout(() => {
  81. uni.navigateBack({
  82. delta: 1
  83. })
  84. }, 1500)
  85. console.log("添加银行卡", data)
  86. })
  87. }
  88. const getCode = () => {
  89. console.log(123);
  90. if (state.form.phone) {
  91. sendCodeApi()
  92. codeInterval()
  93. } else {
  94. uni.showToast({
  95. title: '请输入手机号',
  96. icon: 'none'
  97. });
  98. }
  99. }
  100. // 发送验证码
  101. const sendCodeApi = (type) => {
  102. //参数说明
  103. let options = {
  104. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  105. data: {
  106. mobile: state.form.phone
  107. }, //请求参数
  108. method: "POST", //提交方式(默认POST)
  109. showLoading: true, //是否显示加载中(默认显示)
  110. };
  111. //调用方式
  112. request(sendCode, options)
  113. .then((res) => {
  114. })
  115. .catch((err) => {
  116. console.log(err);
  117. });
  118. }
  119. //倒计时函数
  120. const codeInterval = () => {
  121. waitTime.value = 60
  122. let timer = setInterval(() => {
  123. if (waitTime.value == 1) {
  124. clearInterval(timer)
  125. }
  126. waitTime.value -= 1
  127. }, 1000)
  128. }
  129. // 是否默认
  130. // const switchChange=(e)=>{
  131. // console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  132. // if(e.detail.value){
  133. // state.isDefault=1
  134. // }else{
  135. // state.isDefault=0
  136. // }
  137. // }
  138. </script>
  139. <style lang="scss" scoped>
  140. .container {
  141. padding: 30rpx;
  142. }
  143. .uni-list-cell {
  144. display: flex;
  145. margin: 10rpx auto;
  146. justify-content: space-between;
  147. align-items: center;
  148. }
  149. ::v-deep .u-form-item--right__content__slot {
  150. display: flex !important;
  151. align-items: center;
  152. }
  153. .btn {
  154. background: #19BE6B;
  155. padding: 0rpx 32rpx;
  156. border-radius: 10rpx;
  157. color: white;
  158. font-size: 24rpx;
  159. height: 46rpx;
  160. line-height: 46rpx;
  161. text-align: center;
  162. }
  163. </style>