addBankCard.vue 14 KB

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