addBankCard.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <view class="content">
  3. <view class="content3 flex s-row">
  4. <view class="title">上传银行卡卡号页</view>
  5. <view @click="uploadImg" class="picture picture3" v-if="!dataDetails.payeeAddressUrl">
  6. <image class="xj-image" src="@/static/images/mine/ic_shanchuan@2x.png"></image>
  7. <view class="text">上传银行卡卡号页</view>
  8. </view>
  9. <view v-if="dataDetails.payeeAddressUrl" @click.stop="uploadImg" class="preview-card-img picture">
  10. <!-- <image class="card-img" :src="dataDetails.cardAddressUrl"></image> -->
  11. <view @click.stop="delCard">
  12. <image class='del-card' src="@/static/images/common/quxiao@2x.png">
  13. </image>
  14. </view>
  15. <image class="" :src="dataDetails.payeeAddressUrl" mode="aspectFit"></image>
  16. </view>
  17. <view class="flex row">
  18. <view class="left-text">银行卡卡号</view>
  19. <view class="flex">
  20. <u--input placeholder="输入银行卡号码" inputAlign='left' border="none" v-model="dataDetails.bankCard">
  21. </u--input>
  22. </view>
  23. </view>
  24. <view class="flex row">
  25. <view class="left-text">开户行</view>
  26. <u--input placeholder="输入开户行" inputAlign='left' border="none" v-model="dataDetails.bankDeposit">
  27. </u--input>
  28. </view>
  29. <view class="flex row">
  30. <view class="left-text khzh-styel">开户支行</view>
  31. <view class="flex align-center" v-if="isShowManualInput">
  32. <u--input class="select-bankzh point" placeholder="输入开户支行" inputAlign='left' border="none"
  33. v-model="dataDetails.bankDepositBranch">
  34. </u--input>
  35. <view @click="manualInput" class="type">选择支行</view>
  36. </view>
  37. <view class="flex align-center" v-if="!isShowManualInput">
  38. <!-- <u--input @click="selectZhbank" placeholder="选择开户支行" inputAlign='left' border="none" disabled>
  39. </u--input> -->
  40. <u--input class="select-bankzh point" placeholder="选择开户支行" inputAlign='left' border="none"
  41. v-model="dataDetails.bankDepositBranch">
  42. </u--input>
  43. <!-- <view class="select-bankzh" @click="selectZhbank">
  44. {{dataDetails.bankDepositBranch?dataDetails.bankDepositBranch:'选择开户支行'}}
  45. </view> -->
  46. <view @click="manualInput" class="type">手动输入</view>
  47. </view>
  48. </view>
  49. <view class="flex row noborder">
  50. <view class="left-text">收款人</view>
  51. <view class="flex">
  52. <u--input placeholder="输入收款人姓名" inputAlign='left' border="none" v-model="dataDetails.payeeName">
  53. </u--input>
  54. </view>
  55. </view>
  56. <u-picker :show="isShowBank" :columns="columns" :closeOnClickOverlay='true' @close='zhBankClose'
  57. @cancel='zhBankClose' @confirm='confirmBank'></u-picker>
  58. </u-picker>
  59. <view class="" style="color: red;font-size: 26rpx;margin-top: 20rpx;">*收款人须为司机本人</view>
  60. </view>
  61. <u-toast ref="uToast"></u-toast>
  62. <view class="submit-btn" @click="$u.throttle(submit, 5000)">提交</view>
  63. <u-action-sheet :actions="$helper.imgTypeList" :title="$helper.imgType" :show="isShowimgType"
  64. @select="imgTypeSelect" :closeOnClickOverlay="true" :closeOnClickAction="true" @close="isShowimgType=false">
  65. </u-action-sheet>
  66. </view>
  67. </template>
  68. <script>
  69. import upload from '@/components/upload.vue';
  70. import uploadImage from '@/components/ossutil/uploadFile.js';
  71. import permision from "@/js_sdk/wa-permission/permission.js"
  72. var _this;
  73. import {
  74. mapState
  75. } from 'vuex';
  76. export default {
  77. components: {},
  78. data() {
  79. return {
  80. isShowimgType: false,
  81. dataDetails: {
  82. driverId: '',
  83. payeeAddressUrl: '',
  84. bankCard: '',
  85. bankDeposit: '',
  86. bankDepositBranch: '',
  87. payeeName: '',
  88. },
  89. imagesrc: '',
  90. columns: [
  91. ],
  92. isShowBank: false,
  93. isShowManualInput: false,
  94. index: ''
  95. };
  96. },
  97. computed: {
  98. ...mapState(['hasLogin', 'userInfo']),
  99. },
  100. onLoad() {
  101. _this = this;
  102. this.get_camera_permission()
  103. this.dataDetails.driverId = this.userInfo.driverId ? this.userInfo.driverId : uni.getStorageSync(
  104. "firstAuthentication").id
  105. },
  106. methods: {
  107. async get_camera_permission() {
  108. var photol = await permision.requestAndroidPermission("android.permission.CAMERA")
  109. if (photol == false) {
  110. uni.showModal({
  111. title: '提示',
  112. content: '您已经关闭相册权限,去设置',
  113. success: function(res) {
  114. if (res.confirm) {
  115. permision.gotoAppPermissionSetting()
  116. // plus.runtime.openURL("app-settings:");
  117. } else if (res.cancel) {
  118. console.log('用户点击取消');
  119. }
  120. }
  121. });
  122. }
  123. },
  124. delCard() {
  125. _this.dataDetails.payeeAddressUrl = ''
  126. _this.$forceUpdate()
  127. },
  128. uploadImg(type, ) {
  129. this.uploadType = type
  130. this.isShowimgType = true
  131. },
  132. zhBankClose() {
  133. this.isShowBank = false
  134. },
  135. // 选择支行
  136. selectZhbank() {
  137. if (!this.dataDetails.payeeAddressUrl) {
  138. this.$refs.uToast.show({
  139. type: 'error',
  140. message: "请先上传银行卡!",
  141. })
  142. return true
  143. } else if (this.dataDetails.payeeAddressUrl && uni.$u.test.isEmpty(this.columns)) {
  144. this.$refs.uToast.show({
  145. type: 'error',
  146. message: "请选择手动输入开户支行!",
  147. })
  148. return true
  149. }
  150. this.isShowBank = true
  151. },
  152. confirmBank(e) {
  153. console.log(e)
  154. this.dataDetails.bankDepositBranch = e.value[0]
  155. this.isShowBank = false
  156. },
  157. manualInput() {
  158. if (this.isShowManualInput) {
  159. if (uni.$u.test.isEmpty(this.dataDetails.payeeAddressUrl)) {
  160. this.$refs.uToast.show({
  161. type: 'error',
  162. message: "请先上传银行卡!",
  163. })
  164. return true
  165. } else if (this.dataDetails.payeeAddressUrl && uni.$u.test.isEmpty(this.columns)) {
  166. this.$refs.uToast.show({
  167. type: 'error',
  168. message: "请选择手动输入开户支行!",
  169. })
  170. return true
  171. }
  172. this.isShowBank = true
  173. } else {
  174. this.isShowBank = false
  175. }
  176. this.isShowManualInput = !this.isShowManualInput
  177. },
  178. //设置图片
  179. setImage(e) {
  180. console.log(e);
  181. //显示在页面
  182. //this.imagesrc = e.path;
  183. if (e.dotype == 'idphoto') {
  184. _this.zjzClipper(e.path);
  185. } else if (e.dotype == 'watermark') {
  186. _this.watermark(e.path);
  187. } else {
  188. _this.savePhoto(e.path);
  189. }
  190. },
  191. //保存图片到相册,方便核查
  192. savePhoto(path) {
  193. this.imagesrc = path;
  194. uploadImage(path, 'appData/',
  195. result => {
  196. // 上传成功
  197. console.log('图片地址', result)
  198. }
  199. )
  200. //保存到相册
  201. // uni.saveImageToPhotosAlbum({
  202. // filePath: path,
  203. // success: () => {
  204. // uni.showToast({
  205. // title: '已保存至相册',
  206. // duration: 2000
  207. // });
  208. // }
  209. // });
  210. },
  211. uploadImg() {
  212. this.imgTypeSelect()
  213. // this.isShowimgType = true
  214. },
  215. imgTypeSelect(val) {
  216. console.log(val)
  217. // if (val.name == '相册') {
  218. uni.chooseImage({
  219. count: 1,
  220. // sourceType: this.$helper.chooseImage.sourceType,
  221. success: function(res) {
  222. console.log(JSON.stringify(res.tempFilePaths));
  223. uploadImage('image', res.tempFilePaths[0], 'appData/',
  224. result => {
  225. // 上传成功
  226. console.log('图片地址', result)
  227. _this.$request.baseRequest('get',
  228. '/driverInfo/bankShibie', {
  229. bankImg: result,
  230. }).then(res => {
  231. _this.dataDetails.payeeAddressUrl = result
  232. if (res.data.bankNo) {
  233. _this.dataDetails.bankCard = res.data.bankNo
  234. }
  235. if (res.data.bankName) {
  236. _this.dataDetails.bankDeposit = res.data.bankName
  237. }
  238. // 开户支行LIst
  239. if (res.data.bankNameZhihang) {
  240. _this.columns.push(res.data
  241. .bankNameZhihang)
  242. }
  243. _this.$forceUpdate()
  244. })
  245. .catch(res => {
  246. uni.$u.toast(res.message);
  247. });
  248. }
  249. )
  250. }
  251. });
  252. // } else {
  253. // uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=bank');
  254. // }
  255. },
  256. validate() {
  257. // true 为校验不通过
  258. // if (uni.$u.test.isEmpty(this.dataDetails.payeeAddressUrl)) {
  259. // this.$refs.uToast.show({
  260. // type: 'error',
  261. // message: "请上传银行卡卡号页!",
  262. // })
  263. // return true
  264. // }
  265. if (uni.$u.test.isEmpty(this.dataDetails.bankCard)) {
  266. this.$refs.uToast.show({
  267. type: 'error',
  268. message: "银行卡卡号不能为空!",
  269. })
  270. return true
  271. }
  272. if (this.dataDetails.bankCard.length < 16 || this.dataDetails.bankCard.length > 20) {
  273. this.$refs.uToast.show({
  274. type: 'error',
  275. message: "银行卡号输入错误!",
  276. })
  277. return true
  278. }
  279. if (uni.$u.test.isEmpty(this.dataDetails.bankDeposit)) {
  280. this.$refs.uToast.show({
  281. type: 'error',
  282. message: "开户行不能为空!",
  283. })
  284. return true
  285. }
  286. if (this.dataDetails.bankDeposit.length < 4 || this.dataDetails.bankDeposit.length > 25) {
  287. this.$refs.uToast.show({
  288. type: 'error',
  289. message: "开户行输入错误!",
  290. })
  291. return true
  292. }
  293. if (uni.$u.test.isEmpty(this.dataDetails.bankDepositBranch)) {
  294. this.$refs.uToast.show({
  295. type: 'error',
  296. message: "开户支行不能为空!",
  297. })
  298. return true
  299. }
  300. if (this.dataDetails.bankDepositBranch.length < 4 || this.dataDetails.bankDepositBranch.length > 25) {
  301. this.$refs.uToast.show({
  302. type: 'error',
  303. message: "开户支行输入错误!",
  304. })
  305. return true
  306. }
  307. // if (uni.$u.test.isEmpty(this.dataDetails.cardholderName)) {
  308. // this.$refs.uToast.show({
  309. // type: 'error',
  310. // message: "持卡人姓名不能为空!",
  311. // })
  312. // return true
  313. // }
  314. if (uni.$u.test.isEmpty(this.dataDetails.payeeName)) {
  315. this.$refs.uToast.show({
  316. type: 'error',
  317. message: "收款人姓名不能为空!",
  318. })
  319. return true
  320. }
  321. // if (uni.$u.test.isEmpty(this.dataDetails.cardholderIdNumber)) {
  322. // this.$refs.uToast.show({
  323. // type: 'error',
  324. // message: "持卡人身份证号不能为空!",
  325. // })
  326. // return true
  327. // }
  328. },
  329. //身份证正面
  330. getImgUrl1(src) {
  331. // console.log(src)
  332. // console.log('------------res-----------')
  333. // let that = this;
  334. // that.id[0] = src
  335. // that.id1 = src
  336. // that.certificates = false
  337. // that.personImgs.personImg = that.id[0]
  338. // that.$api.doRequest('get', '/driverViewInfo/personShibie', that
  339. // .personImgs).then(res => {
  340. // if (res.data.data.recPerson != null) {
  341. // if (res.data.data.recPerson != "") {
  342. // that.$set(that.DriverViewInfo, 'driverName', res
  343. // .data.data.recPerson)
  344. // }
  345. // }
  346. // if (res.data.data.recPersonNo != null) {
  347. // if (res.data.data.recPersonNo != "") {
  348. // that.$set(that.DriverViewInfo, 'numberCard', res
  349. // .data.data.recPersonNo)
  350. // }
  351. // }
  352. // }).catch(res => {
  353. // uni.showToast({
  354. // title: res.data.message,
  355. // icon: 'none',
  356. // duration: 2000
  357. // })
  358. // })
  359. },
  360. submit() {
  361. var that = this
  362. // // 获取银行卡颜色
  363. // let _obj = {
  364. // "input":this.dataDetails.payeeAddressUrl
  365. // }
  366. // this.$request.baseRequest('post', '/ClothingColorController/recognition', _obj)
  367. // .then(res => {
  368. // if (res.code == '200') {
  369. // this.dataDetails.cardColor = res.data
  370. // } else {
  371. // uni.$u.toast(res.message);
  372. // }
  373. // })
  374. // .catch(res => {
  375. // uni.$u.toast(res.message);
  376. // });
  377. if (that.validate()) return
  378. if (this.dataDetails.payeeName != uni.getStorageSync("firstAuthentication").driverName) {
  379. this.$refs.uToast.show({
  380. type: 'error',
  381. message: "收款人须为司机本人!",
  382. })
  383. return
  384. } else {
  385. this.$request.baseRequest('get', '/driverPayeeInfo/bankCradShibie', {
  386. name: this.dataDetails.payeeName,
  387. idCard: uni.getStorageSync("firstAuthentication").numberCard,
  388. accountNo: this.dataDetails.bankCard
  389. }).then(
  390. res => {
  391. if (res.data.distinguishNum == "01") {
  392. this.dataDetails.commonId = this.userInfo.id
  393. this.$request.baseRequest('post', '/driverPayeeInfo/api/addInfo', this.dataDetails)
  394. .then(
  395. res => {
  396. if (res.code == '200') {
  397. let params = {
  398. type: 'success',
  399. message: "提交成功",
  400. }
  401. this.$refs.uToast.show({
  402. ...params
  403. })
  404. uni.navigateBack({
  405. delta: 1
  406. });
  407. // uni.$u.route('/pages/mine/manageBankCards/index');
  408. } else {
  409. uni.$u.toast(res.message);
  410. }
  411. })
  412. .catch(res => {
  413. uni.$u.toast(res.message);
  414. });
  415. } else {
  416. uni.$u.toast(res.message);
  417. }
  418. })
  419. }
  420. },
  421. },
  422. };
  423. </script>
  424. <style scoped lang="scss">
  425. .row4-img {
  426. width: 32rpx;
  427. height: 32rpx;
  428. }
  429. .content {
  430. padding: 20rpx;
  431. padding-bottom: 50rpx;
  432. height: 100vh;
  433. }
  434. .content3 {
  435. background: white;
  436. padding: 20rpx;
  437. box-sizing: border-box;
  438. .left-text {
  439. // background: red;
  440. width: 290rpx;
  441. color: #333333;
  442. display: flex;
  443. align-items: center;
  444. }
  445. .row {
  446. border-bottom: 1px solid #EEEEEE;
  447. padding-bottom: 28rpx;
  448. margin-top: 26rpx;
  449. .ch-style {}
  450. }
  451. .row-ch {
  452. padding-right: 180rpx;
  453. box-sizing: border-box;
  454. }
  455. }
  456. .title {
  457. color: #999999;
  458. margin: 20rpx 0;
  459. }
  460. .picture {
  461. margin-top: 20rpx;
  462. background: #F5F6FA;
  463. border-radius: 10rpx;
  464. display: flex;
  465. flex-direction: column;
  466. justify-content: center;
  467. align-items: center;
  468. color: #6A7282;
  469. width: 100%;
  470. height: 440rpx;
  471. position: relative;
  472. .text {
  473. margin-top: 20rpx;
  474. }
  475. }
  476. .xj-image {
  477. width: 100rpx;
  478. height: 100rpx;
  479. }
  480. .picture3 {
  481. background: url(../../../static/images/mine/yhkzm.png);
  482. background-size: 100% 100%;
  483. }
  484. .select-bankzh {
  485. width: 230rpx;
  486. // height: 48rpx;
  487. }
  488. .type {
  489. background: #2772FB;
  490. border-radius: 10rpx;
  491. color: white;
  492. box-sizing: border-box;
  493. padding: 4rpx 10rpx;
  494. font-size: 26rpx;
  495. display: flex;
  496. justify-content: center;
  497. align-items: center;
  498. height: 68rpx;
  499. margin-left: 26rpx;
  500. }
  501. .submit-btn {
  502. position: fixed;
  503. bottom: 40rpx;
  504. width: 90%;
  505. background: #2772FB;
  506. color: white;
  507. text-align: center;
  508. margin: 2%;
  509. padding: 30rpx 0;
  510. border-radius: 50rpx;
  511. }
  512. .del-card {
  513. position: absolute;
  514. top: -10rpx;
  515. right: -6rpx;
  516. width: 80rpx;
  517. height: 80rpx;
  518. z-index: 9;
  519. }
  520. .preview-card-img {
  521. // /deep/uni-image>div, uni-image>img {
  522. // transform: scale(1.5) rotate(-90deg);
  523. // }
  524. }
  525. </style>