Browse Source

扫码?

master
jiazhipeng 11 months ago
parent
commit
2c152eacef
  1. 56
      components/scanCode.vue
  2. 173
      package-lock.json
  3. 20
      package.json
  4. 31
      pages/verification/index.vue

56
components/scanCode.vue

@ -0,0 +1,56 @@
<template>
<view>
<text>{{ result }}</text>
<qrcode-stream @decode="onDecode" @init="initQR" />
</view>
</template>
<script>
//
import { QrcodeStream } from "vue-qrcode-reader";
export default {
name: "scanCodeVue",
data() {
return {
result: '', //
error: '',
}
},
components: {QrcodeStream},
methods: {
onDecode(result) {
this.result = result;
_this.$emit("success", result)
},
async initQR(promise) {
let _this = this
const { capabilities } = await promise;
const TORCH_IS_SUPPORTED = !!capabilities.torch;
try {
let res = await promise;
console.log(res)
} catch (error) {
if (error.name === "NotAllowedError") {
this.error = "ERROR: 您需要授予相机访问权限";
} else if (error.name === "NotFoundError") {
this.error = "ERROR: 这个设备上没有摄像头";
} else if (error.name === "NotSupportedError") {
this.error = "ERROR: 所需的安全上下文(HTTPS、本地主机)";
} else if (error.name === "NotReadableError") {
this.error = "ERROR: 相机被占用";
} else if (error.name === "OverconstrainedError") {
this.error = "ERROR: 安装摄像头不合适";
} else if (error.name === "StreamApiNotSupportedError") {
this.error = "ERROR: 此浏览器不支持流API";
} else {
this.error = '获取摄像头权限失败'
}
_this.$emit("fail", this.error)
}
},
},
}
</script>

173
package-lock.json

