editDriverCertification.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  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" maxlength="1">
  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" maxlength="18">
  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. if (this.validate()) return
  359. uni.$u.route('/pages/mine/editDriverCertificationNext', {
  360. data: JSON.stringify(this.dataDetails),
  361. });
  362. },
  363. validate() {
  364. // true 为校验不通过
  365. if (uni.$u.test.isEmpty(this.dataDetails.driverName)) {
  366. this.$refs.uToast.show({
  367. type: 'error',
  368. message: "司机姓名不能为空!",
  369. })
  370. return true
  371. }
  372. if (!uni.$u.test.chinese(this.dataDetails.driverName)) {
  373. this.$refs.uToast.show({
  374. type: 'error',
  375. message: "姓名为汉字!",
  376. })
  377. return true
  378. }
  379. if (uni.$u.test.isEmpty(this.dataDetails.driverCall)) {
  380. this.$refs.uToast.show({
  381. type: 'error',
  382. message: "司机称呼不能为空!",
  383. })
  384. return true
  385. }
  386. if (!uni.$u.test.chinese(this.dataDetails.driverCall)) {
  387. this.$refs.uToast.show({
  388. type: 'error',
  389. message: "称呼为汉字!",
  390. })
  391. return true
  392. }
  393. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  394. this.$refs.uToast.show({
  395. type: 'error',
  396. message: "联系电话不能为空!",
  397. })
  398. return true
  399. }
  400. if (!uni.$u.test.mobile(this.dataDetails.driverPhone)) {
  401. this.$refs.uToast.show({
  402. type: 'error',
  403. message: "电话号码格式错误!",
  404. })
  405. return true
  406. }
  407. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  408. this.$refs.uToast.show({
  409. type: 'error',
  410. message: "身份证人像页不能为空!",
  411. })
  412. return true
  413. }
  414. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  415. this.$refs.uToast.show({
  416. type: 'error',
  417. message: "身份证国徽页不能为空!",
  418. })
  419. return true
  420. }
  421. if (uni.$u.test.isEmpty(this.dataDetails.cardValidityDate)) {
  422. this.$refs.uToast.show({
  423. type: 'error',
  424. message: "身份证人有效截止日期不能为空!",
  425. })
  426. return true
  427. }
  428. return false
  429. }
  430. },
  431. };
  432. </script>
  433. <style scoped lang="scss">
  434. /deep/.u-radio {
  435. margin-bottom: 0 !important;
  436. }
  437. .top-head {
  438. background: #2772FB;
  439. height: 80rpx;
  440. width: 100%;
  441. }
  442. .container {
  443. position: relative;
  444. top: -60rpx;
  445. margin: 0 20rpx;
  446. }
  447. .row4-img {
  448. width: 32rpx;
  449. height: 32rpx;
  450. }
  451. .content1,
  452. .content2,
  453. .content3 {
  454. .left-text {
  455. width: 290rpx;
  456. color: #333333;
  457. display: flex;
  458. align-items: center;
  459. }
  460. .row {
  461. border-bottom: 1px solid #EEEEEE;
  462. padding-bottom: 28rpx;
  463. margin-top: 26rpx;
  464. .ch-style {}
  465. }
  466. .row-ch {
  467. padding-right: 180rpx;
  468. box-sizing: border-box;
  469. }
  470. }
  471. .content1-car {
  472. margin-top: 20rpx;
  473. .left-text {
  474. width: 290rpx;
  475. color: #333333;
  476. display: flex;
  477. align-items: center;
  478. }
  479. .row {
  480. border-bottom: 1px solid #EEEEEE;
  481. padding-bottom: 28rpx;
  482. margin-top: 26rpx;
  483. .color {
  484. // background: blue;
  485. width: 340rpx;
  486. }
  487. }
  488. }
  489. .input-ckg {
  490. height: 86rpx;
  491. margin-top: 0 !important;
  492. padding-bottom: 0 !important;
  493. .u-input {
  494. height: 100%;
  495. background: #F7F8FA;
  496. padding-left: 10rpx !important;
  497. padding-right: 85rpx !important;
  498. }
  499. .star {
  500. display: flex;
  501. align-items: center;
  502. margin: 0 10rpx;
  503. }
  504. .input-positon {
  505. position: relative;
  506. }
  507. .position-right {
  508. position: absolute;
  509. right: 20rpx;
  510. top: 0;
  511. width: 60rpx;
  512. height: 50rpx;
  513. bottom: 0;
  514. margin: auto;
  515. }
  516. }
  517. .picture {
  518. margin-top: 20rpx;
  519. background: #F5F6FA;
  520. width: 212rpx;
  521. height: 212rpx;
  522. border-radius: 20rpx;
  523. display: flex;
  524. flex-direction: column;
  525. justify-content: center;
  526. align-items: center;
  527. color: #6A7282;
  528. }
  529. .add-car {
  530. background: #FFFFFF;
  531. margin: 20rpx 50rpx;
  532. border-radius: 50rpx;
  533. display: flex;
  534. justify-content: center;
  535. align-items: center;
  536. padding: 20rpx 0;
  537. .icon {
  538. margin-right: 20rpx;
  539. }
  540. .car-text {
  541. font-size: 36rpx;
  542. font-weight: 700;
  543. color: #2772FB;
  544. }
  545. }
  546. .carlist-item {
  547. margin-top: 20rpx;
  548. padding: 0 20rpx 20rpx 20rpx;
  549. background: white;
  550. border-radius: 10rpx;
  551. position: relative;
  552. .del-car {
  553. position: absolute;
  554. top: 0;
  555. right: 0;
  556. width: 80rpx;
  557. height: 80rpx;
  558. }
  559. }
  560. .content2,
  561. .content3 {
  562. .del-bank {
  563. position: absolute;
  564. top: 0;
  565. right: 0;
  566. width: 80rpx;
  567. height: 80rpx;
  568. }
  569. .picture {
  570. width: 100%;
  571. height: 440rpx;
  572. position: relative;
  573. .text {
  574. margin-top: 20rpx;
  575. }
  576. }
  577. .picture1 {
  578. background: url(../../static/images/mine/zm.png);
  579. background-size: 100% 100%;
  580. }
  581. .picture2 {
  582. background: url(../../static/images/mine/gh.png);
  583. background-size: 100% 100%;
  584. }
  585. .picture3 {
  586. background: url(../../static/images/mine/yhkzm.png);
  587. background-size: 100% 100%;
  588. }
  589. .xj-image {
  590. width: 100rpx;
  591. height: 100rpx;
  592. }
  593. .title {
  594. color: #999999;
  595. margin: 20rpx 0;
  596. }
  597. }
  598. .content3 {
  599. position: relative;
  600. background: white;
  601. margin: 20rpx 0 0 0;
  602. border-radius: 10rpx;
  603. padding: 20rpx;
  604. .khzh-styel {
  605. // width: 350rpx;
  606. }
  607. .type {
  608. background: #2772FB;
  609. border-radius: 10rpx;
  610. color: white;
  611. box-sizing: border-box;
  612. padding: 4rpx 10rpx;
  613. font-size: 26rpx;
  614. display: flex;
  615. justify-content: center;
  616. align-items: center;
  617. }
  618. .select-bankzh {
  619. width: 230rpx;
  620. height: 48rpx;
  621. }
  622. }
  623. .content4 {
  624. display: flex;
  625. justify-content: center;
  626. background: white;
  627. padding: 40rpx 20rpx 50rpx 20rpx;
  628. .next-btn {
  629. background: rgb(39, 114, 251);
  630. width: 90%;
  631. padding: 20rpx 20rpx;
  632. text-align: center;
  633. color: #fff;
  634. border-radius: 50rpx;
  635. }
  636. }
  637. .yzm {}
  638. .yzm-btn {
  639. background: #2772FB;
  640. color: white;
  641. height: 60rpx;
  642. }
  643. .preview-card-img {
  644. // /deep/uni-image>div,
  645. // uni-image>img {
  646. // transform: scale(1.5) rotate(-90deg);
  647. // }
  648. }
  649. .del-card {
  650. position: absolute;
  651. top: -10rpx;
  652. right: -6rpx;
  653. width: 80rpx;
  654. height: 80rpx;
  655. z-index: 9;
  656. }
  657. /deep/.u-radio{
  658. margin-right:10px;
  659. }
  660. </style>