From e11ff85be8850dd686ce81be75cf2c389ce96cbb Mon Sep 17 00:00:00 2001 From: liwenxuan <1298531568@qq.com> Date: Wed, 19 Feb 2025 14:38:33 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=AE=9E=E7=8E=B0=E8=B0=83=E7=94=A8=E4=BC=81?= =?UTF-8?q?=E4=B8=9A=E5=BE=AE=E4=BF=A1=E6=89=AB=E4=B8=80=E6=89=AB=202.?= =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=9F=BA=E4=BA=8Ezxing/library=E7=9A=84?= =?UTF-8?q?=E6=97=A2=E6=94=AF=E6=8C=81=E6=89=AB=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E4=B9=9F=E6=94=AF=E6=8C=81=E6=89=AB=E6=9D=A1=E7=A0=81=E7=9A=84?= =?UTF-8?q?=E6=89=AB=E7=A0=81=E7=BB=84=E4=BB=B6=203.=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E8=87=AA=E7=A0=94zxing=E7=BB=84=E4=BB=B6=E5=B0=8F=E7=B1=B3?= =?UTF-8?q?=E6=89=8B=E6=9C=BA=E4=B8=AD=E7=9A=84=E4=BC=81=E4=B8=9A=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1=E5=8F=AA=E8=83=BD=E8=8E=B7=E5=8F=96=E5=88=B0=E5=89=8D?= =?UTF-8?q?=E7=BD=AE=E6=91=84=E5=83=8F=E5=A4=B4,=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E6=8C=89=E9=9C=80=E5=8A=A0=E8=BD=BD=E5=8A=9F=E8=83=BD,?= =?UTF-8?q?=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1=E7=8E=AF=E5=A2=83=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E4=BC=81=E4=B8=9A=E5=BE=AE=E4=BF=A1=E6=89=AB=E4=B8=80?= =?UTF-8?q?=E6=89=AB,=E5=85=B6=E5=AE=83=E7=8E=AF=E5=A2=83=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E8=87=AA=E7=A0=94zxing=E6=89=AB=E7=A0=81=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- package-lock.json | 49 ++- package.json | 5 +- src/components/lowCode/formItem.vue | 62 +++- src/views/home/scanQrCode.vue | 267 +++++++-------- src/views/home/scanQrCode1.vue | 368 ++++++++++---------- src/views/home/scanQrCodeInput.vue | 497 +++++++++++++++++++--------- src/views/home/scanQrCodeInput1.vue | 195 +++++++++++ 8 files changed, 965 insertions(+), 480 deletions(-) create mode 100644 src/views/home/scanQrCodeInput1.vue diff --git a/index.html b/index.html index 4a71864..eb8814f 100644 --- a/index.html +++ b/index.html @@ -6,11 +6,11 @@ - 数通智联化工云平台
+ diff --git a/package-lock.json b/package-lock.json index 587d4f8..ded01cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,8 @@ "version": "0.0.0", "dependencies": { "@element-plus/icons-vue": "^2.3.1", + "@zxing/browser": "^0.1.5", + "@zxing/library": "^0.21.3", "axios": "^1.7.7", "element-plus": "^2.8.6", "font-awesome": "^4.7.0", @@ -29,7 +31,8 @@ "vue-qrcode-reader": "^5.7.0", "vue-router": "^4.4.5", "vue3-pdf-embed": "^1.1.7", - "vue3-pdfjs": "^0.1.6" + "vue3-pdfjs": "^0.1.6", + "weixin-js-sdk": "^1.6.5" }, "devDependencies": { "@types/js-beautify": "^1.14.3", @@ -1780,6 +1783,37 @@ } } }, + "node_modules/@zxing/browser": { + "version": "0.1.5", + "resolved": "https://registry.npmmirror.com/@zxing/browser/-/browser-0.1.5.tgz", + "integrity": "sha512-4Lmrn/il4+UNb87Gk8h1iWnhj39TASEHpd91CwwSJtY5u+wa0iH9qS0wNLAWbNVYXR66WmT5uiMhZ7oVTrKfxw==", + "optionalDependencies": { + "@zxing/text-encoding": "^0.9.0" + }, + "peerDependencies": { + "@zxing/library": "^0.21.0" + } + }, + "node_modules/@zxing/library": { + "version": "0.21.3", + "resolved": "https://registry.npmmirror.com/@zxing/library/-/library-0.21.3.tgz", + "integrity": "sha512-hZHqFe2JyH/ZxviJZosZjV+2s6EDSY0O24R+FQmlWZBZXP9IqMo7S3nb3+2LBWxodJQkSurdQGnqE7KXqrYgow==", + "dependencies": { + "ts-custom-error": "^3.2.1" + }, + "engines": { + "node": ">= 10.4.0" + }, + "optionalDependencies": { + "@zxing/text-encoding": "~0.9.0" + } + }, + "node_modules/@zxing/text-encoding": { + "version": "0.9.0", + "resolved": "https://registry.npmmirror.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", + "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", + "optional": true + }, "node_modules/abbrev": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/abbrev/-/abbrev-2.0.0.tgz", @@ -7038,6 +7072,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/ts-custom-error": { + "version": "3.3.1", + "resolved": "https://registry.npmmirror.com/ts-custom-error/-/ts-custom-error-3.3.1.tgz", + "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/ts-md5": { "version": "1.3.1", "resolved": "https://registry.npmmirror.com/ts-md5/-/ts-md5-1.3.1.tgz", @@ -7823,6 +7865,11 @@ "npm": ">=3.10.0" } }, + "node_modules/weixin-js-sdk": { + "version": "1.6.5", + "resolved": "https://registry.npmmirror.com/weixin-js-sdk/-/weixin-js-sdk-1.6.5.tgz", + "integrity": "sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ==" + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmmirror.com/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index d755b5e..1a486ae 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.3.1", + "@zxing/browser": "^0.1.5", + "@zxing/library": "^0.21.3", "axios": "^1.7.7", "element-plus": "^2.8.6", "font-awesome": "^4.7.0", @@ -31,7 +33,8 @@ "vue-qrcode-reader": "^5.7.0", "vue-router": "^4.4.5", "vue3-pdf-embed": "^1.1.7", - "vue3-pdfjs": "^0.1.6" + "vue3-pdfjs": "^0.1.6", + "weixin-js-sdk": "^1.6.5" }, "devDependencies": { "@types/js-beautify": "^1.14.3", diff --git a/src/components/lowCode/formItem.vue b/src/components/lowCode/formItem.vue index b1553cf..bf992e7 100644 --- a/src/components/lowCode/formItem.vue +++ b/src/components/lowCode/formItem.vue @@ -16,6 +16,8 @@ import { } from '@/api/lowCode/utils'; import { AnalysisCss,AnalysisInputCss } from '@/api/common/cssInfo' import validate from "@/api/lowCode/form/validate" +import wx from 'weixin-js-sdk' +import request from '@/utils/axios/index' import { Md5 } from 'ts-md5' import { debounce } from '@/utils/lowCode/item/index' @@ -123,6 +125,62 @@ const handleScanResult = (val: any) => { updateModel(val) qrScaning.value = false } + +const isQywx = ref(false) +onMounted(()=>{ + if (/wxwork\//.test(navigator.userAgent)) { + isQywx.value = true + } +}) +const handelScan = ()=>{ + if(isQywx.value == true){//企业微信环境 + initWxConfig() + }else{//浏览器环境 + qrScaning.value=true + } + +} +function getQyWxSignature() { + let url = window.location.href.split("#")[0]; + var req = {url:"1"}; + req.url = url; + return request({ + url: "/javasys/lowCode/QrCode/QyWxSignature", + method: "get", + data: req, + }); +} +async function initWxConfig() { + getQyWxSignature().then(({ data }) => { + //alert(data.corpid) + wx.config({ + beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题 + debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 + appId: data.corpid, // 必填,企业微信的corpID + timestamp: data.timestamp, // 必填,生成签名的时间戳 + nonceStr: data.noncestr, // 必填,生成签名的随机串 + signature: data.jsapi_ticket_enterprises,// 必填,签名,见 附录-JS-SDK使用权限签名算法 + jsApiList: ['scanQRCode'] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来 + }); + startScan() + }); +} +// 触发扫码 +function startScan() { + wx.ready(() => { + wx.scanQRCode({ + needResult: 1, // 返回扫码结果 + scanType: ['qrCode','barCode'], // 扫码类型:二维码 条码 + success: (res) => { + const result = res.resultStr; + handleScanResult(result); + }, + fail: (err) => { + alert(err.errMsg) + } + }); + }); +} //liwenxuan 20250217 扫描录入 end //获取值 const value = computed({ @@ -579,7 +637,7 @@ const currentComponent = computed(() => { {{ config.append }} diff --git a/src/views/home/scanQrCode.vue b/src/views/home/scanQrCode.vue index ca246f9..8cea4b6 100644 --- a/src/views/home/scanQrCode.vue +++ b/src/views/home/scanQrCode.vue @@ -1,41 +1,43 @@ - +} + - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/home/scanQrCode1.vue b/src/views/home/scanQrCode1.vue index 95418e8..ca246f9 100644 --- a/src/views/home/scanQrCode1.vue +++ b/src/views/home/scanQrCode1.vue @@ -1,212 +1,184 @@ + + // 定义变量 + const dataList = ref('') + const result = ref(true) + const error = ref('') - - ​ \ No newline at end of file +} + + \ No newline at end of file diff --git a/src/views/home/scanQrCodeInput.vue b/src/views/home/scanQrCodeInput.vue index 32fa3b3..7c5ee26 100644 --- a/src/views/home/scanQrCodeInput.vue +++ b/src/views/home/scanQrCodeInput.vue @@ -1,186 +1,343 @@ - - \ No newline at end of file + +@keyframes Heightchange { + 0% { + height: 0; + } + + 100% { + height: 100%; + } +} + +.txt { + width: 100%; + height: 35px; + line-height: 35px; + font-size: 14px; + text-align: center; + /* color: #f9f9f9; */ + margin: 0 auto; + position: absolute; + top: 63%; + left: 0; + color: white; + z-index: 1001; +} + +.close-icon { + position: absolute; + top: 15px; + left: 15px; + width: 20px; + height: 20px; + color: white; + z-index: 1001; + cursor: pointer; + background: rgba(0, 0, 0, 0.3); /* 可选背景 */ + border-radius: 50%; /* 圆形背景 */ + padding: 5px; + /* 点击区域扩大 */ +} +.Qr_scanner { + z-index: 999; /* 低于图标容器 */ + /* 其他原有样式保持不变 */ +} + diff --git a/src/views/home/scanQrCodeInput1.vue b/src/views/home/scanQrCodeInput1.vue new file mode 100644 index 0000000..32fa3b3 --- /dev/null +++ b/src/views/home/scanQrCodeInput1.vue @@ -0,0 +1,195 @@ + + + \ No newline at end of file