1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

[门禁端&后端&小程序] 完成门禁端;完成小程序扫码跳转页面;完成后端获取不限制的小程序场景码接口

This commit is contained in:
2022-11-28 18:36:52 +08:00
parent 42e3952b83
commit 8640c2b413
20 changed files with 365 additions and 38 deletions

View File

@@ -8,6 +8,11 @@ export default defineAppConfig({
*/
'pages/residents/code', // 进出码
'pages/residents/report', // 体温上报
/**
* 扫码跳转
*/
'pages/scan/entrance', // 门禁码扫码跳转页
],
window: {
backgroundTextStyle: 'dark',

View File

@@ -37,6 +37,7 @@ export default {
this.debugText = JSON.stringify({
TARO_ENV: process.env.TARO_ENV,
globalData: Taro.getApp().globalData,
"启动参数": Taro.getCurrentInstance().router.params,
params: this.params,
storage: storage,
ENUM: ENUM,

View File

@@ -15,6 +15,7 @@
</view>
<button type="primary" size="mini" @tap="toggleDot('code', true)">显示小红点</button>
<button type="primary" size="mini" @tap="toggleDot('code', false)">隐藏小红点</button>
<button type="warn" size="mini" @tap="magicButton">魔法按钮</button>
<DebugComp :params="debugObject" :userGroup="userGroup" />
</view>
</template>
@@ -51,13 +52,13 @@ export default {
onLoad() {
// 开发模式下自动跳转到指定页面,节省开发时间
if (this.debugMode) {
Taro.switchTab({ url: '/pages/residents/report' })
}
// if (this.debugMode) {
// Taro.switchTab({ url: '/pages/residents/report' })
// }
},
onShow() {
console.log('onShow')
onShow(options) {
console.log('onShow', options)
console.log("menuItemDict", menuItemDict)
this.userInfo = Taro.getStorageSync("userInfo");
this.displayUsername = this.userInfo?.username ?? "请登录";
@@ -67,8 +68,21 @@ export default {
url: '/pages/index/login'
})
} else {
// 用户已登录
this.userGroup = getUserGroupByRole(this.userInfo.role);
this.debugObject = { userGroup: this.userGroup };
//判断用户是否是通过扫小程序码进来的
let launchParams = Taro.getCurrentInstance().router.params;
if (launchParams.scene) {
// 扫门禁的小程序码
if (launchParams.scene.split('%')[0] == "guard") {
Taro.getCurrentInstance().router.params.scene = null;
Taro.navigateTo({
url: "/pages/scan/entrance"
})
}
}
}
},
methods: {
@@ -92,6 +106,11 @@ export default {
},
toggleDot(iconName, status = true) {
this.menuItemDict[iconName].addDot = status;
},
magicButton() {
Taro.navigateTo({
url: "/pages/scan/entrance"
})
}
}
}

View File

@@ -28,3 +28,9 @@
color: grey;
font-size: small;
}
#scan-btn {
margin-top: 50px;
padding: 9px 60px;
font-size: initial;
}

View File

@@ -5,6 +5,8 @@
<canvas type="2d" style="width: 250px; height: 250px;" id="myQrcode"></canvas>
<view id="show-text"><text :style="{ color: showTextColor }">{{ showText }}</text></view>
<view id="small-text"><text>下拉可刷新</text></view>
<button id="scan-btn" size="mini" @tap="scan">扫门禁码</button>
</view>
</template>
@@ -12,6 +14,7 @@
import Taro from '@tarojs/taro'
import md5 from 'blueimp-md5'
import drawQrcode from '../../utils/qrcode/index'
import scanQRCode from '../../utils/scanQRCode'
import utils from '../../utils/utils'
import './code.css'
@@ -158,6 +161,9 @@ export default {
updateTime() {
this.time = utils.formatTime(new Date())
console.log("刷新时间")
},
scan() {
scanQRCode(Taro)
}
}
}

View File

@@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '进入社区',
})

View File

@@ -0,0 +1,38 @@
<template>
<view>
您将要进入社区
<textarea maxlength="-1" disabled="true" auto-height="true" style="width: 100%" :value="debugText"></textarea>
</view>
</template>
<script>
import Taro from '@tarojs/taro'
import utils from '../../utils/utils'
export default {
data() {
return {
...Taro.getApp().globalData,
userInfo: null,
scene: null,
debugText: JSON.stringify(Taro.getCurrentInstance().router, null, 4),
}
},
onLaunch(option) {
console.log("onLaunch", option);
},
onShow() {
console.log('onShow')
this.userInfo = Taro.getStorageSync("userInfo")
},
onHide() {
console.log('onHide')
},
methods: {
}
}
</script>

View File

@@ -0,0 +1,25 @@
function scanQRCode(Taro) {
// 只允许从相机扫码
Taro.scanCode({
onlyFromCamera: true,
success(res) {
console.log(res)
if (res.scanType == "WX_CODE" && res.path) {
let searchParams = res.path.split('?');
if (searchParams.length > 1 && searchParams[1].startsWith('scene=guard')) {
Taro.navigateTo({
url: "/pages/scan/entrance"
})
return
}
}
Taro.showToast({
title: "您扫描的不是门禁码",
icon: 'error',
duration: 2000
})
}
})
}
module.exports = scanQRCode;