79 lines
1.8 KiB
Vue
79 lines
1.8 KiB
Vue
<script>
|
|
import {
|
|
getInspectionManage
|
|
} from '@/api/inspection/inspectionManage.js'
|
|
export default {
|
|
created() {
|
|
this.requestCameraAuth()
|
|
},
|
|
methods: {
|
|
requestCameraAuth() {
|
|
const _this = this
|
|
uni.authorize({
|
|
scope: 'scope.camera', // 请求相机权限
|
|
success: (res) => {
|
|
_this.scanQRCode();
|
|
},
|
|
fail: (err) => {
|
|
// 用户拒绝授权
|
|
uni.showToast({
|
|
title: '您拒绝了授权',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
scanQRCode() {
|
|
const _this = this
|
|
uni.scanCode({
|
|
onlyFromCamera: true,
|
|
scanType: ['qrCode'],
|
|
success(res) {
|
|
if (res.result) {
|
|
// 扫描成功,处理二维码内容
|
|
getInspectionManage(res.result).then(res => {
|
|
if (res.data.inspectionStatus === "1") {
|
|
let inspectionPoint = res.data.inspectionPoint
|
|
let inspectionRequirements = res.data.inspectionRequirements
|
|
// _this.$tab.redirectTo(
|
|
// `/pages/work/inspection/scanSign/index?inspectionPoint=${inspectionPoint}&inspectionRequirements=${inspectionRequirements}`
|
|
// )
|
|
uni.reLaunch({
|
|
url: `/pages/work/inspection/scanSign/index?inspectionPoint=${inspectionPoint}&inspectionRequirements=${inspectionRequirements}`
|
|
})
|
|
} else {
|
|
uni.reLaunch({
|
|
url: '/pages/work/index'
|
|
}).then(()=>{
|
|
// 扫描失败
|
|
uni.showToast({
|
|
title: '验证码已失效!!!',
|
|
icon: 'none'
|
|
});
|
|
})
|
|
}
|
|
});
|
|
|
|
} else {
|
|
// 扫描失败
|
|
uni.showToast({
|
|
title: '扫描失败',
|
|
icon: 'none'
|
|
});
|
|
}
|
|
},
|
|
fail(res) {
|
|
uni.showToast({
|
|
title: '调用相机失败',
|
|
icon: 'none'
|
|
});
|
|
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
</style> |