addBankCard.vue 13 KB

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