Files
supplier-dispatch-h5/src/views/index/cameraGuide.vue
T

48 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<!-- 独立拍摄页 vehicleAdd 跳转进入query.type = front/back/car),
确认/取消/降级后 $router.back() 返回 vehicleAdd -->
<camera-guide
:visible="show"
:type="type"
@confirm="onConfirm"
@cancel="goBack"
@fallback="onFallback"
/>
</template>
<script>
import CameraGuide from "@/components/CameraGuide.vue";
export default {
name: 'cameraGuidePage',
components: { CameraGuide },
data() {
return {
show: false // 挂载后置 true,触发组件 visible 侦听器启动相机
}
},
computed: {
type() {
const t = this.$route.query.type
return ['front', 'back', 'car'].includes(t) ? t : 'front'
}
},
mounted() {
this.show = true
},
methods: {
onConfirm({ blob, dataURL }) { // 拍照确认:结果存入 store,返回 vehicleAdd 消费
this.$store.commit('camera/setResult', { type: this.type, blob, dataURL })
this.$router.back()
},
onFallback(e) { // 相机不可用:降级信息存入 store,返回 vehicleAdd 走系统选择器
this.$store.commit('camera/setFallback', { type: this.type, error: e })
this.$router.back()
},
goBack() {
this.$router.back()
}
}
}
</script>