addBankCard.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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 :style="{'color':dataDetails.bankDepositBranch?'#000':'#C6CBD5'}" style='font-size:15px;' 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.dataDetails.bankDepositBranch=''
  245. this.imgTypeSelect()
  246. // this.isShowimgType = true
  247. },
  248. validate() {
  249. // true 为校验不通过
  250. // if (uni.$u.test.isEmpty(this.dataDetails.payeeAddressUrl)) {
  251. // this.$refs.uToast.show({
  252. // type: 'error',
  253. // message: "请上传银行卡卡号页!",
  254. // })
  255. // return true
  256. // }
  257. if (uni.$u.test.isEmpty(this.dataDetails.bankCard)) {
  258. this.$refs.uToast.show({
  259. type: 'error',
  260. message: "银行卡卡号不能为空!",
  261. })
  262. return true
  263. }
  264. if (uni.$u.test.rangeLength(this.dataDetails.bankCard,[16,20])) {
  265. this.$refs.uToast.show({
  266. type: 'error',
  267. message: "银行卡号输入错误!",
  268. })
  269. return true
  270. }
  271. if (uni.$u.test.isEmpty(this.dataDetails.bankDeposit)) {
  272. this.$refs.uToast.show({
  273. type: 'error',
  274. message: "开户行不能为空!",
  275. })
  276. return true
  277. }
  278. if (uni.$u.test.rangeLength(this.dataDetails.bankDeposit,[4,25])) {
  279. this.$refs.uToast.show({
  280. type: 'error',
  281. message: "开户行输入错误!",
  282. })
  283. return true
  284. }
  285. if (uni.$u.test.isEmpty(this.dataDetails.bankDepositBranch)) {
  286. this.$refs.uToast.show({
  287. type: 'error',
  288. message: "开户支行不能为空!",
  289. })
  290. return true
  291. }
  292. if (uni.$u.test.rangeLength(this.dataDetails.bankDepositBranch,[4,25])) {
  293. this.$refs.uToast.show({
  294. type: 'error',
  295. message: "开户支行输入错误!",
  296. })
  297. return true
  298. }
  299. if (uni.$u.test.isEmpty(this.dataDetails.cardholderName)) {
  300. this.$refs.uToast.show({
  301. type: 'error',
  302. message: "持卡人姓名不能为空!",
  303. })
  304. return true
  305. }
  306. if (uni.$u.test.isEmpty(this.dataDetails.cardholderIdNumber)) {
  307. this.$refs.uToast.show({
  308. type: 'error',
  309. message: "持卡人身份证号不能为空!",
  310. })
  311. return true
  312. }
  313. },
  314. imgTypeSelect(val) {
  315. console.log(val)
  316. // if (val.name == '相册') {
  317. uni.chooseImage({
  318. count: 1,
  319. // sourceType: this.$helper.chooseImage.sourceType,
  320. success: function(res) {
  321. console.log(JSON.stringify(res.tempFilePaths));
  322. uploadImage('image', res.tempFilePaths[0], 'appData/',
  323. result => {
  324. // 上传成功
  325. console.log('图片地址', result)
  326. _this.$request.baseRequest('get',
  327. '/driverInfo/bankShibie', {
  328. bankImg: result,
  329. }).then(res => {
  330. console.log(res)
  331. _this.dataDetails.payeeAddressUrl = result
  332. _this.columns = []
  333. if (res.data.bankNo) {
  334. _this.dataDetails.bankCard = res.data.bankNo
  335. }
  336. if (res.data.bankName) {
  337. _this.dataDetails.bankDeposit = res.data.bankName
  338. }
  339. // 开户支行LIst
  340. if (res.data.bankNameZhihang) {
  341. _this.columns.push(res.data
  342. .bankNameZhihang)
  343. }
  344. _this.$forceUpdate()
  345. })
  346. .catch(res => {
  347. uni.$u.toast(res.message);
  348. });
  349. }
  350. )
  351. }
  352. });
  353. // } else {
  354. // uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=bank');
  355. // }
  356. },
  357. submit() {
  358. let that = this
  359. // // 获取银行卡颜色
  360. // let _obj = {
  361. // "input":this.dataDetails.payeeAddressUrl
  362. // }
  363. // this.$request.baseRequest('post', '/ClothingColorController/recognition', _obj)
  364. // .then(res => {
  365. // if (res.code == '200') {
  366. // this.dataDetails.cardColor = res.data
  367. // } else {
  368. // uni.$u.toast(res.message);
  369. // }
  370. // })
  371. // .catch(res => {
  372. // uni.$u.toast(res.message);
  373. // });
  374. console.log(this.name)
  375. if (that.validate()) return //校验 511303198809243079
  376. if(!this.submitstatus){
  377. this.submitstatus=true
  378. if (that.dataDetails.cardholderName != this.name&&this.name!='') {
  379. that.$refs.uToast.show({
  380. type: 'error',
  381. message: "收款人须为货主本人!",
  382. })
  383. return
  384. } else {
  385. uni.showLoading({
  386. title: '加载中',
  387. mask: true
  388. })
  389. that.$request.baseRequest('get', '/driverPayeeInfo/bankCradShibie', { //三要素验证
  390. name: that.dataDetails.cardholderName, //持卡人姓名
  391. idCard: this.id, //货主身份证号
  392. accountNo: that.dataDetails.bankCard //卡号
  393. }).then(response => {
  394. if (response.data.distinguishNum == "01") {
  395. that.dataDetails.commonId = uni.getStorageSync("userInfo").id
  396. delete that.dataDetails.payeeAddressUrl
  397. that.$request.baseRequest('post', '/hyCargoOwnerPayeeInfo/api/addPayee',
  398. that.dataDetails).then(res => {
  399. uni.hideLoading()
  400. if (res.code == '200') {
  401. let params = {
  402. type: 'success',
  403. message: "提交成功",
  404. }
  405. this.submitstatus=false
  406. that.$refs.uToast.show({
  407. ...params
  408. })
  409. //uni.$u.route('/pages/mine/manageBankCards/index');
  410. uni.navigateBack({
  411. delta: 1
  412. });
  413. } else {
  414. this.submitstatus=false
  415. uni.$u.toast(res.message);
  416. }
  417. })
  418. .catch(res => {
  419. uni.hideLoading()
  420. this.submitstatus
  421. uni.$u.toast(res.message);
  422. });
  423. } else {
  424. uni.hideLoading()
  425. this.submitstatus=false
  426. uni.$u.toast(response.data.distinguish);
  427. }
  428. })
  429. }
  430. }
  431. },
  432. },
  433. };
  434. </script>
  435. <style scoped lang="scss">
  436. .row4-img {
  437. width: 32rpx;
  438. height: 32rpx;
  439. }
  440. .content {
  441. padding: 20rpx ;
  442. height: calc(100vh - 23vh);
  443. }
  444. .content3 {
  445. background: white;
  446. padding: 20rpx;
  447. box-sizing: border-box;
  448. .left-text {
  449. // background: red;
  450. width: 290rpx;
  451. color: #333333;
  452. display: flex;
  453. align-items: center;
  454. }
  455. .row {
  456. border-bottom: 1px solid #EEEEEE;
  457. padding-bottom: 28rpx;
  458. margin-top: 26rpx;
  459. .ch-style {}
  460. }
  461. .row-ch {
  462. padding-right: 180rpx;
  463. box-sizing: border-box;
  464. }
  465. }
  466. .title {
  467. color: #999999;
  468. margin: 20rpx 0;
  469. }
  470. .picture {
  471. margin-top: 20rpx;
  472. background: #F5F6FA;
  473. border-radius: 10rpx;
  474. display: flex;
  475. flex-direction: column;
  476. justify-content: center;
  477. align-items: center;
  478. color: #6A7282;
  479. width: 100%;
  480. height: 440rpx;
  481. position: relative;
  482. .text {
  483. margin-top: 20rpx;
  484. }
  485. }
  486. .xj-image {
  487. width: 100rpx;
  488. height: 100rpx;
  489. }
  490. .picture3 {
  491. background: url(../../../static/images/mine/yhkzm.png);
  492. background-size: 100% 100%;
  493. }
  494. .select-bankzh {
  495. width: 230rpx;
  496. // height: 48rpx;
  497. }
  498. .type {
  499. background: #2772FB;
  500. border-radius: 10rpx;
  501. color: white;
  502. box-sizing: border-box;
  503. padding: 4rpx 10rpx;
  504. font-size: 26rpx;
  505. display: flex;
  506. justify-content: center;
  507. align-items: center;
  508. height: 68rpx;
  509. }
  510. .submit-btn {
  511. position: fixed;
  512. bottom: 40rpx;
  513. width: 90%;
  514. background: #2772FB;
  515. color: white;
  516. text-align: center;
  517. margin-left: 5%;
  518. padding: 30rpx 0;
  519. border-radius: 50rpx;
  520. }
  521. .del-card {
  522. position: absolute;
  523. top: -10rpx;
  524. right: -6rpx;
  525. width: 80rpx;
  526. height: 80rpx;
  527. z-index: 9;
  528. }
  529. .preview-card-img {
  530. // /deep/uni-image>div, uni-image>img {
  531. // transform: scale(1.5) rotate(-90deg);
  532. // }
  533. }
  534. </style>