bindBank.vue 7.1 KB

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