bindBank.vue 6.1 KB

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