addBankCard.vue 15 KB

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