editDriverCertification.vue 18 KB

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