addBankCard.vue 12 KB

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