bindBank.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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 @click="showAction" v-model="bankname" :field-style="{textAlign:'right'}" label="选择银行"
  14. placeholder="点击选择银行">
  15. </u-field>
  16. <u-field v-model="bankAddress" :field-style="{textAlign:'right'}" label="开户行" placeholder="输入开户行">
  17. </u-field>
  18. </view>
  19. <u-button class="mt-5" type="primary" style="background-color:#0052FF ;font-weight: bold;width: 100%;"
  20. @tap="submit">
  21. 绑定银行卡</u-button>
  22. </view>
  23. <u-popup mode="bottom" v-model="promptShow" width="100%" height="100%" border-radius="14">
  24. <view style="padding: 16px;">
  25. <view class="prompt dis a-c j-c f-c">
  26. <image src="/static/image/bindBank/success.png" mode="" style="width: 50px;height:50px;"></image>
  27. <text>绑定成功</text>
  28. </view>
  29. <view class="dis j-end a-c" style="width: 100%;">
  30. <text class="back" @click="GoBack">完成</text>
  31. </view>
  32. </view>
  33. </u-popup>
  34. <u-select v-model="show" :list="list" @confirm="confirm"></u-select>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. mapState,
  40. mapMutations
  41. } from "vuex"
  42. import bankBin from "@/common/bankcardinfo.js"
  43. export default {
  44. data() {
  45. return {
  46. promptShow: false,
  47. bankname: "", //银行名称
  48. accountno: "", //银行卡账号
  49. bankAddress: "",
  50. disabled: true,
  51. show: false,
  52. list: [{
  53. value: '1',
  54. label: '中国工商银行'
  55. },
  56. {
  57. value: '2',
  58. label: '中国农业银行'
  59. },
  60. {
  61. value: '3',
  62. label: '中国银行'
  63. },
  64. {
  65. value: '4',
  66. label: '中国建设银行'
  67. },
  68. {
  69. value: '5',
  70. label: '交通银行'
  71. },
  72. {
  73. value: '6',
  74. label: '中国邮政储蓄银行'
  75. },
  76. {
  77. value: '7',
  78. label: '招商银行'
  79. },
  80. {
  81. value: '8',
  82. label: '中信银行'
  83. },
  84. {
  85. value: '9',
  86. label: '中国光大银行'
  87. },
  88. {
  89. value: '10',
  90. label: '华夏银行'
  91. },
  92. {
  93. value: '11',
  94. label: '中国民生银行'
  95. },
  96. {
  97. value: '12',
  98. label: '广发银行'
  99. },
  100. {
  101. value: '13',
  102. label: '平安银行'
  103. },
  104. {
  105. value: '14',
  106. label: '上海浦东发展银行'
  107. },
  108. {
  109. value: '15',
  110. label: '兴业银行'
  111. },
  112. {
  113. value: '16',
  114. label: '浙商银行'
  115. },
  116. {
  117. value: '17',
  118. label: '渤海银行'
  119. },
  120. {
  121. value: '18',
  122. label: '恒丰银行'
  123. },
  124. {
  125. value: '19',
  126. label: '北京银行'
  127. },
  128. {
  129. value: '20',
  130. label: '上海银行'
  131. },
  132. ],
  133. validateBankCardStatus: false, //银行卡验证状态
  134. }
  135. },
  136. computed: {
  137. ...mapState(['userInfo'])
  138. },
  139. watch: {
  140. bankname(val) {
  141. this.OnBtnChange();
  142. },
  143. accountno(val) {
  144. this.OnBtnChange();
  145. },
  146. },
  147. methods: {
  148. ...mapMutations(['setUserModules']),
  149. // 改变按钮状态
  150. OnBtnChange() {
  151. if (this.accountno && this.bankname) {
  152. this.disabled = false;
  153. return;
  154. }
  155. this.disabled = true;
  156. },
  157. confirm(e) {
  158. this.bankname = e[0].label;
  159. },
  160. showAction() {
  161. this.show = true;
  162. },
  163. // 验证银行卡
  164. async validateBankCard() {
  165. var that = this;
  166. that.bankname = "";
  167. await bankBin.getBankBin(this.accountno)
  168. .then((data) => {
  169. console.log(data);
  170. that.bankname = data.bankName;
  171. that.validateBankCardStatus = true;
  172. return true;
  173. })
  174. .catch((err) => {
  175. that.validateBankCardStatus = false;
  176. return uni.showToast({
  177. title: err.split(":")[1],
  178. icon: "none"
  179. });
  180. })
  181. },
  182. async submit() {
  183. if (!this.bankname || !this.accountno) {
  184. return uni.showToast({
  185. title: '信息不完整',
  186. duration: 2000,
  187. icon: "none"
  188. });
  189. }
  190. var params = {
  191. "bankNumber": this.accountno,
  192. "bankAccount": this.bankname,
  193. "bankAddress": this.bankAddress,
  194. "isDefault": 0,
  195. }
  196. let res = await this.$http.post('/userBank/insertByBankNumber', params);
  197. if (res.code == '200') {
  198. this.promptShow = true;
  199. } else {
  200. uni.showToast({
  201. title: res.msg,
  202. duration: 2000,
  203. icon: "none"
  204. });
  205. }
  206. },
  207. GoBack() {
  208. return uni.navigateBack();
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. @import '@/style/mixin.scss';
  215. page {
  216. background-color: #F8FAFE;
  217. }
  218. .prompt {
  219. padding: 16px;
  220. position: absolute;
  221. top: 30%;
  222. left: 50%;
  223. transform: translate(-50%, -50%);
  224. text {
  225. font-size: 22px;
  226. color: #333333;
  227. font-weight: bold;
  228. margin-top: 15px;
  229. }
  230. .back {
  231. font-size: 14px;
  232. color: #333333;
  233. }
  234. }
  235. .binding {
  236. padding: 16px;
  237. .title {
  238. font-size: 14px;
  239. color: #333333;
  240. text:first-child {
  241. font-size: 20px;
  242. font-weight: bold;
  243. }
  244. }
  245. .formInfo {
  246. margin-top: 18px;
  247. width: 100%;
  248. background: #FFFFFF;
  249. box-shadow: 0px 4px 10px 0px #DAE3F4;
  250. border-radius: 6px;
  251. }
  252. }
  253. </style>