Browse Source

企业端二维码扫码

master
蟑螂恶霸 2 years ago
parent
commit
50d14d18ca
  1. 28
      package-lock.json
  2. 3
      package.json
  3. 1
      src/api/Home.js
  4. 7
      src/config/env.js
  5. 9
      src/router/enforceHome.js
  6. 1
      src/views/enforce/enterpriseScanPreview.vue
  7. 251
      src/views/enforce/scanPage_szy.vue
  8. 2
      src/views/enforce/scanQrCode.vue
  9. 7
      src/views/enforceHome.vue

28
package-lock.json

@ -12,6 +12,7 @@
"axios": "^1.6.7",
"core-js": "^3.36.0",
"crypto-js": "^4.2.0",
"date-fns": "^3.6.0",
"echarts": "^5.5.0",
"html2canvas": "^1.4.1",
"jsonp": "^0.2.1",
@ -31,7 +32,8 @@
"vue-pdf": "^4.3.0",
"vue-pdf-embed": "^2.0.3",
"vue-qrcode-reader": "^5.5.3",
"vue-router": "^4.3.0"
"vue-router": "^4.3.0",
"weixin-js-sdk": "^1.6.5"
},
"devDependencies": {
"@vitejs/plugin-basic-ssl": "^1.1.0",
@ -4925,6 +4927,15 @@
"integrity": "sha512-0sVXIohTfLqVIW3kb/0n6IiWF3Ifj5nm2XaSrLq2DI6fKIGa2fYAZdk917rUneaeLVpYfFcyXE2ft0fe3remsA==",
"peer": true
},
"node_modules/date-fns": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz",
"integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww==",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/kossnocorp"
}
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@ -11923,6 +11934,11 @@
"npm": ">=3.10.0"
}
},
"node_modules/weixin-js-sdk": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/weixin-js-sdk/-/weixin-js-sdk-1.6.5.tgz",
"integrity": "sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ=="
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
@ -15572,6 +15588,11 @@
"integrity": "sha512-0sVXIohTfLqVIW3kb/0n6IiWF3Ifj5nm2XaSrLq2DI6fKIGa2fYAZdk917rUneaeLVpYfFcyXE2ft0fe3remsA==",
"peer": true
},
"date-fns": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-3.6.0.tgz",
"integrity": "sha512-fRHTG8g/Gif+kSh50gaGEdToemgfj74aRX3swtiouboip5JDLAyDE9F11nHMIcvOaXeOC6D7SpNhi7uFyB7Uww=="
},
"debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
@ -20906,6 +20927,11 @@
"sdp": "^3.2.0"
}
},
"weixin-js-sdk": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/weixin-js-sdk/-/weixin-js-sdk-1.6.5.tgz",
"integrity": "sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ=="
},
"whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",

3
package.json

