修改扫码页面

This commit is contained in:
2025-09-04 19:40:29 +08:00
parent a16d74cccd
commit 2d09878787
5 changed files with 464 additions and 476 deletions

View File

@@ -1,9 +1,9 @@
// 应用全局配置 // 应用全局配置
module.exports = { module.exports = {
// baseUrl: 'http://172.16.129.101:8080/dev-api/', // baseUrl: 'http://172.16.129.101:8080/dev-api/',
//baseUrl: 'http://pasd.gxsdxy.cn/prod-api/', baseUrl: 'https://pasd.gxsdxy.cn/prod-api/',
// baseUrl: 'http://172.16.129.101:8080',//172.16.129.101 // baseUrl: 'http://172.16.129.101:8080',//172.16.129.101
baseUrl: 'http://192.168.100.106:8080', // baseUrl: 'http://localhost:8080',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称

View File

@@ -95,13 +95,15 @@
{ {
"path": "pages/work/inspection/scanSign/scanSign", "path": "pages/work/inspection/scanSign/scanSign",
"style": { "style": {
"navigationBarTitleText": "扫一扫" "navigationBarTitleText": "扫一扫",
"navigationStyle": "custom"
} }
}, },
{ {
"path": "pages/work/inspection/scanSign/scanSign2", "path": "pages/work/inspection/scanSign/scanSign2",
"style": { "style": {
"navigationBarTitleText": "扫一扫" "navigationBarTitleText": "扫一扫",
"navigationStyle": "custom"
} }
}, },
{ {
@@ -154,7 +156,7 @@
"text": "工作台" "text": "工作台"
}, },
{ {
"pagePath": "pages/work/inspection/scanSign/scanSign2", "pagePath": "pages/work/inspection/scanSign/scanSign",
"iconPath": "static/images/tabbar/scan2.png", "iconPath": "static/images/tabbar/scan2.png",
"selectedIconPath": "static/images/tabbar/scan2.png", "selectedIconPath": "static/images/tabbar/scan2.png",
"text": "扫一扫" "text": "扫一扫"

View File

@@ -1,79 +1,75 @@
<template>
<view>
<!-- HTML -->
<mumu-get-qrcode @success='qrcodeSucess' @error="qrcodeError" :scanWidth="300"
:scanHeight="300"></mumu-get-qrcode>
</view>
</template>
<script> <script>
import { // js
getInspectionManage import mumuGetQrcode from '@/uni_modules/mumu-getQrcode/components/mumu-getQrcode/mumu-getQrcode.vue'
} from '@/api/inspection/inspectionManage.js' // 嫌路径长的话可以单独复制出来
export default { export default {
created() { components: {
this.requestCameraAuth() mumuGetQrcode
}, },
methods: { methods: {
requestCameraAuth() { qrcodeSucess(data) {
const _this = this console.log("二维码数据", data)
uni.authorize({ this.handleScanResult(data);
scope: 'scope.camera', // 请求相机权限
success: (res) => {
_this.scanQRCode();
}, },
fail: (err) => { qrcodeError(err) {
// 用户拒绝授权 console.log(err)
let that = this;
uni.showModal({
title: '摄像头授权失败',
content: '摄像头授权失败,请检测当前浏览器是否有摄像头权限。',
success: () => {
that.redirectToWorkbench(); // 请求错误跳回工作台
}
})
},
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}`
});
} else {
uni.showToast({ uni.showToast({
title: '您拒绝了授权', title: '验证码已失效!',
icon: 'none' icon: 'none'
}); });
that.redirectToWorkbench(); // 验证码失效跳回工作台
} }
})
.catch(err => {
console.log("请求错误", err);
uni.showToast({
title: '服务器错误',
icon: 'none'
});
that.redirectToWorkbench(); // 请求错误跳回工作台
}); });
}, },
scanQRCode() { // 新增方法:跳转回工作台
const _this = this redirectToWorkbench() {
uni.scanCode({ setTimeout(() => {
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({ uni.reLaunch({
url: '/pages/work/index' url: '/pages/work/index'
}).then(()=>{
// 扫描失败
uni.showToast({
title: '验证码已失效!!!',
icon: 'none'
}); });
}) }, 1500); // 1.5秒后跳转,让用户看到提示信息
}
});
} else {
// 扫描失败
uni.showToast({
title: '扫描失败',
icon: 'none'
});
}
}, },
fail(res) {
uni.showToast({
title: '调用相机失败',
icon: 'none'
});
}
});
}
} }
} }
</script> </script>
<style> <style>
</style> </style>

View File

@@ -1,42 +1,28 @@
<template> <template>
<view class="canvasBox"> <view class="canvasBox">
<template v-if="isUse"> <template v-if="isUse">
<view class="box"> <view class="box" :style="`width: ${scanWidth}px; height: ${scanHeight}px;`">
<view class="line"></view> <view class="line"></view>
<view class="angle"></view> <view class="angle"></view>
</view> </view>
<view class="box2" v-if="isUseTorch"> <view class="box2" v-if="isUseTorch" :style="`width: ${scanWidth}px; height: ${scanHeight}px;`">
<view class="track" @click="openTrack"> <view class="track" @click="openTrack" :style="`bottom: -${scanHeight/2 + 10}px;`">
<svg <svg t="1653920715959" class="icon" viewBox="0 0 1024 1024" version="1.1"
t="1653920715959" xmlns="http://www.w3.org/2000/svg" p-id="1351" width="32" height="32">
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="1351"
width="32"
height="32"
>
<path <path
d="M651.353043 550.479503H378.752795L240.862609 364.315031c-3.688944-4.897391-5.660621-10.876025-5.660621-17.045466v-60.040745c0-15.773416 12.847702-28.621118 28.621118-28.621118h502.459627c15.773416 0 28.621118 12.847702 28.621118 28.621118v59.977143c0 6.105839-1.971677 12.084472-5.660621 17.045466l-137.890187 186.228074zM378.752795 598.308571v398.024348c0 15.328199 12.402484 27.667081 27.667081 27.667081h217.266087c15.328199 0 27.667081-12.402484 27.66708-27.667081V598.308571H378.752795z m136.300124 176.942112c-14.564969 0-26.331429-11.76646-26.331428-26.331428v-81.283975c0-14.564969 11.76646-26.331429 26.331428-26.331429 14.564969 0 26.331429 11.76646 26.331429 26.331429v81.283975c0 14.564969-11.76646 26.331429-26.331429 26.331428zM512 222.608696c-17.554286 0-31.801242-14.246957-31.801242-31.801243V31.801242c0-17.554286 14.246957-31.801242 31.801242-31.801242s31.801242 14.246957 31.801242 31.801242v159.006211c0 17.554286-14.246957 31.801242-31.801242 31.801243zM280.932174 205.881242c-9.47677 0-18.889938-4.197764-25.122981-12.275279L158.242981 67.991056a31.864845 31.864845 0 0 1 5.597019-44.648944 31.864845 31.864845 0 0 1 44.648944 5.597018l97.502609 125.551305a31.864845 31.864845 0 0 1-5.597019 44.648944c-5.787826 4.579379-12.656894 6.741863-19.46236 6.741863zM723.987081 205.881242c-6.805466 0-13.674534-2.162484-19.462361-6.678261a31.794882 31.794882 0 0 1-5.597018-44.648944l97.566211-125.551304a31.794882 31.794882 0 0 1 44.648944-5.597019 31.794882 31.794882 0 0 1 5.597019 44.648944l-97.566211 125.551305c-6.360248 8.077516-15.709814 12.27528-25.186584 12.275279z" d="M651.353043 550.479503H378.752795L240.862609 364.315031c-3.688944-4.897391-5.660621-10.876025-5.660621-17.045466v-60.040745c0-15.773416 12.847702-28.621118 28.621118-28.621118h502.459627c15.773416 0 28.621118 12.847702 28.621118 28.621118v59.977143c0 6.105839-1.971677 12.084472-5.660621 17.045466l-137.890187 186.228074zM378.752795 598.308571v398.024348c0 15.328199 12.402484 27.667081 27.667081 27.667081h217.266087c15.328199 0 27.667081-12.402484 27.66708-27.667081V598.308571H378.752795z m136.300124 176.942112c-14.564969 0-26.331429-11.76646-26.331428-26.331428v-81.283975c0-14.564969 11.76646-26.331429 26.331428-26.331429 14.564969 0 26.331429 11.76646 26.331429 26.331429v81.283975c0 14.564969-11.76646 26.331429-26.331429 26.331428zM512 222.608696c-17.554286 0-31.801242-14.246957-31.801242-31.801243V31.801242c0-17.554286 14.246957-31.801242 31.801242-31.801242s31.801242 14.246957 31.801242 31.801242v159.006211c0 17.554286-14.246957 31.801242-31.801242 31.801243zM280.932174 205.881242c-9.47677 0-18.889938-4.197764-25.122981-12.275279L158.242981 67.991056a31.864845 31.864845 0 0 1 5.597019-44.648944 31.864845 31.864845 0 0 1 44.648944 5.597018l97.502609 125.551305a31.864845 31.864845 0 0 1-5.597019 44.648944c-5.787826 4.579379-12.656894 6.741863-19.46236 6.741863zM723.987081 205.881242c-6.805466 0-13.674534-2.162484-19.462361-6.678261a31.794882 31.794882 0 0 1-5.597018-44.648944l97.566211-125.551304a31.794882 31.794882 0 0 1 44.648944-5.597019 31.794882 31.794882 0 0 1 5.597019 44.648944l-97.566211 125.551305c-6.360248 8.077516-15.709814 12.27528-25.186584 12.275279z"
fill="#ffffff" fill="#ffffff" p-id="1352"></path>
p-id="1352"
></path>
</svg> </svg>
{{ trackStatus ? '关闭闪光灯' : '打开闪光灯' }} {{ trackStatus ? '关闭闪光灯' : '打开闪光灯' }}
</view> </view>
</view> </view>
<view class="mask1 mask" :style="'height:' + maskHeight + 'px;'"></view> <view class="mask1 mask" :style="'height:' + maskHeight + 'px;'"></view>
<view <view class="mask2 mask"
class="mask2 mask" :style="'width:' + maskWidth + 'px;top:' + maskHeight + 'px;height:' + canvasHeight + 'px'"></view>
:style="'width:' + maskWidth + 'px;top:' + maskHeight + 'px;height:' + canvasHeight + 'px'"
></view>
<view class="mask3 mask" :style="'height:' + maskHeight + 'px;'"></view> <view class="mask3 mask" :style="'height:' + maskHeight + 'px;'"></view>
<view <view class="mask4 mask"
class="mask4 mask" :style="'width:' + maskWidth + 'px;top:' + maskHeight + 'px;height:' + canvasHeight + 'px'"></view>
:style="'width:' + maskWidth + 'px;top:' + maskHeight + 'px;height:' + canvasHeight + 'px'"
></view>
</template> </template>
<template v-else> <template v-else>
<slot name="error"> <slot name="error">
@@ -71,6 +57,14 @@ export default {
definition: { definition: {
type: Boolean, type: Boolean,
default: false // fasle 正常 true 高清 default: false // fasle 正常 true 高清
},
scanWidth: {
type: Number,
default: 200 // 扫描框宽度
},
scanHeight: {
type: Number,
default: 200 // 扫描框高度
} }
}, },
data() { data() {
@@ -80,8 +74,8 @@ export default {
video: null, video: null,
canvas2d: null, canvas2d: null,
canvas2d2: null, canvas2d2: null,
canvasWidth: 200, canvasWidth: this.scanWidth,
canvasHeight: 200, canvasHeight: this.scanHeight,
maskWidth: 0, maskWidth: 0,
maskHeight: 0, maskHeight: 0,
inter: 0, inter: 0,
@@ -117,7 +111,9 @@ export default {
const videoParam = { const videoParam = {
audio: false, audio: false,
video: { video: {
facingMode: { exact: this.exact }, facingMode: {
exact: this.exact
},
width, width,
height height
} }
@@ -148,7 +144,8 @@ export default {
canvas2.id = 'canvas2' canvas2.id = 'canvas2'
canvas2.width = this.canvasWidth canvas2.width = this.canvasWidth
canvas2.height = this.canvasHeight canvas2.height = this.canvasHeight
canvas2.style = 'position: absolute;top: 50%;left: 50%;z-index: 20;transform: translate(-50%, -50%);' canvas2.style =
'position: absolute;top: 50%;left: 50%;z-index: 20;transform: translate(-50%, -50%);'
this.canvas2d2 = canvas2.getContext('2d') this.canvas2d2 = canvas2.getContext('2d')
canvasBox.append(canvas2) canvasBox.append(canvas2)
@@ -184,8 +181,8 @@ export default {
this.video, this.video,
this.transtion(this.maskWidth), this.transtion(this.maskWidth),
this.transtion(this.maskHeight), this.transtion(this.maskHeight),
this.transtion(200), this.transtion(this.scanWidth),
this.transtion(200), this.transtion(this.scanHeight),
0, 0,
0, 0,
this.transtion(this.canvasWidth), this.transtion(this.canvasWidth),
@@ -235,13 +232,15 @@ export default {
openTrack() { openTrack() {
this.trackStatus = !this.trackStatus this.trackStatus = !this.trackStatus
this.track.applyConstraints({ this.track.applyConstraints({
advanced: [{ torch: this.trackStatus }] advanced: [{
torch: this.trackStatus
}]
}) })
}, },
createMsk() { createMsk() {
this.maskWidth = this.windowWidth / 2 - this.canvasWidth / 2 this.maskWidth = this.windowWidth / 2 - this.scanWidth / 2
this.maskHeight = this.windowHeight / 2 - this.canvasHeight / 2 this.maskHeight = this.windowHeight / 2 - this.scanHeight / 2
}, },
transtion(number) { transtion(number) {
@@ -264,8 +263,7 @@ page {
height: 100vh; height: 100vh;
position: relative; position: relative;
background-image: linear-gradient( background-image: linear-gradient(0deg,
0deg,
transparent 24%, transparent 24%,
rgba(32, 255, 77, 0.1) 25%, rgba(32, 255, 77, 0.1) 25%,
rgba(32, 255, 77, 0.1) 26%, rgba(32, 255, 77, 0.1) 26%,
@@ -274,10 +272,8 @@ page {
rgba(32, 255, 77, 0.1) 75%, rgba(32, 255, 77, 0.1) 75%,
rgba(32, 255, 77, 0.1) 76%, rgba(32, 255, 77, 0.1) 76%,
transparent 77%, transparent 77%,
transparent transparent),
), linear-gradient(90deg,
linear-gradient(
90deg,
transparent 24%, transparent 24%,
rgba(32, 255, 77, 0.1) 25%, rgba(32, 255, 77, 0.1) 25%,
rgba(32, 255, 77, 0.1) 26%, rgba(32, 255, 77, 0.1) 26%,
@@ -286,8 +282,7 @@ page {
rgba(32, 255, 77, 0.1) 75%, rgba(32, 255, 77, 0.1) 75%,
rgba(32, 255, 77, 0.1) 76%, rgba(32, 255, 77, 0.1) 76%,
transparent 77%, transparent 77%,
transparent transparent);
);
background-size: 3rem 3rem; background-size: 3rem 3rem;
background-position: -1rem -1rem; background-position: -1rem -1rem;
z-index: 10; z-index: 10;
@@ -295,8 +290,6 @@ page {
} }
.box { .box {
width: 200px;
height: 200px;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
@@ -370,8 +363,6 @@ page {
} }
.box2 { .box2 {
width: 300px;
height: 200px;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
@@ -381,7 +372,6 @@ page {
.track { .track {
position: absolute; position: absolute;
bottom: -100px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
z-index: 20; z-index: 20;