bindBank.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view>
  3. <public-module></public-module>
  4. <view class="binding dis f-c a-c ">
  5. <view class="title dis f-c a-c ">
  6. <text>添加银行卡</text>
  7. <text>请填写本人的银行卡信息</text>
  8. </view>
  9. <view class="formInfo">
  10. <u-field v-model="accountno" @blur="validateBankCard" :field-style="{textAlign:'right'}" label="银行卡"
  11. placeholder="请输入银行卡卡号">
  12. </u-field>
  13. <u-field v-model="bankname" :field-style="{textAlign:'right'}" label="选择银行" placeholder="系统自动识别">
  14. </u-field>
  15. </view>
  16. <u-button class="mt-5" type="primary" style="background-color:#0052FF ;font-weight: bold;width: 100%;"
  17. @tap="submit">
  18. 绑定银行卡</u-button>
  19. </view>
  20. <u-popup mode="bottom" v-model="promptShow" width="100%" height="100%" border-radius="14">
  21. <view style="padding: 16px;">
  22. <view class="prompt dis a-c j-c f-c">
  23. <image src="/static/image/bindBank/success.png" mode="" style="width: 50px;height:50px;"></image>
  24. <text>绑定成功</text>
  25. </view>
  26. <view class="dis j-end a-c" style="width: 100%;">
  27. <text class="back" @click="GoBack">完成</text>
  28. </view>
  29. </view>
  30. </u-popup>
  31. </view>
  32. </template>
  33. <script>
  34. import {
  35. mapState,
  36. mapMutations
  37. } from "vuex"
  38. import bankBin from "@/common/bankcardinfo.js"
  39. export default {
  40. data() {
  41. return {
  42. promptShow: false,
  43. bankname: "", //银行名称
  44. accountno: "", //银行卡账号
  45. disabled: true,
  46. validateBankCardStatus: false, //银行卡验证状态
  47. }
  48. },
  49. computed: {
  50. ...mapState(['userInfo'])
  51. },
  52. watch: {
  53. bankname(val) {
  54. this.OnBtnChange();
  55. },
  56. accountno(val) {
  57. this.OnBtnChange();
  58. },
  59. },
  60. methods: {
  61. ...mapMutations(['setUserModules']),
  62. // 改变按钮状态
  63. OnBtnChange() {
  64. if (this.accountno && this.bankname) {
  65. this.disabled = false;
  66. return;
  67. }
  68. this.disabled = true;
  69. },
  70. // 验证银行卡
  71. async validateBankCard() {
  72. var that = this;
  73. that.bankname = "";
  74. await bankBin.getBankBin(this.accountno)
  75. .then((data) => {
  76. console.log(data);
  77. that.bankname = data.bankName;
  78. that.validateBankCardStatus = true;
  79. return true;
  80. })
  81. .catch((err) => {
  82. that.validateBankCardStatus = false;
  83. return uni.showToast({
  84. title: err.split(":")[1],
  85. icon: "none"
  86. });
  87. })
  88. },
  89. async submit() {
  90. if (!this.bankname || !this.accountno) {
  91. return uni.showToast({
  92. title: '信息不完整',
  93. duration: 2000,
  94. icon: "none"
  95. });
  96. }
  97. var params = {
  98. "bankNumber": this.accountno,
  99. "bankAccount": this.bankname,
  100. "isDefault": 0,
  101. }
  102. let res = await this.$http.post('/userBank/insertByBankNumber', params);
  103. if (res.code == '200') {
  104. this.promptShow = true;
  105. } else {
  106. uni.showToast({
  107. title: res.msg,
  108. duration: 2000,
  109. icon: "none"
  110. });
  111. }
  112. },
  113. GoBack() {
  114. return uni.navigateBack();
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. @import '@/style/mixin.scss';
  121. page {
  122. background-color: #F8FAFE;
  123. }
  124. .prompt {
  125. padding: 16px;
  126. position: absolute;
  127. top: 30%;
  128. left: 50%;
  129. transform: translate(-50%, -50%);
  130. text {
  131. font-size: 22px;
  132. color: #333333;
  133. font-weight: bold;
  134. margin-top: 15px;
  135. }
  136. .back {
  137. font-size: 14px;
  138. color: #333333;
  139. }
  140. }
  141. .binding {
  142. padding: 16px;
  143. .title {
  144. font-size: 14px;
  145. color: #333333;
  146. text:first-child {
  147. font-size: 20px;
  148. font-weight: bold;
  149. }
  150. }
  151. .formInfo {
  152. margin-top: 18px;
  153. width: 100%;
  154. height: 88px;
  155. background: #FFFFFF;
  156. box-shadow: 0px 4px 10px 0px #DAE3F4;
  157. border-radius: 6px;
  158. }
  159. }
  160. </style>