bindBank.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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="realUserName" :field-style="{textAlign:'right'}" label="本人姓名" placeholder="输入真实姓名">
  11. </u-field>
  12. <u-field v-model="accountno" @blur="validateBankCard" :field-style="{textAlign:'right'}" label="银行卡"
  13. 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. "accountno": {
  156. handler(val) {
  157. if (val) {
  158. this.accountno = val.replace(/\s/g, "");
  159. }
  160. },
  161. },
  162. },
  163. methods: {
  164. ...mapMutations(['setUserModules']),
  165. // 改变按钮状态
  166. confirm(e) {
  167. this.bankname = e[0].label;
  168. },
  169. showAction() {
  170. this.show = true;
  171. },
  172. // 验证银行卡
  173. async validateBankCard() {
  174. var that = this;
  175. that.bankname = "";
  176. await bankBin.getBankBin(this.accountno)
  177. .then((data) => {
  178. that.bankname = data.bankName;
  179. that.validateBankCardStatus = true;
  180. return true;
  181. })
  182. .catch((err) => {
  183. that.validateBankCardStatus = false;
  184. return uni.showToast({
  185. title: err.split(":")[1],
  186. icon: "none"
  187. });
  188. })
  189. },
  190. async submit() {
  191. if (!this.bankname || !this.accountno || !this.realUserName || !this.bankAddress) {
  192. return uni.showToast({
  193. title: '信息不完整',
  194. duration: 2000,
  195. icon: "none"
  196. });
  197. }
  198. var params = {
  199. "bankNumber": this.accountno,
  200. "realUserName": this.realUserName,
  201. "bankAccount": this.bankname,
  202. "bankAddress": this.bankAddress,
  203. "isDefault": 0,
  204. "userId": this.userInfo.sysUser.id,
  205. "userName": this.userInfo.sysUser.name
  206. }
  207. let res = await this.$http.post('/userBank/insertByBankNumber', params);
  208. if (res.code == '200') {
  209. this.promptShow = true;
  210. } else {
  211. uni.showToast({
  212. title: res.msg,
  213. duration: 2000,
  214. icon: "none"
  215. });
  216. }
  217. },
  218. GoBack() {
  219. return uni.navigateBack();
  220. }
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. @import '@/style/mixin.scss';
  226. page {
  227. background-color: #F8FAFE;
  228. }
  229. .prompt {
  230. padding: 16px;
  231. position: absolute;
  232. top: 30%;
  233. left: 50%;
  234. transform: translate(-50%, -50%);
  235. text {
  236. font-size: 22px;
  237. color: #333333;
  238. font-weight: bold;
  239. margin-top: 15px;
  240. }
  241. .back {
  242. font-size: 14px;
  243. color: #333333;
  244. }
  245. }
  246. .binding {
  247. padding: 16px;
  248. .title {
  249. font-size: 14px;
  250. color: #333333;
  251. text:first-child {
  252. font-size: 20px;
  253. font-weight: bold;
  254. }
  255. }
  256. .formInfo {
  257. margin-top: 18px;
  258. width: 100%;
  259. background: #FFFFFF;
  260. box-shadow: 0px 4px 10px 0px #DAE3F4;
  261. border-radius: 6px;
  262. }
  263. }
  264. </style>