diff --git a/src/views/index/driverAdd.vue b/src/views/index/driverAdd.vue index f7c4d1da..0501e6ad 100644 --- a/src/views/index/driverAdd.vue +++ b/src/views/index/driverAdd.vue @@ -16,29 +16,28 @@ 身份证正面 - - + +
@@ -154,6 +153,8 @@ import {saveDriver, uploadImage, ocrHandler} from "@/api/mine" import TwoCommonBtn from "@/components/twoBtnCommon.vue" import CellGroup from "@/components/cellGroup.vue" import {formatDate1} from "@/utils/common" +import {ImagePreview} from "vant"; + export default { name: "driverAdd", mixins:[myMixins], @@ -187,9 +188,8 @@ export default { idCardValidStartTime:'', idCardValidEndTime:'', authorization:{Authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzb25nIiwiYXVkIjpbInN1cHBsaWVyLWFwcCJdLCJuYmYiOjE3MjY4MDk4MTQsInVzZXJfaW5mbyI6eyJ1c2VySWQiOjU0NjU0LCJwaG9uZSI6IjE3NjMwMDM1NjU4IiwibmFtZSI6InNvbmciLCJzdXBwbGllck5hbWUiOiLkuIrmtbfmtYvor5XkvpvlupTllYYiLCJzdXBwbGllcklkIjozMzA0MSwic3VwcGxpZXJUeXBlIjoyLCJ1c2VybmFtZSI6InNvbmciLCJ1c2VyVHlwZSI6InJlc2N1ZUFwcCIsImRldmljZUlkIjoiMTkwZTM1ZjdlMTRhYzdjMDAwNyIsImF1dGhvcml0aWVzIjpbXX0sInNjb3BlIjpbImFsbCJdLCJpc3MiOiJodHRwczovL3Npbm9hc3Npc3QuY29tIiwiZXhwIjoxNzI2ODk2MjE0LCJpYXQiOjE3MjY4MDk4MTR9.5KTAMXZf8ll6HS4Z49YJQ1HiRvHr79Q1goDAGEtsBmY'}, - fileList:'', - file:'', - } + // authorization:{Authorization:''}, + } }, mounted() { if (window.location.href.includes('www.sinoassist.com')) { @@ -201,8 +201,8 @@ export default { this.baseURL = 'http://localhost:8080' } - // this.authorization={Authorization: localStorage.getItem('token')} - // this.requestPermissions(); + let token=localStorage.getItem('token') + this.authorization.Authorization=token; this.id = this.$route.params?.id; this.driverName = this.$route.params?.name; this.driverPhone = this.$route.params?.phone; @@ -243,35 +243,45 @@ export default { }, methods:{ - /* requestPermissions() { - // 请求访问摄像头的权限 - if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) { - navigator.mediaDevices.getUserMedia({ video: true }) - .then(() => { - console.log('Camera permission granted'); - }) - .catch((error) => { - console.error('Camera permission denied:', error); - }); - } - },*/ isUse(e){ this.states=e }, - /* beforeAvatarUpload(file){ - this.licenseOcrInfo= file + checkImgType(file) { + const FileExt = file.name.replace(/.+\./, ""); + const isLt5M = file.size / 1024 / 1024 < 5; + const whiteList = ['png', 'jpeg', 'jpg']; + if (whiteList.indexOf(FileExt.toLowerCase()) === -1) { + this.$message.error("请上传正确的文件格式:" + whiteList.join('、')) + return false + } + if (!isLt5M) { + this.$message.error('上传图片大小不能超过 5MB!'); + return false + } }, - async changeHandle() { - - const formData = new FormData() - formData.append('file', this.licenseOcrInfo); - /!* await this.$post(this.$api.supplier.supplierApproval.recognizeBusinessLicense, formData).then((res) => { - - - });*!/ - },*/ - beforeRead(){ - console.log("-----------") + handleRemove(file, fileList) { + console.log(file, fileList); + this.identityCardFront = '' + }, + handlePreview(file) { + ImagePreview({ + images: this.identityCardFront, + startPosition: 1, + closeable: true, + }); + console.log(file); + }, + async changeHandle(response) { + if (response.success === true) { + this.$toast('上传成功') + // this.form.identityCardFront = response.data; + // await this.ocrFrontHandler() + this.identityCardFront = response.data; + console.log("this.identityCardFront",this.identityCardFront) + await this.idCardOcrHandler(); + } else { + this.$toast('上传失败') + } }, async identityCardFrontHandler(file, detail) { // 上传身份证正面照片 console.log("检查文件类型",file, detail)