editDriverCertification.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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. this.imgTypeSelect()
  318. },
  319. // 上传图片
  320. imgTypeSelect() {
  321. // console.log(val)
  322. console.log(this.uploadType)
  323. // if (val.name == '相册') {
  324. uni.chooseImage({
  325. count: 1,
  326. // sourceType: this.$helper.chooseImage.sourceType,
  327. success: function(res) {
  328. console.log(JSON.stringify(res.tempFilePaths));
  329. uploadImage('image',res.tempFilePaths[0], 'appData/',
  330. result => {
  331. // 上传成功回调函数
  332. console.log('图片地址', result)
  333. switch (_this.uploadType) {
  334. // 身份正面
  335. case 1:
  336. _this.dataDetails.cardAddressUrl = result
  337. // 识别
  338. _this.$request.baseRequest('get',
  339. '/driverInfo/personShibie', {
  340. personImg: result,
  341. flag:1
  342. }).then(res => {
  343. _this.dataDetails.numberCard = res.data.recPersonNo
  344. })
  345. .catch(res => {
  346. uni.$u.toast(res.message);
  347. });
  348. break
  349. // 身份反面
  350. case 2:
  351. _this.dataDetails.cardBackAddressUrl = result
  352. // 识别
  353. _this.$request.baseRequest('get',
  354. '/driverInfo/personShibie', {
  355. personImg: result,
  356. flag:2
  357. }).then(res => {
  358. if(res.data.idCardValidity){
  359. let date = res.data.idCardValidity.split("-")[1]
  360. _this.dataDetails.cardValidityDate = date.replace('.', '-').replace('.', '-')
  361. }
  362. })
  363. .catch(res => {
  364. uni.$u.toast(res.message);
  365. });
  366. break
  367. case 3:
  368. break;
  369. }
  370. }
  371. )
  372. }
  373. });
  374. // } else {
  375. // switch (this.uploadType) {
  376. // case 0:
  377. // break
  378. // case 1:
  379. // uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=idcardface');
  380. // console.log('身份正面')
  381. // break
  382. // case 2:
  383. // uni.$u.route('/pages/mine/camera/idcard/idcard?dotype=badge');
  384. // console.log('身份反面')
  385. // break
  386. // case 3:
  387. // break
  388. // case 4:
  389. // }
  390. // }
  391. },
  392. next(val) {
  393. if (this.validate()) return
  394. uni.$u.route('/pages/mine/editDriverCertificationNext', {
  395. data: JSON.stringify(this.dataDetails),
  396. });
  397. },
  398. validate() {
  399. // true 为校验不通过
  400. if (uni.$u.test.isEmpty(this.dataDetails.driverName)) {
  401. this.$refs.uToast.show({
  402. type: 'error',
  403. message: "司机姓名不能为空!",
  404. })
  405. return true
  406. }
  407. if (!uni.$u.test.chinese(this.dataDetails.driverName)) {
  408. this.$refs.uToast.show({
  409. type: 'error',
  410. message: "姓名为汉字!",
  411. })
  412. return true
  413. }
  414. if (uni.$u.test.isEmpty(this.dataDetails.driverCall)) {
  415. this.$refs.uToast.show({
  416. type: 'error',
  417. message: "司机称呼不能为空!",
  418. })
  419. return true
  420. }
  421. if (!uni.$u.test.chinese(this.dataDetails.driverCall)) {
  422. this.$refs.uToast.show({
  423. type: 'error',
  424. message: "称呼为汉字!",
  425. })
  426. return true
  427. }
  428. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  429. this.$refs.uToast.show({
  430. type: 'error',
  431. message: "联系电话不能为空!",
  432. })
  433. return true
  434. }
  435. if (!uni.$u.test.mobile(this.dataDetails.driverPhone)) {
  436. this.$refs.uToast.show({
  437. type: 'error',
  438. message: "电话号码格式错误!",
  439. })
  440. return true
  441. }
  442. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  443. this.$refs.uToast.show({
  444. type: 'error',
  445. message: "身份证人像页不能为空!",
  446. })
  447. return true
  448. }
  449. if (uni.$u.test.isEmpty(this.dataDetails.driverPhone)) {
  450. this.$refs.uToast.show({
  451. type: 'error',
  452. message: "身份证国徽页不能为空!",
  453. })
  454. return true
  455. }
  456. if (uni.$u.test.isEmpty(this.dataDetails.cardValidityDate)) {
  457. this.$refs.uToast.show({
  458. type: 'error',
  459. message: "身份证人有效截止日期不能为空!",
  460. })
  461. return true
  462. }
  463. return false
  464. }
  465. },
  466. };
  467. </script>
  468. <style scoped lang="scss">
  469. /deep/.u-radio {
  470. margin-bottom: 0 !important;
  471. }
  472. .top-head {
  473. background: #2772FB;
  474. height: 80rpx;
  475. width: 100%;
  476. }
  477. .container {
  478. position: relative;
  479. top: -60rpx;
  480. margin: 0 20rpx;
  481. }
  482. .row4-img {
  483. width: 32rpx;
  484. height: 32rpx;
  485. }
  486. .content1,
  487. .content2,
  488. .content3 {
  489. .left-text {
  490. width: 290rpx;
  491. color: #333333;
  492. display: flex;
  493. align-items: center;
  494. }
  495. .row {
  496. border-bottom: 1px solid #EEEEEE;
  497. padding-bottom: 28rpx;
  498. margin-top: 26rpx;
  499. .ch-style {}
  500. }
  501. .row-ch {
  502. padding-right: 180rpx;
  503. box-sizing: border-box;
  504. }
  505. }
  506. .content1-car {
  507. margin-top: 20rpx;
  508. .left-text {
  509. width: 290rpx;
  510. color: #333333;
  511. display: flex;
  512. align-items: center;
  513. }
  514. .row {
  515. border-bottom: 1px solid #EEEEEE;
  516. padding-bottom: 28rpx;
  517. margin-top: 26rpx;
  518. .color {
  519. // background: blue;
  520. width: 340rpx;
  521. }
  522. }
  523. }
  524. .input-ckg {
  525. height: 86rpx;
  526. margin-top: 0 !important;
  527. padding-bottom: 0 !important;
  528. .u-input {
  529. height: 100%;
  530. background: #F7F8FA;
  531. padding-left: 10rpx !important;
  532. padding-right: 85rpx !important;
  533. }
  534. .star {
  535. display: flex;
  536. align-items: center;
  537. margin: 0 10rpx;
  538. }
  539. .input-positon {
  540. position: relative;
  541. }
  542. .position-right {
  543. position: absolute;
  544. right: 20rpx;
  545. top: 0;
  546. width: 60rpx;
  547. height: 50rpx;
  548. bottom: 0;
  549. margin: auto;
  550. }
  551. }
  552. .picture {
  553. margin-top: 20rpx;
  554. background: #F5F6FA;
  555. width: 212rpx;
  556. height: 212rpx;
  557. border-radius: 20rpx;
  558. display: flex;
  559. flex-direction: column;
  560. justify-content: center;
  561. align-items: center;
  562. color: #6A7282;
  563. }
  564. .add-car {
  565. background: #FFFFFF;
  566. margin: 20rpx 50rpx;
  567. border-radius: 50rpx;
  568. display: flex;
  569. justify-content: center;
  570. align-items: center;
  571. padding: 20rpx 0;
  572. .icon {
  573. margin-right: 20rpx;
  574. }
  575. .car-text {
  576. font-size: 36rpx;
  577. font-weight: 700;
  578. color: #2772FB;
  579. }
  580. }
  581. .carlist-item {
  582. margin-top: 20rpx;
  583. padding: 0 20rpx 20rpx 20rpx;
  584. background: white;
  585. border-radius: 10rpx;
  586. position: relative;
  587. .del-car {
  588. position: absolute;
  589. top: 0;
  590. right: 0;
  591. width: 80rpx;
  592. height: 80rpx;
  593. }
  594. }
  595. .content2,
  596. .content3 {
  597. .del-bank {
  598. position: absolute;
  599. top: 0;
  600. right: 0;
  601. width: 80rpx;
  602. height: 80rpx;
  603. }
  604. .picture {
  605. width: 100%;
  606. height: 440rpx;
  607. position: relative;
  608. .text {
  609. margin-top: 20rpx;
  610. }
  611. }
  612. .picture1 {
  613. background: url(../../static/images/mine/zm.png);
  614. background-size: 100% 100%;
  615. }
  616. .picture2 {
  617. background: url(../../static/images/mine/gh.png);
  618. background-size: 100% 100%;
  619. }
  620. .picture3 {
  621. background: url(../../static/images/mine/yhkzm.png);
  622. background-size: 100% 100%;
  623. }
  624. .xj-image {
  625. width: 100rpx;
  626. height: 100rpx;
  627. }
  628. .title {
  629. color: #999999;
  630. margin: 20rpx 0;
  631. }
  632. }
  633. .content3 {
  634. position: relative;
  635. background: white;
  636. margin: 20rpx 0 0 0;
  637. border-radius: 10rpx;
  638. padding: 20rpx;
  639. .khzh-styel {
  640. // width: 350rpx;
  641. }
  642. .type {
  643. background: #2772FB;
  644. border-radius: 10rpx;
  645. color: white;
  646. box-sizing: border-box;
  647. padding: 4rpx 10rpx;
  648. font-size: 26rpx;
  649. display: flex;
  650. justify-content: center;
  651. align-items: center;
  652. }
  653. .select-bankzh {
  654. width: 230rpx;
  655. height: 48rpx;
  656. }
  657. }
  658. .content4 {
  659. display: flex;
  660. justify-content: center;
  661. background: white;
  662. padding: 40rpx 20rpx 50rpx 20rpx;
  663. .next-btn {
  664. background: rgb(39, 114, 251);
  665. width: 90%;
  666. padding: 20rpx 20rpx;
  667. text-align: center;
  668. color: #fff;
  669. border-radius: 50rpx;
  670. }
  671. }
  672. .yzm {}
  673. .yzm-btn {
  674. background: #2772FB;
  675. color: white;
  676. height: 60rpx;
  677. }
  678. .preview-card-img {
  679. // /deep/uni-image>div,
  680. // uni-image>img {
  681. // transform: scale(1.5) rotate(-90deg);
  682. // }
  683. }
  684. .del-card {
  685. position: absolute;
  686. top: -10rpx;
  687. right: -6rpx;
  688. width: 80rpx;
  689. height: 80rpx;
  690. z-index: 9;
  691. }
  692. /deep/.u-radio{
  693. margin-right:10px;
  694. }
  695. </style>