CRM_26-08-05#story#9126,车辆管理、服务商管理系统需求

This commit is contained in:
zlf
2026-08-04 17:57:26 +08:00
parent 1f0d537c80
commit ae77c69fe9
2 changed files with 35 additions and 25 deletions
+2 -2
View File
@@ -203,8 +203,8 @@ export default {
} }
} catch (e) { } catch (e) {
// 权限拒绝或相机不可用 → 通知父组件降级为系统选择器 // 权限拒绝或相机不可用 → 通知父组件降级为系统选择器
console.error('getUserMedia error:', e) console.warn('getUserMedia error:', e && (e.name || e.message || e))
this.$emit('fallback') this.$emit('fallback', e)
} }
}, },
stopCamera() { stopCamera() {
+32 -22
View File
@@ -959,14 +959,37 @@ export default {
stream.getTracks().forEach(t => t.stop()) stream.getTracks().forEach(t => t.stop())
this.cameraGuideVisible = true this.cameraGuideVisible = true
} catch (e) { } catch (e) {
console.error('probe getUserMedia error:', e) console.warn('probe getUserMedia error:', e && (e.name || e.message || e))
if (e && (e.name === 'NotAllowedError' || e.name === 'SecurityError')) { this.handleCameraFail(e)
// 权限被拒:弹框询问(重试/从相册选择)
this.onCameraFallback()
} else {
// 无摄像头、被占用等其他异常:直接降级系统选择器
this.triggerNativeUpload(type)
} }
},
isCameraPermissionError(e) { // 是否为相机权限类错误
return !!(e && (e.name === 'NotAllowedError' || e.name === 'SecurityError' || e.name === 'PermissionDeniedError'))
},
handleCameraFail(e) { // 相机不可用统一处理:权限类弹确认框,其他异常提示后由用户点击触发相册(保证点击手势有效)
this.cameraGuideVisible = false
if (this.isCameraPermissionError(e)) {
Dialog.confirm({
title: '提示',
message: '相机权限未开启,无法使用拍摄引导。是否重新尝试开启相机?',
confirmButtonText: '重新尝试',
cancelButtonText: '从相册选择',
confirmButtonColor: '#354D93',
}).then(() => {
// 重新走前置探测,探测通过才打开拍摄引导
this.onLicenseSlotClick(this.cameraGuideType)
}).catch(() => {
this.triggerNativeUpload(this.cameraGuideType)
})
} else {
Dialog.alert({
title: '提示',
message: '当前设备无法调用相机拍摄,请从相册选择照片上传。',
confirmButtonText: '从相册选择',
confirmButtonColor: '#354D93',
}).then(() => {
this.triggerNativeUpload(this.cameraGuideType)
})
} }
}, },
triggerNativeUpload(type) { // 主动触发对应 uploader 的原生文件选择 triggerNativeUpload(type) { // 主动触发对应 uploader 的原生文件选择
@@ -999,21 +1022,8 @@ export default {
onCameraCancel() { // 返回放弃 onCameraCancel() { // 返回放弃
this.cameraGuideVisible = false this.cameraGuideVisible = false
}, },
onCameraFallback() { // 权限拒绝/相机不可用:弹框询问,重试或降级系统选择器 onCameraFallback(e) { // CameraGuide 内 getUserMedia 失败(前置探测已通过,概率极低):按异常类型统一处理
this.cameraGuideVisible = false this.handleCameraFail(e)
Dialog.confirm({
title: '提示',
message: '相机权限未开启,无法使用拍摄引导。是否重新尝试开启相机?',
confirmButtonText: '重新尝试',
cancelButtonText: '从相册选择',
confirmButtonColor: '#354D93',
}).then(() => {
// 重新走前置探测,探测通过才打开拍摄引导
this.onLicenseSlotClick(this.cameraGuideType)
}).catch(() => {
// 降级为系统选择器
this.triggerNativeUpload(this.cameraGuideType)
})
}, },
async vehicleLicenseFrontHandler(file) { // 上传 行驶证首页 async vehicleLicenseFrontHandler(file) { // 上传 行驶证首页
console.log('file',file) console.log('file',file)