Aiden 9 months ago
parent 4fe502833c
commit e32f8207bd

@ -21,8 +21,16 @@ const qrCodeInfo = (data) => {
data, data,
}); });
}; };
const checkQr = () => {
return http.request({
url: "/api/smart/check/verify/qrCode",
method: "POST",
data,
});
};
export default { export default {
sendCode, sendCode,
login, login,
qrCodeInfo, qrCodeInfo,
checkQr,
}; };

File diff suppressed because it is too large Load Diff

@ -1,443 +1,418 @@
<template> <template>
<view class="container"> <view class="canvasBox">
<view class="canvasBox"> <template v-if="isUse">
<template v-if="isUse"> <view class="box">
<view class="box"> <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"> <view class="track" @click="openTrack">
<view class="track" @click="openTrack"> <svg t="1653920715959" class="icon" viewBox="0 0 1024 1024" version="1.1"
<svg t="1653920715959" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" p-id="1351" width="32" height="32">
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" p-id="1352"></path>
fill="#ffffff" p-id="1352" /> </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 class="mask2 mask"
<view 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 class="mask4 mask"
<view 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"> <view class="error">
<view class="error"> <view class="on1">相机权限被拒绝请尝试如下操作</view>
<view class="on1">相机权限被拒绝请尝试如下操作</view> <view>· 刷新页面后重试</view>
<view>· 刷新页面后重试</view> <view>· 在系统中检测当前App或浏览器的相机权限是否被禁用</view>
<view>· 在系统中检测当前App或浏览器的相机权限是否被禁用</view> <view>· 如果依然不能体验建议在微信中打开链接</view>
<view>· 如果依然不能体验建议在微信中打开链接</view> </view>
</view> </slot>
</slot> </template>
</template> </view>
</view>
</view>
</template> </template>
<script> <script>
import * as jsQR from './jsQR.js' import jsQR from 'jsQR'
export default { export default {
props: { props: {
continue: { continue: {
type: Boolean, type: Boolean,
default: false // false true default: false // false true
}, },
exact: { exact: {
type: String, type: String,
default: "environment" // environment user default: 'environment' // environment user
}, },
size: { size: {
type: String, type: String,
default: "whole" // whole balf default: 'whole' // whole balf
}, },
definition: { definition: {
type: Boolean, type: Boolean,
default: false // fasle true default: false // fasle true
} }
}, },
data() { data() {
return { return {
windowWidth: 0, windowWidth: 0,
windowHeight: 0, windowHeight: 0,
video: null, video: null,
canvas2d: null, canvas2d: null,
canvas2d2: null, canvas2d2: null,
canvasWidth: 200, canvasWidth: 200,
canvasHeight: 200, canvasHeight: 200,
maskWidth: 0, maskWidth: 0,
maskHeight: 0, maskHeight: 0,
inter: 0, inter: 0,
track: null, track: null,
isUseTorch: false, isUseTorch: false,
trackStatus: false, trackStatus: false,
isParse: false, isParse: false,
isUse: true isUse: true
}; }
}, },
mounted() { mounted() {
if (origin.indexOf("https") === -1) if (origin.indexOf('https') === -1) throw '请在 https 环境中使用摄像头组件。'
throw "请在 https 环境中使用摄像头组件。";
this.windowWidth = document.documentElement.clientWidth || document.body.clientWidth
this.windowWidth = this.windowHeight = document.documentElement.clientHeight || document.body.clientHeight
document.documentElement.clientWidth || document.body.clientWidth; this.windowHeight = this.size === 'whole' ? this.windowHeight : this.windowHeight / 2
this.windowHeight = this.isParse = true
document.documentElement.clientHeight || document.body.clientHeight;
this.windowHeight = this.$nextTick(() => {
this.size === "whole" ? this.windowHeight : this.windowHeight / 2; this.createMsk()
this.isParse = true; this.openScan()
})
this.$nextTick(() => { },
this.createMsk(); destroyed() {
this.openScan(); this.closeCamera()
}); },
}, methods: {
destroyed() { openScan() {
this.closeCamera(); const width = this.transtion(this.windowHeight)
}, const height = this.transtion(this.windowWidth)
methods: { const videoParam = {
openScan() { audio: false,
const width = this.transtion(this.windowHeight); video: {
const height = this.transtion(this.windowWidth); facingMode: { exact: this.exact },
const videoParam = { width,
audio: false, height
video: { }
facingMode: { exact: this.exact }, }
width, navigator.mediaDevices
height .getUserMedia(videoParam)
} .then(stream => {
}; this.video = document.createElement('video')
navigator.mediaDevices this.video.width = this.windowWidth
.getUserMedia(videoParam) this.video.height = this.windowHeight
.then(stream => {
this.video = document.createElement("video"); const canvas = document.createElement('canvas')
this.video.width = this.windowWidth; canvas.id = 'canvas'
this.video.height = this.windowHeight; canvas.width = this.transtion(this.canvasWidth)
canvas.height = this.transtion(this.canvasHeight)
const canvas = document.createElement("canvas"); canvas.style = 'display:none;'
canvas.id = "canvas"; //canvas.style = 'position: fixed;top: 0;z-index: 999;left:0'
canvas.width = this.transtion(this.canvasWidth); this.canvas2d = canvas.getContext('2d')
canvas.height = this.transtion(this.canvasHeight);
canvas.style = "display:none;"; //
//canvas.style = 'position: fixed;top: 0;z-index: 999;left:0' const canvasBox = document.querySelector('.canvasBox')
this.canvas2d = canvas.getContext("2d"); canvasBox.append(this.video)
canvasBox.append(canvas)
// canvasBox.style = `width:${this.windowWidth}px;height:${this.windowHeight}px;`
const canvasBox = document.querySelector(".canvasBox");
canvasBox.append(this.video); // canvas
canvasBox.append(canvas); const canvas2 = document.createElement('canvas')
canvasBox.style = `width:${this.windowWidth}px;height:${this.windowHeight}px;`; canvas2.id = 'canvas2'
canvas2.width = this.canvasWidth
// canvas canvas2.height = this.canvasHeight
const canvas2 = document.createElement("canvas"); canvas2.style = 'position: absolute;top: 50%;left: 50%;z-index: 20;transform: translate(-50%, -50%);'
canvas2.id = "canvas2"; this.canvas2d2 = canvas2.getContext('2d')
canvas2.width = this.canvasWidth; canvasBox.append(canvas2)
canvas2.height = this.canvasHeight;
canvas2.style = this.video.srcObject = stream
"position: absolute;top: 50%;left: 50%;z-index: 20;transform: translate(-50%, -50%);"; this.video.setAttribute('playsinline', true)
this.canvas2d2 = canvas2.getContext("2d"); this.video.play()
canvasBox.append(canvas2); this.tick()
this.video.srcObject = stream; this.track = stream.getVideoTracks()[0]
this.video.setAttribute("playsinline", true); setTimeout(() => {
this.video.play(); this.isUseTorch = this.track.getCapabilities().torch || null
this.tick(); }, 500)
})
this.track = stream.getVideoTracks()[0]; .catch(err => {
setTimeout(() => { this.isUse = false
this.isUseTorch = this.track.getCapabilities().torch || null; this.$emit('error', err)
}, 500); })
}) },
.catch(err => {
this.isUse = false; closeCamera() {
this.$emit("error", err); this.isParse = false
}); if (this.video && this.video.srcObject) {
}, this.video.srcObject.getTracks().forEach(track => {
track.stop()
closeCamera() { })
this.isParse = false; }
if (this.video && this.video.srcObject) { },
this.video.srcObject.getTracks().forEach(track => {
track.stop(); tick() {
}); if (!this.isParse) return
} if (this.video.readyState === this.video.HAVE_ENOUGH_DATA) {
}, this.canvas2d.drawImage(
this.video,
tick() { this.transtion(this.maskWidth),
if (!this.isParse) return; this.transtion(this.maskHeight),
if (this.video.readyState === this.video.HAVE_ENOUGH_DATA) { this.transtion(200),
this.canvas2d.drawImage( this.transtion(200),
this.video, 0,
this.transtion(this.maskWidth), 0,
this.transtion(this.maskHeight), this.transtion(this.canvasWidth),
this.transtion(200), this.transtion(this.canvasHeight)
this.transtion(200), )
0,
0, const imageData = this.canvas2d.getImageData(
this.transtion(this.canvasWidth), 0,
this.transtion(this.canvasHeight) 0,
); this.transtion(this.canvasWidth),
this.transtion(this.canvasHeight)
const imageData = this.canvas2d.getImageData( )
0,
0, const code = jsQR(imageData.data, imageData.width, imageData.height, {
this.transtion(this.canvasWidth), inversionAttempts: 'dontInvert'
this.transtion(this.canvasHeight) })
);
this.canvas2d2.clearRect(0, 0, this.canvasWidth, this.canvasHeight)
const code = jsQR(imageData.data, imageData.width, imageData.height, { if (code) {
inversionAttempts: "dontInvert" this.drawLine(code.location.topLeftCorner, code.location.topRightCorner)
}); this.drawLine(code.location.topRightCorner, code.location.bottomRightCorner)
this.drawLine(code.location.bottomRightCorner, code.location.bottomLeftCorner)
this.canvas2d2.clearRect(0, 0, this.canvasWidth, this.canvasHeight); this.drawLine(code.location.bottomLeftCorner, code.location.topLeftCorner)
if (code) { if (code.data) {
this.drawLine( this.getData(code.data)
code.location.topLeftCorner, }
code.location.topRightCorner }
); }
this.drawLine( requestAnimationFrame(this.tick)
code.location.topRightCorner, },
code.location.bottomRightCorner drawLine(begin, end, color = '#FF3B58') {
); this.canvas2d2.beginPath()
this.drawLine( this.canvas2d2.moveTo(this.nutranstion(begin.x), this.nutranstion(begin.y))
code.location.bottomRightCorner, this.canvas2d2.lineTo(this.nutranstion(end.x), this.nutranstion(end.y))
code.location.bottomLeftCorner this.canvas2d2.lineWidth = 4
); this.canvas2d2.strokeStyle = color
this.drawLine( this.canvas2d2.stroke()
code.location.bottomLeftCorner, },
code.location.topLeftCorner
); getData(data) {
if (code.data) { this.$emit('success', data)
this.getData(code.data); if (!this.continue) {
} this.closeCamera()
} }
} },
requestAnimationFrame(this.tick);
}, openTrack() {
drawLine(begin, end, color = "#FF3B58") { this.trackStatus = !this.trackStatus
this.canvas2d2.beginPath(); this.track.applyConstraints({
this.canvas2d2.moveTo( advanced: [{ torch: this.trackStatus }]
this.nutranstion(begin.x), })
this.nutranstion(begin.y) },
);
this.canvas2d2.lineTo(this.nutranstion(end.x), this.nutranstion(end.y)); createMsk() {
this.canvas2d2.lineWidth = 4; this.maskWidth = this.windowWidth / 2 - this.canvasWidth / 2
this.canvas2d2.strokeStyle = color; this.maskHeight = this.windowHeight / 2 - this.canvasHeight / 2
this.canvas2d2.stroke(); },
},
transtion(number) {
getData(data) { return this.definition ? number * 2.8 : number * 1.8
this.$emit("success", data); },
if (!this.continue) { nutranstion(number) {
this.closeCamera(); return this.definition ? number / 2.8 : number / 1.8
} }
}, }
}
openTrack() {
this.trackStatus = !this.trackStatus;
this.track.applyConstraints({
advanced: [{ torch: this.trackStatus }]
});
},
createMsk() {
this.maskWidth = this.windowWidth / 2 - this.canvasWidth / 2;
this.maskHeight = this.windowHeight / 2 - this.canvasHeight / 2;
},
transtion(number) {
return this.definition ? number * 2.8 : number * 1.8;
},
nutranstion(number) {
return this.definition ? number / 2.8 : number / 1.8;
}
}
};
</script> </script>
<style scoped lang="scss"> <style scoped>
page { page {
background-color: #333333; background-color: #333333;
} }
// .container {
// background-color: #333333;
// opacity: 0.7;
// }
.canvasBox { .canvasBox {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
position: relative; position: relative;
// background-image: linear-gradient(0deg, background-image: linear-gradient(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%,
// transparent 27%, transparent 27%,
// transparent 74%, transparent 74%,
// 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%,
// transparent 27%, transparent 27%,
// transparent 74%, transparent 74%,
// 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;
background-color: #1110; background-color: #1110;
} }
.box { .box {
width: 200px; width: 200px;
height: 200px; height: 200px;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
overflow: hidden; overflow: hidden;
border: 0.1rem solid rgba(0, 255, 51, 0.2); border: 0.1rem solid rgba(0, 255, 51, 0.2);
z-index: 11; z-index: 11;
} }
.line { .line {
height: calc(100% - 2px); height: calc(100% - 2px);
width: 100%; width: 100%;
background: linear-gradient(180deg, rgba(0, 255, 51, 0) 43%, #00ff33 211%); background: linear-gradient(180deg, rgba(0, 255, 51, 0) 43%, #00ff33 211%);
border-bottom: 3px solid #00ff33; border-bottom: 3px solid #00ff33;
transform: translateY(-100%); transform: translateY(-100%);
animation: radar-beam 2s infinite alternate; animation: radar-beam 2s infinite alternate;
animation-timing-function: cubic-bezier(0.53, 0, 0.43, 0.99); animation-timing-function: cubic-bezier(0.53, 0, 0.43, 0.99);
animation-delay: 1.4s; animation-delay: 1.4s;
} }
.box:after, .box:after,
.box:before, .box:before,
.angle:after, .angle:after,
.angle:before { .angle:before {
content: ""; content: '';
display: block; display: block;
position: absolute; position: absolute;
width: 3vw; width: 3vw;
height: 3vw; height: 3vw;
z-index: 12; z-index: 12;
border: 0.2rem solid transparent; border: 0.2rem solid transparent;
} }
.box:after, .box:after,
.box:before { .box:before {
top: 0; top: 0;
border-top-color: #00ff33; border-top-color: #00ff33;
} }
.angle:after, .angle:after,
.angle:before { .angle:before {
bottom: 0; bottom: 0;
border-bottom-color: #00ff33; border-bottom-color: #00ff33;
} }
.box:before, .box:before,
.angle:before { .angle:before {
left: 0; left: 0;
border-left-color: #00ff33; border-left-color: #00ff33;
} }
.box:after, .box:after,
.angle:after { .angle:after {
right: 0; right: 0;
border-right-color: #00ff33; border-right-color: #00ff33;
} }
@keyframes radar-beam { @keyframes radar-beam {
0% { 0% {
transform: translateY(-100%); transform: translateY(-100%);
} }
100% { 100% {
transform: translateY(0); transform: translateY(0);
} }
} }
.msg { .msg {
text-align: center; text-align: center;
padding: 20rpx 0; padding: 20rpx 0;
} }
.box2 { .box2 {
width: 300px; width: 300px;
height: 200px; height: 200px;
position: absolute; position: absolute;
left: 50%; left: 50%;
top: 50%; top: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
z-index: 20; z-index: 20;
} }
.track { .track {
position: absolute; position: absolute;
bottom: -100px; bottom: -100px;
left: 50%; left: 50%;
transform: translateX(-50%); transform: translateX(-50%);
z-index: 20; z-index: 20;
color: #fff; color: #fff;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
} }
.mask { .mask {
position: absolute; position: absolute;
z-index: 10; z-index: 10;
background-color: rgba(0, 0, 0, 0.55); background-color: rgba(0, 0, 0, 0.55);
} }
.mask1 { .mask1 {
top: 0; top: 0;
left: 0; left: 0;
right: 0; right: 0;
} }
.mask2 { .mask2 {
right: 0; right: 0;
} }
.mask3 { .mask3 {
right: 0; right: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
} }
.mask4 { .mask4 {
left: 0; left: 0;
} }
.error { .error {
color: #fff; color: #fff;
padding: 40rpx; padding: 40rpx;
font-size: 24rpx; font-size: 24rpx;
background-color: #333333; background-color: #333333;
position: fixed; position: fixed;
top: 50%; top: 50%;
left: 50%; left: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
width: 550rpx; width: 550rpx;
border-radius: 20rpx; border-radius: 20rpx;
} }
.error .on1 { .error .on1 {
font-size: 30rpx; font-size: 30rpx;
} }
</style> </style>

@ -68,5 +68,10 @@
"uniStatistics" : { "uniStatistics" : {
"enable" : false "enable" : false
}, },
"vueVersion" : "3" "vueVersion" : "3",
"h5" : {
"devServer" : {
"https" : true
}
}
} }

