addBankCard.vue 14 KB

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