addBankCard.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  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 (uni.$u.test.isEmpty(this.dataDetails.bankDeposit)) {
  264. this.$refs.uToast.show({
  265. type: 'error',
  266. message: "开户行不能为空!",
  267. })
  268. return true
  269. }
  270. if (uni.$u.test.rangeLength(this.dataDetails.bankDeposit,[4,25])) {
  271. this.$refs.uToast.show({
  272. type: 'error',
  273. message: "开户行输入错误!",
  274. })
  275. return true
  276. }
  277. if (uni.$u.test.isEmpty(this.dataDetails.bankDepositBranch)) {
  278. this.$refs.uToast.show({
  279. type: 'error',
  280. message: "开户支行不能为空!",
  281. })
  282. return true
  283. }
  284. if (uni.$u.test.rangeLength(this.dataDetails.bankDepositBranch,[4,25])) {
  285. this.$refs.uToast.show({
  286. type: 'error',
  287. message: "开户支行输入错误!",
  288. })
  289. return true
  290. }
  291. if (uni.$u.test.isEmpty(this.dataDetails.cardholderName)) {
  292. this.$refs.uToast.show({
  293. type: 'error',
  294. message: "持卡人姓名不能为空!",
  295. })
  296. return true
  297. }
  298. if (uni.$u.test.isEmpty(this.dataDetails.cardholderIdNumber)) {
  299. this.$refs.uToast.show({
  300. type: 'error',
  301. message: "持卡人身份证号不能为空!",
  302. })
  303. return true
  304. }
  305. },
  306. //身份证正面
  307. getImgUrl1(src) {
  308. // console.log(src)
  309. // console.log('------------res-----------')
  310. // let that = this;
  311. // that.id[0] = src
  312. // that.id1 = src
  313. // that.certificates = false
  314. // that.personImgs.personImg = that.id[0]
  315. // that.$api.doRequest('get', '/driverViewInfo/personShibie', that
  316. // .personImgs).then(res => {
  317. // if (res.data.data.recPerson != null) {
  318. // if (res.data.data.recPerson != "") {
  319. // that.$set(that.DriverViewInfo, 'driverName', res
  320. // .data.data.recPerson)
  321. // }
  322. // }
  323. // if (res.data.data.recPersonNo != null) {
  324. // if (res.data.data.recPersonNo != "") {
  325. // that.$set(that.DriverViewInfo, 'numberCard', res
  326. // .data.data.recPersonNo)
  327. // }
  328. // }
  329. // }).catch(res => {
  330. // uni.showToast({
  331. // title: res.data.message,
  332. // icon: 'none',
  333. // duration: 2000
  334. // })
  335. // })
  336. },
  337. submit() {
  338. var that = this
  339. // // 获取银行卡颜色
  340. // let _obj = {
  341. // "input":this.dataDetails.payeeAddressUrl
  342. // }
  343. // this.$request.baseRequest('post', '/ClothingColorController/recognition', _obj)
  344. // .then(res => {
  345. // if (res.code == '200') {
  346. // this.dataDetails.cardColor = res.data
  347. // } else {
  348. // uni.$u.toast(res.message);
  349. // }
  350. // })
  351. // .catch(res => {
  352. // uni.$u.toast(res.message);
  353. // });
  354. if (that.validate()) return
  355. if(this.dataDetails.payeeName != uni.getStorageSync("firstAuthentication").driverName){
  356. this.$refs.uToast.show({
  357. type: 'error',
  358. message: "收款人须为司机本人!",
  359. })
  360. return
  361. }else{
  362. this.$request.baseRequest('get', '/driverPayeeInfo/bankCradShibie', {
  363. name: this.dataDetails.payeeName,
  364. idCard: uni.getStorageSync("firstAuthentication").numberCard,
  365. accountNo: this.dataDetails.bankCard
  366. }).then(
  367. res => {
  368. if(res.data.distinguishNum == "01"){
  369. this.dataDetails.commonId = this.userInfo.id
  370. this.$request.baseRequest('post', '/driverPayeeInfo/api/addInfo', this.dataDetails).then(
  371. res => {
  372. if (res.code == '200') {
  373. let params = {
  374. type: 'success',
  375. message: "提交成功",
  376. }
  377. this.$refs.uToast.show({
  378. ...params
  379. })
  380. uni.navigateBack({
  381. delta: 1
  382. });
  383. // uni.$u.route('/pages/mine/manageBankCards/index');
  384. } else {
  385. uni.$u.toast(res.message);
  386. }
  387. })
  388. .catch(res => {
  389. uni.$u.toast(res.message);
  390. });
  391. }else{
  392. uni.$u.toast(res.data.distinguish);
  393. }
  394. })
  395. }
  396. },
  397. },
  398. };
  399. </script>
  400. <style scoped lang="scss">
  401. .row4-img {
  402. width: 32rpx;
  403. height: 32rpx;
  404. }
  405. .content {
  406. padding: 20rpx;
  407. padding-bottom: 50rpx;
  408. height:100vh;
  409. }
  410. .content3 {
  411. background: white;
  412. padding: 20rpx;
  413. box-sizing: border-box;
  414. .left-text {
  415. // background: red;
  416. width: 290rpx;
  417. color: #333333;
  418. display: flex;
  419. align-items: center;
  420. }
  421. .row {
  422. border-bottom: 1px solid #EEEEEE;
  423. padding-bottom: 28rpx;
  424. margin-top: 26rpx;
  425. .ch-style {}
  426. }
  427. .row-ch {
  428. padding-right: 180rpx;
  429. box-sizing: border-box;
  430. }
  431. }
  432. .title {
  433. color: #999999;
  434. margin: 20rpx 0;
  435. }
  436. .picture {
  437. margin-top: 20rpx;
  438. background: #F5F6FA;
  439. border-radius: 10rpx;
  440. display: flex;
  441. flex-direction: column;
  442. justify-content: center;
  443. align-items: center;
  444. color: #6A7282;
  445. width: 100%;
  446. height: 440rpx;
  447. position: relative;
  448. .text {
  449. margin-top: 20rpx;
  450. }
  451. }
  452. .xj-image {
  453. width: 100rpx;
  454. height: 100rpx;
  455. }
  456. .picture3 {
  457. background: url(../../../static/images/mine/yhkzm.png);
  458. background-size: 100% 100%;
  459. }
  460. .select-bankzh {
  461. width: 230rpx;
  462. // height: 48rpx;
  463. }
  464. .type {
  465. background: #2772FB;
  466. border-radius: 10rpx;
  467. color: white;
  468. box-sizing: border-box;
  469. padding: 4rpx 10rpx;
  470. font-size: 26rpx;
  471. display: flex;
  472. justify-content: center;
  473. align-items: center;
  474. height: 68rpx;
  475. }
  476. .submit-btn {
  477. position: fixed;
  478. bottom: 40rpx;
  479. width: 90%;
  480. background: #2772FB;
  481. color: white;
  482. text-align: center;
  483. margin: 2%;
  484. padding: 30rpx 0;
  485. border-radius: 50rpx;
  486. }
  487. .del-card {
  488. position: absolute;
  489. top: -10rpx;
  490. right: -6rpx;
  491. width: 80rpx;
  492. height: 80rpx;
  493. z-index: 9;
  494. }
  495. .preview-card-img {
  496. // /deep/uni-image>div, uni-image>img {
  497. // transform: scale(1.5) rotate(-90deg);
  498. // }
  499. }
  500. </style>