11
package-lock.json generated

@ -5,6 +5,7 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"jsqr": "^1.4.0",
"sass": "^1.69.5", "sass": "^1.69.5",
"sass-loader": "^13.3.2", "sass-loader": "^13.3.2",
"uview-plus": "^3.1.41" "uview-plus": "^3.1.41"
@ -656,6 +657,11 @@
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"peer": true "peer": true
}, },
"node_modules/jsqr": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/jsqr/-/jsqr-1.4.0.tgz",
"integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A=="
},
"node_modules/loader-runner": { "node_modules/loader-runner": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.0.tgz", "resolved": "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.0.tgz",
@ -1612,6 +1618,11 @@
"integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
"peer": true "peer": true
}, },
"jsqr": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/jsqr/-/jsqr-1.4.0.tgz",
"integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A=="
},
"loader-runner": { "loader-runner": {
"version": "4.3.0", "version": "4.3.0",
"resolved": "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.0.tgz", "resolved": "https://registry.npmmirror.com/loader-runner/-/loader-runner-4.3.0.tgz",

@ -1,5 +1,6 @@
{ {
"dependencies": { "dependencies": {
"jsqr": "^1.4.0",
"sass": "^1.69.5", "sass": "^1.69.5",
"sass-loader": "^13.3.2", "sass-loader": "^13.3.2",
"uview-plus": "^3.1.41" "uview-plus": "^3.1.41"

@ -1,6 +1,6 @@
<template> <template>
<div class="main"> <div class="main">
<up-button type="primary" :text="'审核员'" shape="circle" color="#AB2F23" style="width:700rpx "></up-button> <up-button type="primary" :text="'审核员 ' + name" shape="circle" color="#AB2F23" style="width:700rpx "></up-button>
<image src="" mode="scaleToFill" class="img" style="" /> <image src="" mode="scaleToFill" class="img" style="" />
<card> <card>
<template #l1> <template #l1>
@ -9,7 +9,7 @@
</div> </div>
</template> </template>
<template #r1> <template #r1>
123123 {{ userInfo[0]?.userName }}
</template> </template>
<template #l2> <template #l2>
<div class="box-left"> <div class="box-left">
@ -18,7 +18,7 @@
</template> </template>
<template #r2> <template #r2>
<div class="box-right"> <div class="box-right">
123123132 {{ userInfo[0]?.idCard }}
</div> </div>
</template> </template>
<template #l3> <template #l3>
@ -27,7 +27,7 @@
</div> </div>
</template> </template>
<template #r3> <template #r3>
123123 {{ ticketsInfo.drawDay }}
</template> </template>
<template #l4> <template #l4>
<div class="box-left"> <div class="box-left">
@ -35,26 +35,26 @@
</div> </div>
</template> </template>
<template #r4> <template #r4>
123123 {{ ticketsInfo.ticketName }}
</template> </template>
<template #l5> <template #l5 v-if="userInfo[0]?.checkTime">
<div class="box-left"> <div class="box-left">
核验日期 核验日期
</div> </div>
</template> </template>
<template #r5> <template #r5 v-if="userInfo[0]?.checkTime">
123123 {{ userInfo[0]?.checkTime }}
</template> </template>
</card> </card>
<up-button type="primary" text="核验人像" shape="circle" color="#000" style="width:436rpx "></up-button> <up-button type="primary" text="核验人像" shape="circle" color="#000" style="width:436rpx " @click="checkPerson"
v-if="ticketsInfo.status === 1"></up-button>
</div> </div>
</template> </template>
<script setup> <script setup>
import card from '@/components/card/index.vue' import card from '@/components/card/index.vue'
import { onMounted } from "vue"; import { reactive } from "vue";
import { onLoad } from "@dcloudio/uni-app" import { onLoad } from "@dcloudio/uni-app"
import mumuGetQrcode from "../../components/mumu-getQrcode/mumu-getQrcode.vue";
import { ref, getCurrentInstance } from 'vue'; import { ref, getCurrentInstance } from 'vue';
const currentInstance = getCurrentInstance(); const currentInstance = getCurrentInstance();
const { $request } = const { $request } =
@ -64,11 +64,52 @@ onLoad((option) => {
getQrInfo() getQrInfo()
}); });
let ticketsInfo = reactive({})
let userInfo = ref([])
const name = ref(uni.getStorageSync('nickName'))
const getQrInfo = () => { const getQrInfo = () => {
$request.qrCodeInfo({ appointmentUid: '245fa520-3724-4151-82a9-dd84d6838b68' }).then((res) => { $request.qrCodeInfo({ appointmentUid: 'd7db1538-eb98-4ef8-86ed-0400adcee6ac' }).then((res) => {
if (res.status === 0) { if (res.status === 0) {
ticketsInfo = res.data.ticketsInfo
userInfo.value = res.data.userInfo
console.log(res.data.userInfo)
} else {
uni.$u.toast(res.msg);
}
})
}
const checkPerson = () => {
uni.connectSocket({
url: `ws://warehouse.szjixun.cn/ticket/api/smart/check/issue/msg?AppointmentUid=d7db1538-eb98-4ef8-86ed-0400adcee6ac`,
success: function () {
console.log('WebSocket连接已创建成功');
}
});
uni.onSocketOpen((res) => {
console.log(res, 'onSocketOpen')
});
uni.onSocketMessage((res) => {
console.log('WebSocket接收到消息', res);
if (res.data) {
checkQr(res.data)
}
});
uni.onSocketError(function (res) {
console.log(res);
});
}
const checkQr = (img) => {
$request.checkQr({
appointmentUid: '',
imageUrl: img
}).then((res) => {
if (res.status === 0) {
getQrInfo()
} else {
uni.$u.toast(res.msg);
} }
}) })
} }

@ -1,39 +1,23 @@
<template> <template>
<div> <div>
<mumuGetQrcode @success="qrcodeSucess" @error="qrcodeError"></mumuGetQrcode> <mumuGetQrcode @success="qrcodeSucess" @error="qrcodeError"></mumuGetQrcode>
<!-- <up-button type="primary" text="xxx" shape="circle" color="#000" style="width:436rpx ;"
@click="qrcodeSucess"></up-button> -->
</div> </div>
</template> </template>
<script setup> <script setup>
import mumuGetQrcode from "../../components/mumu-getQrcode/mumu-getQrcode.vue"; import mumuGetQrcode from "../../components/mumu-getQrcode/mumu-getQrcode.vue";
import { ref, getCurrentInstance } from 'vue';
const currentInstance = getCurrentInstance();
const { $request } =
currentInstance.appContext.config.globalProperties;
const qrcodeSucess = (id) => { const qrcodeSucess = (id) => {
uni.showModal({ uni.showModal({
title: id, title: id,
content: id, content: id,
success: () => {
uni.navigateBack({});
},
}); });
// $request.qrCodeInfo({ appointmentUid: '245fa520-3724-4151-82a9-dd84d6838b68' }).then((res) => {
// if (res.status === 0) {
// }
// })
} }
const qrcodeError = (err) => { const qrcodeError = (err) => {
console.log(err); console.log(err);
uni.showModal({ uni.showModal({
title: "摄像头授权失败", title: "摄像头授权失败",
content: "摄像头授权失败,请检测当前浏览器是否有摄像头权限。",
success: () => {
uni.navigateBack({});
},
}); });
} }
</script> </script>

Loading…
Cancel
Save