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.1KB

2 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. console.log("添加银行卡",data)
  80. })
  81. }
  82. const getCode = () => {
  83. console.log(123);
  84. if (state.form.phone) {
  85. sendCodeApi()
  86. codeInterval()
  87. } else {
  88. uni.showToast({
  89. title: '请输入手机号',
  90. icon: 'none'
  91. });
  92. }
  93. }
  94. // 发送验证码
  95. const sendCodeApi = (type) => {
  96. //参数说明
  97. let options = {
  98. type: 2, //type: 2,JSON格式提交数据(默认表单形式提交)
  99. data: {
  100. mobile: state.form.phone
  101. }, //请求参数
  102. method: "POST", //提交方式(默认POST)
  103. showLoading: true, //是否显示加载中(默认显示)
  104. };
  105. //调用方式
  106. request(sendCode, options)
  107. .then((res) => {
  108. })
  109. .catch((err) => {
  110. console.log(err);
  111. });
  112. }
  113. //倒计时函数
  114. const codeInterval = () => {
  115. waitTime.value = 60
  116. let timer = setInterval(() => {
  117. if (waitTime.value == 1) {
  118. clearInterval(timer)
  119. }
  120. waitTime.value -= 1
  121. }, 1000)
  122. }
  123. // 是否默认
  124. // const switchChange=(e)=>{
  125. // console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  126. // if(e.detail.value){
  127. // state.isDefault=1
  128. // }else{
  129. // state.isDefault=0
  130. // }
  131. // }
  132. </script>
  133. <style lang="scss" scoped>
  134. .container {
  135. padding: 30rpx;
  136. }
  137. .uni-list-cell{
  138. display: flex;
  139. margin: 10rpx auto;
  140. justify-content: space-between;
  141. align-items: center;
  142. }
  143. ::v-deep .u-form-item--right__content__slot{
  144. display:flex !important;
  145. align-items: center;
  146. }
  147. .btn{
  148. background: #19BE6B;
  149. padding: 0rpx 32rpx;
  150. border-radius: 10rpx;
  151. color: white;
  152. font-size: 24rpx;
  153. height: 46rpx;
  154. line-height: 46rpx;
  155. text-align: center;
  156. }
  157. </style>