身份证正面,文件上传
This commit is contained in:
@ -16,23 +16,29 @@
|
|||||||
<img class="startImg" src="@/assets/start.png" />
|
<img class="startImg" src="@/assets/start.png" />
|
||||||
<span>身份证正面</span>
|
<span>身份证正面</span>
|
||||||
</div>
|
</div>
|
||||||
<van-field label="文件上传">
|
<!-- <el-upload
|
||||||
<template slot="input">
|
:action="baseURL + '/order/uploadImage'"
|
||||||
<!-- 上传组件要兼容安卓,必须设置before-read对文件进行预处理 -->
|
:headers='authorization'
|
||||||
<van-uploader :before-read="beforeRead" accept="image/*" v-model="identityCardFrontList"
|
accept=".png,.jpg,.jpeg,.zip,.rar,.xlsx,.xsavels,.pdf,.PDF,.doc,.docx"
|
||||||
:preview-size="54"
|
:on-success="changeHandle"
|
||||||
:max-count="1" :after-read="identityCardFrontHandler" />
|
:before-upload="beforeAvatarUpload"
|
||||||
</template>
|
class="avatar-uploader"
|
||||||
</van-field>
|
:show-file-list="false"
|
||||||
<!-- <van-uploader
|
|
||||||
|
>
|
||||||
|
<el-button slot="default" style="margin: 15px" size="mini" type="primary"
|
||||||
|
class="add">
|
||||||
|
点击上传
|
||||||
|
</el-button>
|
||||||
|
</el-upload>-->
|
||||||
|
<van-uploader
|
||||||
v-model="identityCardFrontList"
|
v-model="identityCardFrontList"
|
||||||
:before-read="beforeRead"
|
|
||||||
:after-read="identityCardFrontHandler"
|
:after-read="identityCardFrontHandler"
|
||||||
:max-count="1"
|
:max-count="1"
|
||||||
capture="camera"
|
capture="camera"
|
||||||
:preview-size="54"
|
:preview-size="54"
|
||||||
accept="image/png, image/jpeg"
|
accept="image/png, image/jpeg"
|
||||||
/>-->
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="lineBot"></div>
|
<div class="lineBot"></div>
|
||||||
<div class="itemContent">
|
<div class="itemContent">
|
||||||
@ -153,6 +159,8 @@ export default {
|
|||||||
mixins:[myMixins],
|
mixins:[myMixins],
|
||||||
data(){
|
data(){
|
||||||
return{
|
return{
|
||||||
|
baseURL:'',
|
||||||
|
licenseOcrInfo:'',
|
||||||
id:'',
|
id:'',
|
||||||
driverName:"",
|
driverName:"",
|
||||||
driverPhone:"",
|
driverPhone:"",
|
||||||
@ -178,11 +186,22 @@ export default {
|
|||||||
idCardAuthority:'',
|
idCardAuthority:'',
|
||||||
idCardValidStartTime:'',
|
idCardValidStartTime:'',
|
||||||
idCardValidEndTime:'',
|
idCardValidEndTime:'',
|
||||||
token:''
|
authorization:{Authorization: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzb25nIiwiYXVkIjpbInN1cHBsaWVyLWFwcCJdLCJuYmYiOjE3MjY4MDk4MTQsInVzZXJfaW5mbyI6eyJ1c2VySWQiOjU0NjU0LCJwaG9uZSI6IjE3NjMwMDM1NjU4IiwibmFtZSI6InNvbmciLCJzdXBwbGllck5hbWUiOiLkuIrmtbfmtYvor5XkvpvlupTllYYiLCJzdXBwbGllcklkIjozMzA0MSwic3VwcGxpZXJUeXBlIjoyLCJ1c2VybmFtZSI6InNvbmciLCJ1c2VyVHlwZSI6InJlc2N1ZUFwcCIsImRldmljZUlkIjoiMTkwZTM1ZjdlMTRhYzdjMDAwNyIsImF1dGhvcml0aWVzIjpbXX0sInNjb3BlIjpbImFsbCJdLCJpc3MiOiJodHRwczovL3Npbm9hc3Npc3QuY29tIiwiZXhwIjoxNzI2ODk2MjE0LCJpYXQiOjE3MjY4MDk4MTR9.5KTAMXZf8ll6HS4Z49YJQ1HiRvHr79Q1goDAGEtsBmY'},
|
||||||
|
fileList:'',
|
||||||
|
file:'',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.token = localStorage.getItem('token');
|
if (window.location.href.includes('www.sinoassist.com')) {
|
||||||
|
this.baseURL = 'https://api.sinoassist.com'
|
||||||
|
} else if (window.location.href.includes('ccreview.sino-assist.com')) {
|
||||||
|
this.baseURL = 'https://api.sinoassist.com'
|
||||||
|
} else {
|
||||||
|
// this.baseURL = 'https://api1.sino-assist.com'
|
||||||
|
this.baseURL = 'http://localhost:8080'
|
||||||
|
|
||||||
|
}
|
||||||
|
// this.authorization={Authorization: localStorage.getItem('token')}
|
||||||
// this.requestPermissions();
|
// this.requestPermissions();
|
||||||
this.id = this.$route.params?.id;
|
this.id = this.$route.params?.id;
|
||||||
this.driverName = this.$route.params?.name;
|
this.driverName = this.$route.params?.name;
|
||||||
@ -239,29 +258,23 @@ export default {
|
|||||||
isUse(e){
|
isUse(e){
|
||||||
this.states=e
|
this.states=e
|
||||||
},
|
},
|
||||||
// 返回布尔值
|
/* beforeAvatarUpload(file){
|
||||||
beforeRead(file) {
|
this.licenseOcrInfo= file
|
||||||
this.$toast('beforeReadbeforeReadbeforeRead');
|
},
|
||||||
console.log("beforeRead",file)
|
async changeHandle() {
|
||||||
if (file.type !== 'image/jpeg') {
|
|
||||||
this.$toast('请上传 jpg 格式图片');
|
const formData = new FormData()
|
||||||
return false;
|
formData.append('file', this.licenseOcrInfo);
|
||||||
}
|
/!* await this.$post(this.$api.supplier.supplierApproval.recognizeBusinessLicense, formData).then((res) => {
|
||||||
return true;
|
|
||||||
|
|
||||||
|
});*!/
|
||||||
|
},*/
|
||||||
|
beforeRead(){
|
||||||
|
console.log("-----------")
|
||||||
},
|
},
|
||||||
async identityCardFrontHandler(file, detail) { // 上传身份证正面照片
|
async identityCardFrontHandler(file, detail) { // 上传身份证正面照片
|
||||||
console.log("检查文件类型",file, detail)
|
console.log("检查文件类型",file, detail)
|
||||||
// 检查文件类型
|
|
||||||
if (!file.file.type.startsWith('image/')) {
|
|
||||||
this.$toast('请选择图片文件');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log("上传身份证正面照片",file)
|
|
||||||
// 检查文件大小
|
|
||||||
if (file.file.size > 5 * 1024 * 1024) {
|
|
||||||
this.$toast('文件大小不能超过 5MB');
|
|
||||||
// return;
|
|
||||||
}
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("file" , file.file);
|
formData.append("file" , file.file);
|
||||||
let res = await uploadImage(formData)
|
let res = await uploadImage(formData)
|
||||||
|
Reference in New Issue
Block a user