addBankCard.vue 16 KB

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