editDriverCertification.vue 16 KB

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