Commit 9d5590d6 authored by 罗新东's avatar 罗新东

修改了扫码

parent 40748dba
Pipeline #7653 passed with stage
in 12 seconds
...@@ -5,9 +5,8 @@ ...@@ -5,9 +5,8 @@
@click="$router.back()" @click="$router.back()"
:src="require('../assets/back.png')" :src="require('../assets/back.png')"
/> />
<!-- <p class="error">{{ error }}</p> --> <p class="error">{{ error }}</p>
<!--错误信息--> <!--错误信息-->
<!-- <p class="decode-result"> <!-- <p class="decode-result">
扫描结果: 扫描结果:
<b>{{ result }}</b> <b>{{ result }}</b>
...@@ -19,11 +18,9 @@ ...@@ -19,11 +18,9 @@
<p @click="openFlash">打开手电筒</p> <p @click="openFlash">打开手电筒</p>
<p @click="switchCamera">相机反转</p> <p @click="switchCamera">相机反转</p>
</div> --> </div> -->
<qrcode-stream <qrcode-stream
v-show="qrcode" v-show="qrcode"
:camera="camera"
:torch="torchActive"
@decode="onDecode" @decode="onDecode"
@init="onInit" @init="onInit"
> >
...@@ -53,7 +50,6 @@ import { QrcodeStream } from "vue-qrcode-reader"; ...@@ -53,7 +50,6 @@ import { QrcodeStream } from "vue-qrcode-reader";
export default { export default {
// 注册 // 注册
components: { QrcodeStream }, components: { QrcodeStream },
data() { data() {
return { return {
result: "", // 扫码结果信息 result: "", // 扫码结果信息
...@@ -73,13 +69,12 @@ export default { ...@@ -73,13 +69,12 @@ export default {
this.$emit('success',result) this.$emit('success',result)
}, },
async onInit(promise) { async onInit(promise) {
const { capabilities } = await promise; // const { capabilities } = await promise;
const TORCH_IS_SUPPORTED = !!capabilities.torch; // const TORCH_IS_SUPPORTED = !!capabilities.torch;
try { promise.catch(error=>{
await promise; // alert(1111)
} catch (error) { if (error.name === "NotAllowedError") {
if (error.name === "NotAllowedError") {
this.error = "ERROR: 您需要授予相机访问权限"; this.error = "ERROR: 您需要授予相机访问权限";
} else if (error.name === "NotFoundError") { } else if (error.name === "NotFoundError") {
this.error = "ERROR: 这个设备上没有摄像头"; this.error = "ERROR: 这个设备上没有摄像头";
...@@ -92,7 +87,8 @@ export default { ...@@ -92,7 +87,8 @@ export default {
} else if (error.name === "StreamApiNotSupportedError") { } else if (error.name === "StreamApiNotSupportedError") {
this.error = "ERROR: 此浏览器不支持流API"; this.error = "ERROR: 此浏览器不支持流API";
} }
} // console.log(error.name)
})
}, },
// 打开相机 // 打开相机
// openCamera() { // openCamera() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment