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