editDriverCertification.vue 17 KB

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