bindBank.vue 7.0 KB

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