addBankCard.vue 13 KB

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