addBankCard.vue 14 KB

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