@ -1,11 +1,174 @@
{ {
"requires": true, "name": "tourGuide",
"version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true,
"dependencies": { "dependencies": {
"weixin-js-sdk": { "@babel/helper-string-parser": {
"version": "1.6.5", "version": "7.25.9",
"resolved": "https://registry.npmmirror.com/weixin-js-sdk/-/weixin-js-sdk-1.6.5.tgz", "resolved": "https://registry.npmmirror.com/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz",
"integrity": "sha512-Gph1WAWB2YN/lMOFB/ymb+hbU/wYazzJgu6PMMktCy9cSCeW5wA6Zwt0dpahJbJ+RJEwtTv2x9iIu0U4enuVSQ==" "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA=="
},
"@babel/helper-validator-identifier": {
"version": "7.25.9",
"resolved": "https://registry.npmmirror.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz",
"integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ=="
},
"@babel/parser": {
"version": "7.26.2",
"resolved": "https://registry.npmmirror.com/@babel/parser/-/parser-7.26.2.tgz",
"integrity": "sha512-DWMCZH9WA4Maitz2q21SRKHo9QXZxkDsbNZoVD62gusNtNBBqDg9i7uOhASfTfIGNzW+O+r7+jAlM8dwphcJKQ==",
"requires": {
"@babel/types": "^7.26.0"
}
},
"@babel/types": {
"version": "7.26.0",
"resolved": "https://registry.npmmirror.com/@babel/types/-/types-7.26.0.tgz",
"integrity": "sha512-Z/yiTPj+lDVnF7lWeKCIJzaIkI0vYO87dMpZ4bg4TDrFe4XXLFWL1TbXU27gBP3QccxV9mZICCrnjnYlJjXHOA==",
"requires": {
"@babel/helper-string-parser": "^7.25.9",
"@babel/helper-validator-identifier": "^7.25.9"
}
},
"@vue/compiler-sfc": {
"version": "2.7.16",
"resolved": "https://registry.npmmirror.com/@vue/compiler-sfc/-/compiler-sfc-2.7.16.tgz",
"integrity": "sha512-KWhJ9k5nXuNtygPU7+t1rX6baZeqOYLEforUPjgNDBnLicfHCoi48H87Q8XyLZOrNNsmhuwKqtpDQWjEFe6Ekg==",
"requires": {
"@babel/parser": "^7.23.5",
"postcss": "^8.4.14",
"prettier": "^1.18.2 || ^2.0.0",
"source-map": "^0.6.1"
}
},
"@zxing/library": {
"version": "0.18.6",
"resolved": "https://registry.npmmirror.com/@zxing/library/-/library-0.18.6.tgz",
"integrity": "sha512-bulZ9JHoLFd9W36pi+7e7DnEYNJhljYjZ1UTsKPOoLMU3qtC+REHITeCRNx40zTRJZx18W5TBRXt5pq2Uopjsw==",
"requires": {
"@zxing/text-encoding": "~0.9.0",
"ts-custom-error": "^3.0.0"
}
},
"@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
},
"barcode-detector": {
"version": "0.5.0",
"resolved": "https://registry.npmmirror.com/barcode-detector/-/barcode-detector-0.5.0.tgz",
"integrity": "sha512-CL0ETCnLjaklGbFJeU1f5SU3CHVK1Tm+SjPbLKlt8iJ6Fqgc9yseNmWEpXSPmcGW3ET3rUwkWk2fXG+kcSbwBw==",
"requires": {
"@zxing/library": "^0.18.4",
"jsqr": "^1.3.1"
}
},
"callforth": {
"version": "0.3.1",
"resolved": "https://registry.npmmirror.com/callforth/-/callforth-0.3.1.tgz",
"integrity": "sha512-Q2zPfqnwoKsb1DTVCr4lmhe49wKNBsMmNlbudjleu3/co+Nw1pOqFHYJHrW3VZ253ou9AAr+xauQR0C55NPdzA=="
},
"core-js": {
"version": "3.39.0",
"resolved": "https://registry.npmmirror.com/core-js/-/core-js-3.39.0.tgz",
"integrity": "sha512-raM0ew0/jJUqkJ0E6e8UDtl+y/7ktFivgWvqw8dNSQeNWoSDLvQ1H/RN3aPXB9tBd4/FhyR4RDPGhsNIMsAn7g=="
},
"csstype": {
"version": "3.1.3",
"resolved": "https://registry.npmmirror.com/csstype/-/csstype-3.1.3.tgz",
"integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="
},
"jsqr": {
"version": "1.4.0",
"resolved": "https://registry.npmmirror.com/jsqr/-/jsqr-1.4.0.tgz",
"integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A=="
},
"nanoid": {
"version": "3.3.8",
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.8.tgz",
"integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w=="
},
"picocolors": {
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.1.1.tgz",
"integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA=="
},
"postcss": {
"version": "8.4.49",
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.49.tgz",
"integrity": "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==",
"requires": {
"nanoid": "^3.3.7",
"picocolors": "^1.1.1",
"source-map-js": "^1.2.1"
}
},
"prettier": {
"version": "2.8.8",
"resolved": "https://registry.npmmirror.com/prettier/-/prettier-2.8.8.tgz",
"integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==",
"optional": true
},
"rtcpeerconnection-shim": {
"version": "1.2.15",
"resolved": "https://registry.npmmirror.com/rtcpeerconnection-shim/-/rtcpeerconnection-shim-1.2.15.tgz",
"integrity": "sha512-C6DxhXt7bssQ1nHb154lqeL0SXz5Dx4RczXZu2Aa/L1NJFnEVDxFwCBo3fqtuljhHIGceg5JKBV4XJ0gW5JKyw==",
"requires": {
"sdp": "^2.6.0"
}
},
"sdp": {
"version": "2.12.0",
"resolved": "https://registry.npmmirror.com/sdp/-/sdp-2.12.0.tgz",
"integrity": "sha512-jhXqQAQVM+8Xj5EjJGVweuEzgtGWb3tmEEpl3CLP3cStInSbVHSg0QWOGQzNq8pSID4JkpeV2mPqlMDLrm0/Vw=="
},
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
},
"source-map-js": {
"version": "1.2.1",
"resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz",
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA=="
},
"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=="
},
"vue": {
"version": "2.7.16",
"resolved": "https://registry.npmmirror.com/vue/-/vue-2.7.16.tgz",
"integrity": "sha512-4gCtFXaAA3zYZdTp5s4Hl2sozuySsgz4jy1EnpBHNfpMa9dK1ZCG7viqBPCwXtmgc8nHqUsAu3G4gtmXkkY3Sw==",
"requires": {
"@vue/compiler-sfc": "2.7.16",
"csstype": "^3.1.0"
}
},
"vue-qrcode-reader": {
"version": "3.0.0",
"resolved": "https://registry.npmmirror.com/vue-qrcode-reader/-/vue-qrcode-reader-3.0.0.tgz",
"integrity": "sha512-44TT0PQxMOBtSiJg+8/lM9jXGIBEtp2U3sy642uv13IfKquwEv1UtNyof2y8lILsRX7cn7xt0XkUahIHWyEXAQ==",
"requires": {
"barcode-detector": "^0.5.0",
"callforth": "^0.3.1",
"core-js": "^3.6.5",
"vue": "^2.6.11",
"webrtc-adapter": "7.7.0"
}
},
"webrtc-adapter": {
"version": "7.7.0",
"resolved": "https://registry.npmmirror.com/webrtc-adapter/-/webrtc-adapter-7.7.0.tgz",
"integrity": "sha512-7Bp9OBnx642oJRkom1tNAbeJjUadAq2rh5xLL9YXPw5hVyt2h4hHr5bcoPYDs1stp/mZHSPSQA34YISdnr0DBQ==",
"requires": {
"rtcpeerconnection-shim": "^1.2.15",
"sdp": "^2.12.0"
}
} }
} }
} }

20
package.json

@ -0,0 +1,20 @@
{
"name": "tourGuide",
"version": "1.0.0",
"description": "",
"main": "main.js",
"dependencies": {
"vue-qrcode-reader": "^3.0.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://47.114.134.244:3000/chenkainan/tourGuide.git"
},
"keywords": [],
"author": "",
"license": "ISC"
}

31
pages/verification/index.vue

@ -128,17 +128,25 @@
</view> </view>
</uni-popup> </uni-popup>
<template v-if="showScan">
<scanCodeVue ref="scanCodeVueRef" @success="getCode" @fail="scanFail"></scanCodeVue>
</template>
</view> </view>
</template> </template>
<script> <script>
import scanCodeVue from "../../components/scanCode.vue"
export default { export default {
components:{scanCodeVue},
data() { data() {
return { return {
type: 0, type: 0,
HXCode: '', // HXCode: '', //
HXPhone:"", HXPhone:"",
orderList: [], orderList: [],
showScan: false,
}; };
}, },
onShow() { onShow() {
@ -149,19 +157,16 @@
methods: { methods: {
scanCode () { scanCode () {
let _this = this this.showScan = true
uni.showLoading() },
wxsdk.scanQRCode({ getCode (res) {
needResult: 1, // 01 console.log(res)
scanType: ["qrCode", "barCode"], // this.showScan = false
success: function (res) { },
uni.hideLoading() scanFail(res) {
alert(res.resultStr.split('?')[1].split('=')[1]) this.showScan = false
// _this.getOrderByCode(res.resultStr.split('?')[1].split('=')[1]) uni.showToast({
}, title: res,icon:"none"
fail: function (error) {
uni.hideLoading()
}
}) })
}, },

Loading…
Cancel
Save