task#,身份证上传添加验证

This commit is contained in:
2024-09-14 11:35:51 +08:00
parent 4250119cce
commit c22b3ac319

View File

@ -22,7 +22,7 @@
max-count="1" max-count="1"
:preview-size="54" :preview-size="54"
accept="image " accept="image/*"
/> />
<!-- :max-size="5 * 1024 * 1024"--> <!-- :max-size="5 * 1024 * 1024"-->
</div> </div>
@ -173,6 +173,7 @@ export default {
} }
}, },
mounted() { mounted() {
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;
this.driverPhone = this.$route.params?.phone; this.driverPhone = this.$route.params?.phone;
@ -213,11 +214,23 @@ export default {
}, },
methods:{ 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){ isUse(e){
this.states=e this.states=e
}, },
async identityCardFrontHandler(file) { // 上传身份证正面照片 async identityCardFrontHandler(file) { // 上传身份证正面照片
console.log("file",file) console.log("上传身份证正面照片",file)
// 检查文件大小 // 检查文件大小
if (file.file.size > 5 * 1024 * 1024) { if (file.file.size > 5 * 1024 * 1024) {
this.$toast('文件大小不能超过 5MB'); this.$toast('文件大小不能超过 5MB');