bankCard.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view>
  3. <view class="bg-img" style="background-image: url('https://upload-file-data.obs.cn-south-1.myhuaweicloud.com/5f263a5a6e7c4f2493e0325f28ab659a-bgimg.png');height: 310upx;"></view>
  4. <view class="container">
  5. <view class="text-bold" style="font-size: 40upx;padding: 30upx 0upx 10upx 40upx;">绑定银行卡</view>
  6. <view class="padding-left-lg" style="font-size: 28upx;">请如实填写一下资料</view>
  7. <u-picker mode="selector" v-model="bankShow" :default-selector="[0]" :range="selector" @confirm="confirm"></u-picker>
  8. <view class="flex align-center" style="padding: 30upx 60upx 20upx 60upx;">
  9. <view style="width: 160upx;font-family: PingFang SC;font-weight: bold;color: #000000;"><text class="text-red">*</text>选择银行</view>
  10. <view class="flex justify-between align-center" style="width: 200upx;height: 60upx;border: #565656 1upx solid;border-radius: 16upx;" @click="bankShow = true">
  11. <view class="padding-left-sm">{{bank}}</view>
  12. <view class="padding-right-xs cuIcon-unfold"></view>
  13. </view>
  14. </view>
  15. <view style="padding: 0 60upx;">
  16. <u-line color="#d4d4d4"></u-line>
  17. </view>
  18. <view class="flex align-center" style="padding: 20upx 60upx;">
  19. <view style="width: 160upx;font-family: PingFang SC;font-weight: bold;color: #000000;"><text class="text-red">*</text>银行卡号</view>
  20. <u-input v-model="cardNum" placeholder="请输入银行卡号" :clearable="false" />
  21. </view>
  22. <view style="padding: 0 60upx;">
  23. <u-line color="#d4d4d4"></u-line>
  24. </view>
  25. <view class="flex align-center" style="padding: 20upx 60upx;">
  26. <view style="width: 160upx;font-family: PingFang SC;font-weight: bold;color: #000000;"><text class="text-red">*</text>选择银行</view>
  27. <u-input v-model="name" placeholder="请输入真实姓名" :clearable="false" />
  28. </view>
  29. <view style="padding: 0 60upx;">
  30. <u-line color="#d4d4d4"></u-line>
  31. </view>
  32. <view class="flex align-center" style="padding: 20upx 60upx;">
  33. <view style="width: 160upx;font-family: PingFang SC;font-weight: bold;color: #000000;"><text class="text-red">*</text>手机号码</view>
  34. <u-input v-model="phone" placeholder="请输入手机号码" :clearable="false" />
  35. </view>
  36. <view style="padding: 0 60upx;">
  37. <u-line color="#d4d4d4"></u-line>
  38. </view>
  39. <view class="flex align-center" style="padding: 20upx 60upx;">
  40. <view style="width: 160upx;font-family: PingFang SC;font-weight: bold;color: #000000;"><text class="text-white">*</text>验证码</view>
  41. <u-input v-model="code" placeholder="请输入验证码" :clearable="false" />
  42. <button class="cu-btn round" style="width: 150upx;background-color: #5d41ed;color: #ffffff;" @click="checking" v-if="!state">验证码</button>
  43. <button class="cu-btn round" style="width: 150upx;background-color: #5d41ed;color: #ffffff;" v-else>{{currentTime}}s</button>
  44. </view>
  45. </view>
  46. <view class="footer-fixed padding">
  47. <u-button class="custom-style" shape="circle" @click="bind">确定绑定</u-button>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. data() {
  54. return {
  55. bankShow: false,
  56. bank: '招商银行',
  57. cardNum: '',
  58. name: '',
  59. phone: '',
  60. code: '',
  61. state: false, //是否开启倒计时
  62. totalTime: 120, //总时间,单位秒
  63. recordingTime: 0, //记录时间变量
  64. currentTime: 0, //显示时间变量
  65. selector: ['招商银行', '建设银行', '农业银行', '工商银行', '中信银行', '平安银行'],
  66. }
  67. },
  68. methods: {
  69. confirm(index) {
  70. this.bank = this.selector[index];
  71. },
  72. checking() {
  73. if(!this.$u.test.mobile(this.phone)) {
  74. uni.showToast({
  75. icon: "none",
  76. title: "请输入正确的手机号码"
  77. })
  78. return;
  79. }
  80. //把显示时间设为总时间
  81. this.currentTime = this.totalTime;
  82. //开始倒计时
  83. this.state = true;
  84. //执行倒计时
  85. this.checkingTime();
  86. },
  87. checkingTime() {
  88. let that = this;
  89. //判断是否开启
  90. if (this.state) {
  91. //判断显示时间是否已到0,判断记录时间是否已到总时间
  92. if (this.currentTime > 0 && this.recordingTime <= this.totalTime) {
  93. //记录时间增加 1
  94. this.recordingTime = this.recordingTime + 1;
  95. //显示时间,用总时间 - 记录时间
  96. this.currentTime = this.totalTime - this.recordingTime;
  97. //1秒钟后,再次执行本方法
  98. setTimeout(() => {
  99. //定时器内,this指向外部,找不到vue的方法,所以,需要用that变量。
  100. that.checkingTime();
  101. }, 1000)
  102. } else {
  103. //时间已完成,还原相关变量
  104. this.state = false; //关闭倒计时
  105. this.recordingTime = 0; //记录时间为0
  106. this.currentTime = this.totalTime; //显示时间为总时间
  107. }
  108. } else {
  109. //倒计时未开启,初始化默认变量
  110. this.state = false;
  111. this.recordingTime = 0;
  112. this.currentTime = this.totalTime;
  113. }
  114. },
  115. }
  116. }
  117. </script>
  118. <style>
  119. .container {
  120. border-radius: 36upx;
  121. background-color: #ffffff;
  122. padding-bottom: 30upx;
  123. margin: -120upx 30upx 30upx 30upx;
  124. }
  125. .custom-style {
  126. background-color: #5b3ee7;
  127. color: #ffffff;
  128. }
  129. </style>