Browse Source

执法监督码-执法端二维码扫描

master
chenrui 3 years ago
parent
commit
2cff0a6bc7
  1. 3
      package.json
  2. BIN
      src/assets/images/scan.png
  3. 11
      src/router/home.js
  4. 119
      src/views/enforce/scanPage.vue
  5. 256
      src/views/enforce/scanQrCode.vue
  6. 17
      src/views/enforceHome.vue
  7. 5
      src/views/enterprise/registrationList.vue

3
package.json

@ -15,6 +15,7 @@
"docs:preview": "vitepress preview docs"
},
"dependencies": {
"@zxing/library": "^0.20.0",
"axios": "^1.6.7",
"core-js": "^3.36.0",
"jsonp": "^0.2.1",
@ -22,10 +23,12 @@
"mitt": "^3.0.1",
"pinia": "^2.1.7",
"pinia-plugin-persistedstate": "^3.2.1",
"sass": "^1.71.1",
"vant": "^4.8.5",
"vue": "^3.4.21",
"vue-dompurify-html": "^5.0.1",
"vue-i18n": "^9.9.1",
"vue-qrcode-reader": "^5.5.3",
"vue-router": "^4.3.0"
},
"devDependencies": {

BIN
src/assets/images/scan.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

11
src/router/home.js

@ -7,15 +7,6 @@ const routes = [
component: login,
meta: {},
},
//执法端首页
{
path: "/enforceHome",
name: "enforceHome",
component: () => import("@/views/enforceHome.vue"),
meta: {
isKeepAlive: true,
},
},
//企业端首页
{
path: "/home",
@ -58,7 +49,7 @@ const routes = [
name: "complaint",
component: () => import("@/views/enterprise/complaint.vue"),
},
// 在线投诉
// 执法列表
{
path: "/enterprise/enterpriseInspectionList",
name: "enterpriseInspectionList",

119
src/views/enforce/scanPage.vue

@ -0,0 +1,119 @@
<template>
<div class="scan-page">
<!-- 返回导航栏 -->
<!-- left-text="取消" -->
<van-nav-bar title="扫描二维码/条形码" left-arrow
fixed class="scan-index-bar" @click-left="clickIndexLeft()"
></van-nav-bar>
<!-- 扫码区域 -->
<video ref="video" id="video" class="scan-video" autoplay></video>
<!-- 提示语 -->
<div v-show="tipShow" class="scan-tip">{{ tipMsg }}</div>
</div>
</template>
<script>
import { BrowserMultiFormatReader } from '@zxing/library';
import { Toast, Dialog, Notify } from 'vant';
export default {
name: 'ScanCodePage', //
data() {
return {
codeReader: null,
tipShow: false, //
tipMsg: '', //
scanText: '', //
}
},
created() {
this.openScan();
},
watch: {
'$route'(to, from) {
if(to.path == '/ScanCodePage'){ //
this.openScan();
}
}
},
destroyed(){
this.codeReader.reset();
this.codeReader = null;
},
methods: {
async openScan() { //
this.codeReader = await new BrowserMultiFormatReader();
this.codeReader.getVideoInputDevices().then(videoDevices => {
this.tipMsg = '正在调用摄像头...';
this.tipShow = true;
console.log('get-videoDevices', videoDevices);
// id
let firstDeviceId = videoDevices[videoDevices.length - 1].deviceId;
//
if (videoDevices.length > 1) {
// label 'camera2 0, facing back' 'back' '0'
firstDeviceId = videoDevices.find(el => { return el.label.indexOf('back') > -1 && el.label.indexOf('0') > -1 }) ?
videoDevices.find(el => { return el.label.indexOf('back') > -1 && el.label.indexOf('0') > -1 }).deviceId :
videoDevices[videoDevices.length - 1].deviceId;
}
console.log('get-firstDeviceId', firstDeviceId);
this.decodeFromInputVideoFunc(firstDeviceId);
}).catch(err => {
this.tipShow = false;
console.error(err);
});
},
decodeFromInputVideoFunc(firstDeviceId) { // 使
this.codeReader.reset(); //
this.codeReader.decodeFromInputVideoDeviceContinuously(firstDeviceId, 'video', (result, err) => {
this.tipMsg = '正在尝试识别...';
if (result) {
console.log('扫码结果', result);
this.scanText = result.text;
if (this.scanText) {
this.tipShow = false;
Dialog.confirm({ //
title: '扫码结果',
message: this.scanText,
}).then(() => { //
}).catch(() => { //
});
}
}
});
},
clickIndexLeft(){ //
// this.$destroy();
this.$router.go(-1);
// window.location.href = document.referrer;
}
}
}
</script>
<style lang="scss">
.scan-index-bar{
background-image: linear-gradient( -45deg, #42a5ff ,#59cfff);
.van-nav-bar__title, .van-nav-bar__arrow, .van-nav-bar__text{
color: #fff !important;
}
}
.scan-page{
min-height: 100vh;
background-color: #363636;
overflow-y: hidden;
.scan-video{
height: 85vh;
}
.scan-tip{
width: 100vw;
text-align: center;
color: white;
font-size: 5vw;
}
}
</style>

256
src/views/enforce/scanQrCode.vue

@ -0,0 +1,256 @@
<template>
<div class="home app_content">
<!-- 导航栏 -->
<div class="header_body">
<!-- <header-nav :leftArrow="false" titelText="扫码入企"></header-nav> -->
<header-nav
:slefBack="true"
@goBack="goBack"
:titelText="`扫码入企`"
>
</header-nav>
</div>
<!-- 中间 -->
<div class="warp_body">
<!-- <refresh-list v-model:freshMap="freshMap" @refresh="onRefresh" @onLoad="onLoad"> -->
<div class="carousel_box">
<div class="box-scan-one">
<span class="box-scan-text">扫一扫企业二维码</span>
</div>
<div class="box-scan-two">
<span class="box-scan-text">即可查看企业信息</span>
</div>
</div>
<div class="boutique_box">
<!-- <van-cell :border="false" title="精品" /> -->
<div class="boutique_body">
<!-- <goodsCard :goodsList="boutique" :cardAttr="boutiqueAttr"></goodsCard> -->
<div class="box-qr-code" @click="toScanPageView">
<img src="../../assets/images/scan.png" />
<span class="box-qr-code-text">执法监督码</span>
</div>
</div>
</div>
<!-- <div class="recommend_box">
<van-cell :border="false" title="推荐" />
<div class="recommend_body">
<goodsCard :goodsList="recommend"></goodsCard>
</div>
</div> -->
<!-- </refresh-list> -->
</div>
<!-- 底部 -->
<!-- <div class="footer_body">
<footer-nav></footer-nav>
</div> -->
</div>
</template>
<script setup name="Home">
import {getEnterpriseMerchantAuthorization} from '@/api/Home';
const { useCommon } = $globalStore;
const router = useRouter();
let carouselList = reactive([]); //
let boutique = reactive([]); //
let recommend = reactive([]); //
let freshMap = reactive({
refreshLoad: false, //
listLoading: false, //
listFinished: false, //
});
const data = reactive({});
const boutiqueAttr = reactive({
columnNum: 4,
itemClass: "boutique_item",
goodsCradclass: "boutique-crad",
}); //
//
const getCarousel = async () => {
// const res = await useHome.getCarousel();
// if (res?.code === 20000) {
// carouselList = res?.data;
// }
};
//
const boutiqueGoods = async () => {
// const res = await useHome.boutiqueGoods();
// if (res?.code === 20000) {
// boutique = res?.data;
// }
};
const toScanPageView = async() =>{
router.push({
path: "/enforce/scanPage",
query: {}
});
};
const toRegistrationListView = async() =>{
router.push({
path: "/enterprise/registrationList",
});
}
const toComplaintView = async() =>{
router.push({
path: "/enterprise/complaint",
});
}
//
const onRefresh = () => {
freshMap.listFinished = false;
freshMap.listLoading = true;
freshMap.refreshLoad = true;
// Promise.all([getCarousel(), boutiqueGoods(), recommendGoods()]).then(() => {
// freshMap.refreshLoad = false;
// });
};
//
const onLoad = () => {
// recommendGoods(true);
};
onMounted(() => {
getEnterpriseMerchantAuthorization({merchantTel: useCommon.phonenumber},success =>{
if(!(success.data == null && success.data.length == 0)){
useCommon.SET_USER_ENTERPRISE_NUMBER(success.data[0].enterpriseNumber);
}
},error =>{
})
})
//
const goBack = () => {
router.go(-1);
};
</script>
<style lang="less" scoped>
.home {
display: flex;
flex-direction: column;
height: 100%;
overflow: hidden;
background-color: #f4f4f4;
.warp_body {
background-color: rgb(163, 156, 156);
background-size: cover;
position: relative;
.carousel_box {
height: 150px;
width: 100%;
padding-bottom: 10px;
position: relative;
.box-scan-one{
position: absolute;
top: 30%;
left: 15%;
font-size: 14px;
background-color: beige;
height: 100px;
width: 30%;
.box-scan-text{
margin-top: 70%;
display: block;
font-size: 12px;
width: 100%;
text-align: center
}
}
.box-scan-two{
position: absolute;
top: 30%;
right: 15%;
font-size: 14px;
background-color: beige;
height: 100px;
width: 30%;
.box-scan-text{
margin-top: 70%;
display: block;
font-size: 12px;
width: 100%;
text-align: center
}
}
}
}
.boutique_box {
position: absolute;
width: 100%;
bottom: 30%;
.boutique_body {
padding: 0px 0px 10px 0px;
display: flex;
justify-content: center;
};
.box-qr-code{
width: 47%;
text-align: right;
height: 4.66667rem;
background-color: var(--van-primary-color);
border-radius: 0.26667rem;
// background-size: cover;
border-radius: 50%;
// background-image: url("@/assets/images/scan.png");
.box-qr-code-text{
margin-right: 25%;
margin-top: 70%;
display: block;
font-size: 0.45333rem;
}
img{
position: absolute;
top: 0%;
left: 34%;
}
}
.box-info{
width: 52%;
text-align: right;
height: 3.66667rem;
background-color: #ff976a;
border-radius: 10px;
background: url("@/assets/images/item_check.png");
background-size: cover;
.box-info-text{
margin-right: 3%;
margin-top: 2%;
display: block;
font-size: 17px
}
}
.box-complaint{
width: 36%;
text-align: right;
height: 3.66667rem;
background-color: #ff976a;
border-radius: 10px;
margin-left: 2%;
background: url("@/assets/images/item_complain.png");
background-size: cover;
.box-complaint-text{
margin-right: 5%;
margin-top: 3%;
display: block;
font-size: 17px
}
}
}
.recommend_box {
.recommend_body {
width: 100%;
}
}
}
</style>

17
src/views/enforceHome.vue

@ -15,7 +15,7 @@
<!-- <van-cell :border="false" title="精品" /> -->
<div class="boutique_body">
<!-- <goodsCard :goodsList="boutique" :cardAttr="boutiqueAttr"></goodsCard> -->
<div class="box-qr-code" @click="toRegisterView">
<div class="box-qr-code" @click="toScanCodeView">
<span class="box-qr-code-text">扫码入企</span>
</div>
</div>
@ -80,18 +80,9 @@ const boutiqueGoods = async () => {
// }
};
const toRegisterView = async() =>{
console.log(useCommon.phonenumber);
if(useCommon.enterpriseNumber == null && useCommon.enterpriseNumber == ""){
router.push({ path: "/enterprise/register" });
}else{
router.push({
path: "/enterprise/qrCode",
query: {
enterpriseNumber: useCommon.enterpriseNumber,
}
});
}
/**扫码入企 */
const toScanCodeView = async() =>{
router.push({ path: "/enforce/scanQrCode" });
};
const toRegistrationListView = async() =>{

5
src/views/enterprise/registrationList.vue

@ -6,14 +6,14 @@
<header-nav
:slefBack="true"
@goBack="goBack"
:titelText="`执法信息`"
:titelText="`历史检查信息`"
>
</header-nav>
</div>
<van-search
v-model="searchParam.searchText"
show-action
placeholder="请输入执法人员/执法部门"
placeholder="请输入关键字查询"
@search="onSearch"
>
<template #action>
@ -90,7 +90,6 @@
</template>
<script setup name="registrationList">
import { showToast } from "vant";
import {queryRegistrationList} from '../../api/enterprise';
import { setGoodsNum } from "@/util/util";
const { useCommon, useShopCard } = $globalStore;

Loading…
Cancel
Save