addBankCard.vue 12 KB

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