addBankCard.vue 14 KB

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