bindBank.vue 5.7 KB

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