editDriverCertification.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <view class="content">
  3. <view class="top-head"></view>
  4. <view class="container">
  5. <view class="content1 content-other">
  6. <view class="flex row">
  7. <view class="left-text">姓名</view>
  8. <u--input placeholder="输入姓名" inputAlign='left' border="none" v-model="dataDetails.driverName">
  9. </u--input>
  10. </view>
  11. <view class="flex row">
  12. <view class="left-text">性别</view>
  13. <u-radio-group v-model="dataDetails.driverSex" placement="row">
  14. <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in radiolist1" :key="index"
  15. :label="item.name" :name="item.name" @change="radioChange">
  16. </u-radio>
  17. </u-radio-group>
  18. </view>
  19. <view class="flex row row-ch">
  20. <view class="left-text">称呼</view>
  21. <u--input placeholder="输入姓氏" class="ch-style" inputAlign='center' border="none"
  22. v-model="dataDetails.driverCall">
  23. </u--input>
  24. <view class="flex align-center" v-if="dataDetails.driverSex=='男'">先生</view>
  25. <view class="flex align-center" v-else>女士</view>
  26. </view>
  27. <view class="flex row noborder">
  28. <view class="left-text">联系电话</view>
  29. <u--input placeholder="请输入联系电话" inputAlign='left' border="none" v-model="dataDetails.driverPhone">
  30. </u--input>
  31. </view>
  32. <view class="flex row noborder" v-if="dataDetails.driverPhone!=userInfo.phone">
  33. <view class="left-text">验证码</view>
  34. <u--input v-model="dataDetails.verifyCode" border="none" placeholder="请填写验证码"></u--input>
  35. <view class="yzm">
  36. <u-code :seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange"></u-code>
  37. <u-button class="yzm-btn" @tap="getCode">{{tips}}</u-button>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="content2 content-other">
  42. <view class="title">上传身份证人像面</view>
  43. <view @click.stop="uploadImg(1,index)" class="picture picture1" v-if="!dataDetails.cardAddressUrl">
  44. <image class="xj-image" src="@/static/images/mine/ic_shanchuan@2x.png"></image>
  45. <view class="text">上传身份证人像面</view>
  46. </view>
  47. <view v-if="dataDetails.cardAddressUrl" @click.stop="uploadImg(1,index)"
  48. class="preview-card-img picture">
  49. <image class="" :src="dataDetails.cardAddressUrl" mode="aspectFit" style=""></image>
  50. </view>
  51. <view class="title">上传身份证国徽面</view>
  52. <view @click="uploadImg(2,index)" class="picture picture2" v-if="!dataDetails.cardBackAddressUrl">
  53. <image class="xj-image" src="@/static/images/mine/ic_shanchuan@2x.png"></image>
  54. <view class="text">上传身份证国徽面</view>
  55. </view>
  56. <view class="flex row">
  57. <view class="left-text">身份证号</view>
  58. <u--input placeholder="请输入身份证号" inputAlign='left' border="none" v-model="dataDetails.numberCard">
  59. </u--input>
  60. </view>
  61. <view class="flex row noborder">
  62. <view class="left-text">身份证截止日期</view>
  63. <view class="" @click="selectValidityPeriod">
  64. {{dataDetails.cardValidityDate?dataDetails.cardValidityDate:'选择身份证截止日期>'}}
  65. </view>
  66. </view>
  67. </view>
  68. <u-picker :show="isShowcardValidity" ref="uPicker" :columns="validityPeriod"
  69. @confirm="confirmValidityPeriod" @change="changeHandler">
  70. </u-picker>
  71. <u-action-sheet :actions="$helper.imgTypeList" :title="$helper.imgType" :show="isShowimgType"
  72. @select="imgTypeSelect" :closeOnClickOverlay="true" :closeOnClickAction="true"
  73. @close="isShowimgType=false">
  74. </u-action-sheet>
  75. <u-toast ref="uToast"></u-toast>
  76. </view>
  77. <view class="content4">
  78. <view class="next-btn" @click="next()">
  79. 下一步
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import upload from '@/components/upload.vue';
  86. import uploadImage from '@/components/ossutil/uploadFile.js';
  87. var _this
  88. import {
  89. mapState
  90. } from 'vuex';
  91. export default {
  92. components: {
  93. upload
  94. },
  95. data() {
  96. return {
  97. canvasSiz: {
  98. width: 188,
  99. height: 273
  100. },
  101. tips: '',
  102. // refCode: null,
  103. seconds: 30,
  104. radiolist1: [{
  105. name: '男',
  106. disabled: false
  107. },
  108. {
  109. name: '女',
  110. disabled: false
  111. },
  112. ],
  113. validityPeriod: [],
  114. isShowcardValidity: false,
  115. uploadType: '',
  116. isShowimgType: false,
  117. dataDetails: {
  118. commonId: '',
  119. driverName: '',
  120. driverSex: '',
  121. driverCall: '',
  122. driverPhone: '',
  123. numberCard: '',
  124. cardAddressUrl: '',
  125. cardBackAddressUrl: '',
  126. cardValidityDate: '',
  127. driverType: '',
  128. driverLicenseHomePage: '',
  129. driverLicenseBackPage: '',
  130. driverLicenseValidityDate: '',
  131. drivingLicenseHomePage: '',
  132. drivingLicenseBackPage: '',
  133. drivingLicenseValidityDate: '',
  134. trailerLicenseHomePage: '',
  135. trailerLicenseBackPage: '',
  136. trailerLicenseValidityDate: '',
  137. qualificationCertificate: '',
  138. qualificationCertificateValidityDate: '',
  139. operationCertificate: '',
  140. operationCertificateValidityDate: '',
  141. trailerOperationCertificate: '',
  142. trailerOperationCertificateValidityDate: '',
  143. },
  144. action: this.$helper.ossUploadUrl,
  145. // maxSize: 50 * 1024 * 1024, //限制文件大小 50M
  146. // isAdd: true,
  147. imagesrc: null
  148. };
  149. },
  150. onLoad() {
  151. _this = this;
  152. console.log(this.userInfo)
  153. //获取截止日期List数据
  154. this.validityPeriod = this.$helper.makeValidityPeriod(0)
  155. // this.dataDetails.driverPhone = this.userInfo.phone
  156. this.dataDetails.commonId = this.userInfo.id
  157. //获取认证状态
  158. this.getAuthenticationStatus()
  159. },
  160. computed: {
  161. ...mapState(['hasLogin', 'userInfo']),
  162. },
  163. methods: {
  164. changeHandler(e) {
  165. const {
  166. columnIndex,
  167. value,
  168. values,
  169. index,
  170. picker = this.$refs.uPicker
  171. } = e
  172. // if (columnIndex === 0) {
  173. // debugger
  174. // if (e.index != 0) {
  175. // picker.setColumnValues(1, this.validityPeriod[1].shift())
  176. // }
  177. // } else if (columnIndex === 1) {
  178. // if (e.index != 0) {
  179. // picker.setColumnValues(2, this.validityPeriod[2].shift())
  180. // }
  181. // }
  182. },
  183. codeChange(text) {
  184. this.tips = text;
  185. },
  186. getCode() {
  187. if (/^0?1[3|4|5|6|7|8][0-9]\d{8}$/.test(this.dataDetails.driverPhone)) {
  188. if (this.$refs.uCode.canGetCode) {
  189. // 模拟向后端请求验证码
  190. uni.showLoading({
  191. title: '正在获取验证码'
  192. })
  193. _this.$request.baseRequest('get', '/commonUser/sendVerifyCode', {
  194. phone: this.dataDetails.driverPhone
  195. }).then(res => {
  196. uni.hideLoading();
  197. // 这里此提示会被this.start()方法中的提示覆盖
  198. uni.$u.toast('验证码已发送');
  199. // 通知验证码组件内部开始倒计时
  200. this.$refs.uCode.start();
  201. })
  202. .catch(res => {
  203. uni.$u.toast(res.message);
  204. });
  205. // setTimeout(() => {
  206. // }, 2000);
  207. } else {
  208. uni.$u.toast('倒计时结束后再发送');
  209. }
  210. } else {
  211. uni.$u.toast('请输入正确手机号');
  212. }
  213. },
  214. end() {
  215. // uni.$u.toast('倒计时结束');
  216. },
  217. start() {
  218. // uni.$u.toast('倒计时开始');
  219. },
  220. // 性别切换
  221. radioChange(n) {
  222. console.log('radioChange', n);
  223. this.dataDetails.driverSex = n
  224. },
  225. //判断是否是初次认证
  226. getAuthenticationStatus() {
  227. this.$request.baseRequest('', '/driverInfo/firstAuthentication', {
  228. driverPhone: this.userInfo.phone,
  229. }).then(res => {
  230. if (res.code == 200) {
  231. this.dataDetails = res.data
  232. // this.dataDetails.driverName = res.data.driverName
  233. // this.dataDetails.driverSex = res.data.driverSex
  234. // this.dataDetails.driverCall = res.data.driverCall
  235. // this.dataDetails.driverPhone = res.data.driverPhone
  236. // this.dataDetails.cardAddressUrl = res.data.cardAddressUrl
  237. // this.dataDetails.cardBackAddressUrl = res.data.cardBackAddressUrl
  238. // this.dataDetails.numberCard = res.data.numberCard
  239. // this.dataDetails.cardValidityDate = res.data.cardValidityDate
  240. }
  241. })
  242. .catch(res => {
  243. uni.$u.toast(res.message);
  244. });
  245. },
  246. confirmValidityPeriod(e) {
  247. console.log('confirm', e)
  248. if (e.value[0] == '长期') {
  249. this.dataDetails.cardValidityDate = e.value[0]
  250. } else {
  251. if (!e.value[1] || !e.value[2]) {
  252. this.$refs.uToast.show({
  253. type: 'error',
  254. message: "日期格式错误,请重新选择!",
  255. })
  256. return
  257. }
  258. this.dataDetails.cardValidityDate = e.value[0] + '-' + e.value[1] + '-' + e.value[2]
  259. }
  260. this.isShowcardValidity = false
  261. },
  262. selectValidityPeriod() {
  263. this.isShowcardValidity = true
  264. },
  265. //设置图片
  266. setImage(e) {
  267. console.log(e);
  268. //显示在页面
  269. //this.imagesrc = e.path;
  270. if (e.dotype == 'idphoto') {
  271. _this.zjzClipper(e.path);
  272. } else if (e.dotype == 'watermark') {
  273. _this.watermark(e.path);
  274. } else {
  275. _this.savePhoto(e.path);
  276. }
  277. },
  278. //保存图片到相册,方便核查
  279. savePhoto(path) {
  280. this.imagesrc = path;
  281. // this.dataDetails.cardAddressUrl = path
  282. uploadImage(path, 'appData/',
  283. result => {
  284. // 上传成功
  285. console.log('图片地址', result)
  286. this.dataDetails.cardAddressUrl = result
  287. }
  288. )
  289. },
  290. uploadImg(type, index) {
  291. this.uploadType = type
  292. this.isShowimgType = true
  293. this.index = index
  294. },
  295. // 上传图片
  296. imgTypeSelect(val) {
  297. console.log(val)
  298. console.log(this.uploadType)
  299. if (val.name == '相册') {
  300. uni.chooseImage({
  301. count: 1,
  302. sourceType: this.$helper.chooseImage.sourceType,
  303. success: function(res) {
  304. console.log(JSON.stringify(res.tempFilePaths));
  305. uploadImage(res.tempFilePaths[0], 'appData/',
  306. result => {
  307. // 上传成功回调函数
  308. console.log('图片地址', result)
  309. switch (_this.uploadType) {
  310. // 身份正面
  311. case 1:
  312. _this.dataDetails.cardAddressUrl = result
  313. // 识别
  314. _this.$request.baseRequest('get',
  315. '/driverInfo/personShibie', {
  316. personImg: result,
  317. }).then(res => {
  318. _this.dataDetails.numberCard = res.data.recPersonNo
  319. })
  320. .catch(res => {
  321. uni.$u.toast(res.message);
  322. });
  323. break
  324. // 身份反面
  325. case 2:
  326. _this.dataDetails.cardBackAddressUrl = result
  327. break
  328. case 3:
  329. break;
  330. }
  331. }
  332. )
  333. }
  334. });
  335. } else {
  336. switch (this.uploadType) {
  337. case 0:
  338. break
  339. case 1:
  340. uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=idcardface');
  341. console.log('身份正面')
  342. break
  343. case 2:
  344. uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=badge');
  345. console.log('身份反面')
  346. break
  347. case 3:
  348. break
  349. case 4:
  350. }
  351. }
  352. },
  353. next(val) {
  354. console.log(111111111111)
  355. // if (this.validate()) return
  356. uni.$u.route('/pages/mine/editDriverCertificationNext', {
  357. data: JSON.stringify(this.dataDetails),
  358. });
  359. },
  360. validate() {
  361. // true 为校验不通过
  362. if (uni.$u.test.isEmpty(this.dataDetails.driverName)) {
  363. this.$refs.uToast.show({
  364. type: 'error',
  365. message: "司机姓名不能为空!",
  366. })
  367. return true
  368. }
  369. if (!uni.$u.test.chinese(this.dataDetails.driverName)) {
  370. this.$refs.uToast.show({
  371. type: 'error',
  372. message: "姓名为汉字!",
  373. })
  374. return true
  375. }
  376. if (uni.$u.test.isEmpty(this.dataDetails.driverCall)) {
  377. this.$refs.uToast.show({
  378. type: 'error',
  379. message: "司机称呼不能为空!",
  380. })
  381. return true
  382. }
  383. if (!uni.$u.test.chinese(this.dataDetails.driverCall)) {
  384. this.$refs.uToast.show({
  385. type: 'error',
  386. message: "称呼为汉字!",
  387. })
  388. return true
  389. }
  390. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  391. this.$refs.uToast.show({
  392. type: 'error',
  393. message: "联系电话不能为空!",
  394. })
  395. return true
  396. }
  397. if (!uni.$u.test.mobile(this.dataDetails.driverPhone)) {
  398. this.$refs.uToast.show({
  399. type: 'error',
  400. message: "电话号码格式错误!",
  401. })
  402. return true
  403. }
  404. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  405. this.$refs.uToast.show({
  406. type: 'error',
  407. message: "身份证人像页不能为空!",
  408. })
  409. return true
  410. }
  411. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  412. this.$refs.uToast.show({
  413. type: 'error',
  414. message: "身份证国徽页不能为空!",
  415. })
  416. return true
  417. }
  418. if (uni.$u.test.isEmpty(this.dataDetails.cardValidityDate)) {
  419. this.$refs.uToast.show({
  420. type: 'error',
  421. message: "身份证人有效截止日期不能为空!",
  422. })
  423. return true
  424. }
  425. return false
  426. }
  427. },
  428. };
  429. </script>
  430. <style scoped lang="scss">
  431. /deep/.u-radio {
  432. margin-bottom: 0 !important;
  433. }
  434. .top-head {
  435. background: #2772FB;
  436. height: 80rpx;
  437. width: 100%;
  438. }
  439. .container {
  440. position: relative;
  441. top: -60rpx;
  442. margin: 0 20rpx;
  443. }
  444. .row4-img {
  445. width: 32rpx;
  446. height: 32rpx;
  447. }
  448. .content1,
  449. .content2,
  450. .content3 {
  451. .left-text {
  452. width: 290rpx;
  453. color: #333333;
  454. display: flex;
  455. align-items: center;
  456. }
  457. .row {
  458. border-bottom: 1px solid #EEEEEE;
  459. padding-bottom: 28rpx;
  460. margin-top: 26rpx;
  461. .ch-style {}
  462. }
  463. .row-ch {
  464. padding-right: 180rpx;
  465. box-sizing: border-box;
  466. }
  467. }
  468. .content1-car {
  469. margin-top: 20rpx;
  470. .left-text {
  471. width: 290rpx;
  472. color: #333333;
  473. display: flex;
  474. align-items: center;
  475. }
  476. .row {
  477. border-bottom: 1px solid #EEEEEE;
  478. padding-bottom: 28rpx;
  479. margin-top: 26rpx;
  480. .color {
  481. // background: blue;
  482. width: 340rpx;
  483. }
  484. }
  485. }
  486. .input-ckg {
  487. height: 86rpx;
  488. margin-top: 0 !important;
  489. padding-bottom: 0 !important;
  490. .u-input {
  491. height: 100%;
  492. background: #F7F8FA;
  493. padding-left: 10rpx !important;
  494. padding-right: 85rpx !important;
  495. }
  496. .star {
  497. display: flex;
  498. align-items: center;
  499. margin: 0 10rpx;
  500. }
  501. .input-positon {
  502. position: relative;
  503. }
  504. .position-right {
  505. position: absolute;
  506. right: 20rpx;
  507. top: 0;
  508. width: 60rpx;
  509. height: 50rpx;
  510. bottom: 0;
  511. margin: auto;
  512. }
  513. }
  514. .picture {
  515. margin-top: 20rpx;
  516. background: #F5F6FA;
  517. width: 212rpx;
  518. height: 212rpx;
  519. border-radius: 20rpx;
  520. display: flex;
  521. flex-direction: column;
  522. justify-content: center;
  523. align-items: center;
  524. color: #6A7282;
  525. }
  526. .add-car {
  527. background: #FFFFFF;
  528. margin: 20rpx 50rpx;
  529. border-radius: 50rpx;
  530. display: flex;
  531. justify-content: center;
  532. align-items: center;
  533. padding: 20rpx 0;
  534. .icon {
  535. margin-right: 20rpx;
  536. }
  537. .car-text {
  538. font-size: 36rpx;
  539. font-weight: 700;
  540. color: #2772FB;
  541. }
  542. }
  543. .carlist-item {
  544. margin-top: 20rpx;
  545. padding: 0 20rpx 20rpx 20rpx;
  546. background: white;
  547. border-radius: 10rpx;
  548. position: relative;
  549. .del-car {
  550. position: absolute;
  551. top: 0;
  552. right: 0;
  553. width: 80rpx;
  554. height: 80rpx;
  555. }
  556. }
  557. .content2,
  558. .content3 {
  559. .del-bank {
  560. position: absolute;
  561. top: 0;
  562. right: 0;
  563. width: 80rpx;
  564. height: 80rpx;
  565. }
  566. .picture {
  567. width: 100%;
  568. height: 440rpx;
  569. position: relative;
  570. .text {
  571. margin-top: 20rpx;
  572. }
  573. }
  574. .picture1 {
  575. background: url(../../static/images/mine/zm.png);
  576. background-size: 100% 100%;
  577. }
  578. .picture2 {
  579. background: url(../../static/images/mine/gh.png);
  580. background-size: 100% 100%;
  581. }
  582. .picture3 {
  583. background: url(../../static/images/mine/yhkzm.png);
  584. background-size: 100% 100%;
  585. }
  586. .xj-image {
  587. width: 100rpx;
  588. height: 100rpx;
  589. }
  590. .title {
  591. color: #999999;
  592. margin: 20rpx 0;
  593. }
  594. }
  595. .content3 {
  596. position: relative;
  597. background: white;
  598. margin: 20rpx 0 0 0;
  599. border-radius: 10rpx;
  600. padding: 20rpx;
  601. .khzh-styel {
  602. // width: 350rpx;
  603. }
  604. .type {
  605. background: #2772FB;
  606. border-radius: 10rpx;
  607. color: white;
  608. box-sizing: border-box;
  609. padding: 4rpx 10rpx;
  610. font-size: 26rpx;
  611. display: flex;
  612. justify-content: center;
  613. align-items: center;
  614. }
  615. .select-bankzh {
  616. width: 230rpx;
  617. height: 48rpx;
  618. }
  619. }
  620. .content4 {
  621. display: flex;
  622. justify-content: center;
  623. background: white;
  624. padding: 40rpx 20rpx 50rpx 20rpx;
  625. .next-btn {
  626. background: #F1F3F6;
  627. width: 90%;
  628. padding: 20rpx 20rpx;
  629. text-align: center;
  630. color: #C5CAD4;
  631. border-radius: 50rpx;
  632. }
  633. }
  634. .yzm {}
  635. .yzm-btn {
  636. background: #2772FB;
  637. color: white;
  638. height: 60rpx;
  639. }
  640. .preview-card-img {
  641. /deep/uni-image>div,
  642. uni-image>img {
  643. transform: scale(1.5) rotate(-90deg);
  644. }
  645. }
  646. .del-card {
  647. position: absolute;
  648. top: -10rpx;
  649. right: -6rpx;
  650. width: 80rpx;
  651. height: 80rpx;
  652. z-index: 9;
  653. }
  654. </style>