Files
pasd_app/pages/work/inspection/scanSign/scanSign.vue

78 lines
2.1 KiB
Vue
Raw Normal View History

2025-09-04 19:40:29 +08:00
<template>
<view>
<!-- HTML -->
<mumu-get-qrcode @success='qrcodeSucess' @error="qrcodeError" :scanWidth="300"
:scanHeight="300"></mumu-get-qrcode>
</view>
</template>
2025-07-28 14:57:35 +08:00
<script>
2025-09-04 19:40:29 +08:00
// js
import mumuGetQrcode from '@/uni_modules/mumu-getQrcode/components/mumu-getQrcode/mumu-getQrcode.vue'
2025-09-04 20:06:07 +08:00
import {
getInspectionManage
} from '@/api/inspection/inspectionManage.js'
2025-09-04 19:40:29 +08:00
// 嫌路径长的话可以单独复制出来
2025-07-28 14:57:35 +08:00
export default {
2025-09-04 19:40:29 +08:00
components: {
mumuGetQrcode
2025-07-28 14:57:35 +08:00
},
methods: {
2025-09-04 19:40:29 +08:00
qrcodeSucess(data) {
console.log("二维码数据", data)
this.handleScanResult(data);
},
qrcodeError(err) {
console.log(err)
let that = this;
uni.showModal({
title: '摄像头授权失败',
content: '摄像头授权失败,请检测当前浏览器是否有摄像头权限。',
success: () => {
that.redirectToWorkbench(); // 请求错误跳回工作台
2025-07-28 14:57:35 +08:00
}
2025-09-04 19:40:29 +08:00
})
2025-07-28 14:57:35 +08:00
},
2025-09-04 19:40:29 +08:00
handleScanResult(result) {
let that = this;
getInspectionManage(result)
.then(res => {
if (res.data.inspectionStatus === "1") {
let inspectionPoint = res.data.inspectionPoint;
let inspectionRequirements = res.data.inspectionRequirements;
let inspectionPointId = res.data.id
uni.reLaunch({
url: `/pages/work/inspection/scanSign/index?inspectionPoint=${inspectionPoint}&inspectionRequirements=${inspectionRequirements}&inspectionPointId=${inspectionPointId}`
2025-07-28 14:57:35 +08:00
});
} else {
uni.showToast({
2025-09-04 19:40:29 +08:00
title: '验证码已失效!',
2025-07-28 14:57:35 +08:00
icon: 'none'
});
2025-09-04 19:40:29 +08:00
that.redirectToWorkbench(); // 验证码失效跳回工作台
2025-07-28 14:57:35 +08:00
}
2025-09-04 19:40:29 +08:00
})
.catch(err => {
console.log("请求错误", err);
2025-07-28 14:57:35 +08:00
uni.showToast({
2025-09-04 19:40:29 +08:00
title: '服务器错误',
2025-07-28 14:57:35 +08:00
icon: 'none'
});
2025-09-04 19:40:29 +08:00
that.redirectToWorkbench(); // 请求错误跳回工作台
});
},
// 新增方法:跳转回工作台
redirectToWorkbench() {
setTimeout(() => {
uni.reLaunch({
url: '/pages/work/index'
});
}, 1500); // 1.5秒后跳转,让用户看到提示信息
},
2025-07-28 14:57:35 +08:00
}
}
</script>
<style>
2025-09-04 19:40:29 +08:00
2025-07-28 14:57:35 +08:00
</style>