You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
2.7 KiB
119 lines
2.7 KiB
<template>
|
|
<view>
|
|
<!-- 扫描框 -->
|
|
<view class="scanBox" v-if="canScan">
|
|
<camera class="camera" mode="scanCode" @scancode="scancode" :flash='flashBtn'>
|
|
<image class="coverImg" src="/static/images/border.png"></image>
|
|
</camera>
|
|
|
|
<view style="text-align: center;margin: 80rpx 0 40rpx 0;">
|
|
<button class="cu-btn scancodePic" @click="changeflashBtn()">
|
|
<image :src="flashBtn=='on'?scancodeOpen:scancodeClose"></image>
|
|
</button>
|
|
</view>
|
|
<view class="scanTip">请扫描二维码</view>
|
|
<!-- 关闭扫码页面 -->
|
|
<view class="footbox">
|
|
<tabbar :page="page"></tabbar>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import tabbar from "@/components/tabbar/tabbar.vue";
|
|
export default {
|
|
data() {
|
|
return {
|
|
page: "",
|
|
sceneName:"",
|
|
canScan: true, // 是否显示自定义扫码界面
|
|
flashBtn: 'off', // off关闭 on 打开手电筒
|
|
scanResult: '' ,// 扫描结果
|
|
scancodeOpen:"/static/images/turn_on.png",
|
|
scancodeClose:"/static/images/turn_off.png",
|
|
};
|
|
},
|
|
onShow() {
|
|
this.page= "scan"
|
|
},
|
|
methods: {
|
|
async scancode(event) {
|
|
if (this.isTf) return;
|
|
this.isTf = true;
|
|
setTimeout(() => {
|
|
// 3秒扫描一次
|
|
this.isTf = false;
|
|
return;
|
|
}, 3000);
|
|
uni.vibrateShort(); // 触发手机振动
|
|
const { result } = event.detail; // 获取校验扫描结果
|
|
const { data: res } = await uni.$http.post('/small/scene/manage/listApp',{guid:result})
|
|
|
|
if (res.rows.length==0) {
|
|
return uni.showToast({title: '未找到相关演练场景'})
|
|
}
|
|
res.rows.forEach(item=>{
|
|
this.sceneName = item.name
|
|
})
|
|
uni.navigateTo({
|
|
url: '/subpkg/role/role?guid=' + result+'&name='+this.sceneName
|
|
})
|
|
},
|
|
// 打开关闭手电筒
|
|
changeflashBtn(){
|
|
if(this.flashBtn=="off"){
|
|
this.flashBtn="on"
|
|
}else if(this.flashBtn=="on"){
|
|
this.flashBtn="off"
|
|
}
|
|
},
|
|
},
|
|
components: {tabbar}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss">
|
|
.scanBox {
|
|
position: fixed;
|
|
top: 0;
|
|
width: 100%;
|
|
height: 100vh;
|
|
background-color: #000000;
|
|
}
|
|
|
|
|
|
.camera {
|
|
position: relative;
|
|
width: 70vw;
|
|
height: 70vw;
|
|
margin: 20vh auto 0;
|
|
}
|
|
.coverImg{
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
z-index: 99999;
|
|
}
|
|
.scanTip {
|
|
padding: 20rpx 0 0 0;
|
|
font-size: 32rpx;
|
|
text-align: center;
|
|
color: #fff;
|
|
}
|
|
|
|
|
|
/* 开关手电筒 */
|
|
.scancodePic{
|
|
background: transparent !important;
|
|
width: 100rpx;
|
|
height: 100rpx;
|
|
padding: 0 !important;
|
|
}
|
|
.scancodePic>image{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
</style>
|
|
|