@ -39,7 +39,8 @@
"vue-pdf": "^4.3.0",
"vue-pdf-embed": "^2.0.3",
"vue-qrcode-reader": "^5.5.3",
"vue-router": "^4.3.0"
"vue-router": "^4.3.0",
"weixin-js-sdk": "^1.6.5"
},
"devDependencies": {
"@vitejs/plugin-basic-ssl": "^1.1.0",

1
src/api/Home.js

@ -16,5 +16,6 @@ export const getSiqLoginAuthTest = (params, success, error) => _post("/app/third
// 深圳易平台登录
export const getSzyptLoginAuth = (code, success, error) => _get("/app/thirdLogin/szyptLogin/"+code,null,success,error);
export const szyptGetToken = (params, success, error) => _get("/app/thirdLogin/szyptGetToken",params,success,error);

7
src/config/env.js

@ -1,10 +1,7 @@
//本地环境
// let baseUrl="http://192.168.110.36:85";
// let baseUrl="http://localhost:85";
let baseUrl="https://139.186.135.156:86";
// let baseUrl="http://139.186.135.156:86";
// let baseUrl="http://10.132.108.3:85";
// let baseUrl="http://192.168.1.101:85";
let baseUrl="http://10.132.108.3:85";
// let baseUrl="http://192.168.1.105:85";
// let wsUrl='ws://10.76.108.1:9326';
export {
baseUrl,

9
src/router/enforceHome.js

@ -38,6 +38,15 @@ const routes = [
isKeepAlive: false,
},
},
//执法端扫码页面-深圳易
{
path: "/enforce/scanPage_szy",
name: "scanPage",
component: () => import("@/views/enforce/scanPage_szy.vue"),
meta: {
isKeepAlive: false,
},
},
//执法端扫码页面
// {
// path: "/enforce/scanPageTest",

1
src/views/enforce/enterpriseScanPreview.vue

@ -135,7 +135,6 @@ const onLoad = () => {
};
onMounted(() => {
getEnterpriseInformation(data.enterpriseNumber,success =>{
if (null != success.data) {
data.searchParam.enterpriseNumber = success.data.enterpriseNumber;

251
src/views/enforce/scanPage_szy.vue

@ -0,0 +1,251 @@
<template>
<div class="page bgc-f4f4f4">
<label class="backlab" @click="back()"></label>
<div class="video-show" />
<video id="video" ref="video" class="video vjs-fluid" autoplay />
<span class="change" @click="change">
<i class="el-icon-refresh" />
</span>
</div>
</template>
<!-- import Vconsolefrom from 'vconsole'; -->
<!-- new Vconsolefrom(); -->
<script>
//
import Vconsole from "vconsole";
import { BrowserMultiFormatReader } from "@zxing/library";
import {szyptGetToken} from '../../api/Home';
import wx from 'weixin-js-sdk';
export default {
name: "QrCodeSearch",
components: {},
data() {
return {
loadingShow: false,
// @zxing/librarynew
codeReader: new BrowserMultiFormatReader(),
//
textContent: null,
// 6
num: 6,
//
videoLength: ""
};
},
created() {
//
this.openScan();
// new Vconsole();
},
methods: {
//
openScan() {
let that = this;
let fullUrl = window.location.href;
let code = fullUrl.substring(fullUrl.indexOf('code=')+5, fullUrl.indexOf('&state='));
let paramUrl = window.location.href.split("#")[0];
let param = { code: code, url: paramUrl };
szyptGetToken(param,success =>{
let resMsg = success.data;
console.log(resMsg);
wx.config({
// ,apialertpclogpc
debug: false,
//
appId: resMsg.corpid,
//
timestamp: resMsg.timestamp,
//
nonceStr: resMsg.nonceStr,
// 1
signature: resMsg.signature,
// 使JSJS2
jsApiList: ["scanQRCode"],
});
wx.ready(() => {
//
this.ClickScan()
});
wx.error((res) => {
console.log("获取失败");
});
},error =>{});
},
ClickScan() {
wx.scanQRCode({
needResult: 1, // 01
scanType: ['qrCode', 'barCode'], //
success: (res) => {
//
console.log("=========== 扫码返回 ===========")
console.log(res)
this.$router.push({
path:"/enterpriseScanPreview",
query:{
enterpriseNumber: res.resultStr
}
})
},
cancel: (res) => {
console.log('err', res);
},
});
},
//openScanid
decodeFromInputVideoFunc(firstDeviceId, length) {
const that = this;
that.codeReader.reset(); //
that.textContent = null; //
//
that.codeReader.decodeFromInputVideoDeviceContinuously(
firstDeviceId,
"video",
(result, err) => {
that.textContent = null;
// result
if (result) {
that.textContent = result;
//
if (that.textContent) {
setTimeout(() => {
this.$router.push({
path:"/enterpriseScanPreview",
query:{
enterpriseNumber: that.textContent
}
})
//
that.textContent = null;
that.codeReader && that.codeReader.reset();
}, 100);
}
}
//
if (err && !err) {
this.num++;
setTimeout(() => {
that.tipShow = false;
}, 2000);
if (this.num <= length) {
that.openScan();
}
console.error(err);
}
}
);
},
//
change() {
const that = this;
if (this.videoLength > 2) {
if (this.num < 2) {
this.num = 6;
} else {
this.num = 1;
}
that.textContent = null;
that.codeReader && that.codeReader.reset();
that.openScan();
} else {
if (that.num === 0) {
that.num = 1;
} else {
that.num = 0;
}
that.textContent = null;
that.codeReader && that.codeReader.reset();
that.openScan();
}
},
back(){
this.$router.go(-1);
},
}
};
</script>
<style scoped>
.backlab {
position: absolute;
z-index: 999999;
top: 0.5rem;
left: 0.35rem;
padding-left: 0;
width: 0.6rem;
height: 0.6rem;
background: url(../../assets/images/icon_arbw.png) no-repeat left 40% center;
background-size: auto 50%;
background-color: rgba(255, 255, 255, .2);
border: 1px solid rgba(255, 255, 255, .7);
border-radius: 50%;
}
.video {
width: 100vw;
height: 100vh;
z-index: 1;
}
.video-show {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 70vw;
height: 70vw;
z-index: 2;
background: linear-gradient(to left, #fff, #fff) left top no-repeat,
linear-gradient(to bottom, #fff, #fff) left top no-repeat,
linear-gradient(to left, #fff, #fff) right top no-repeat,
linear-gradient(to bottom, #fff, #fff) right top no-repeat,
linear-gradient(to left, #fff, #fff) left bottom no-repeat,
linear-gradient(to bottom, #fff, #fff) left bottom no-repeat,
linear-gradient(to left, #fff, #fff) right bottom no-repeat,
linear-gradient(to left, #fff, #fff) right bottom no-repeat;
background-size: 2px 20px, 20px 2px, 2px 20px, 20px 2px;
}
.tip {
width: 10vw;
height: 10vw;
background-color: rgb(45, 236, 45);
border: 1px solid #ffffff;
border-radius: 50%;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 10;
}
.bgc-f4f4f4 {
background-color: #363636;
}
.page {
position: relative;
overflow-y: auto;
position: relative;
height: 100vh;
}
.change {
z-index: 100;
position: fixed;
bottom: 40px;
left: 50%;
transform: translateX(-50%);
color: #fff;
text-align: center;
background-color: #fff;
width: 50px;
height: 50px;
border-radius: 50%;
line-height: 60px;
/* align-content: center; */
}
.el-icon-refresh {
color: #000;
font-size: 25px;
}
</style>

2
src/views/enforce/scanQrCode.vue

@ -88,7 +88,7 @@ const boutiqueGoods = async () => {
const toScanPageView = async() =>{
router.push({
path: "/enforce/scanPage",
path: "/enforce/scanPage_szy",
query: {}
});
};

7
src/views/enforceHome.vue

@ -126,8 +126,11 @@ const onLoad = () => {
};
onMounted(() => {
console.log("code: "+route?.query?.code);
getSzyptLoginAuth(route?.query?.code,success =>{
let fullUrl = window.location.href;
let code = fullUrl.substring(fullUrl.indexOf('code=')+5, fullUrl.indexOf('&state='));
// getSzyptLoginAuth(route?.query?.code,success =>{
getSzyptLoginAuth(code,success =>{
console.log(success.data)
},error =>{

Loading…
Cancel
Save