小程序扫门禁码开门流程完成
This commit is contained in:
@@ -16,9 +16,15 @@ Page({
|
||||
|
||||
// UI显示用
|
||||
gateName: "未知",
|
||||
open: false,
|
||||
open: false, // 大门是否开始
|
||||
|
||||
currentTime: "",
|
||||
|
||||
// 是否已经完成开门
|
||||
finishOpen: false,
|
||||
// 用户是否有权限进入
|
||||
isForbidden: false,
|
||||
forbiddenMsg: "",
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -116,6 +122,20 @@ Page({
|
||||
(async () => {
|
||||
let enterGate = await gateService.enterGate(this.data.gateId, "IN")
|
||||
console.log("enterGate", enterGate)
|
||||
if (enterGate === true) {
|
||||
// 开门成功
|
||||
this.setData({
|
||||
finishOpen: true,
|
||||
isForbidden: false,
|
||||
})
|
||||
} else {
|
||||
// 无权进入大门
|
||||
this.setData({
|
||||
finishOpen: true,
|
||||
isForbidden: true,
|
||||
forbiddenMsg: "开门失败",
|
||||
})
|
||||
}
|
||||
})();
|
||||
},
|
||||
|
||||
|
@@ -1,11 +1,12 @@
|
||||
<!--pages/scan/entrance.wxml-->
|
||||
<view style="text-align: center;">
|
||||
<view style="margin-top: 10vh;">
|
||||
<image src="../../image/icon/gate-background.svg" style="height: 40vh;"></image>
|
||||
<image wx:if="{{ !finishOpen }}" src="../../image/icon/gate-background.svg" style="height: 40vh;"></image>
|
||||
<image wx:else src="../../image/icon/{{isForbidden?'error':'done'}}.svg" style="height: 32vh; margin: 20px;"></image>
|
||||
</view>
|
||||
|
||||
<view style="margin-top: 2vh;">
|
||||
<text>您将要进入社区</text>
|
||||
<text wx:if="{{ !finishOpen }}">您将要进入社区</text>
|
||||
</view>
|
||||
|
||||
<view style="margin-top: 10px;">
|
||||
@@ -15,13 +16,21 @@
|
||||
<view style="margin-top: 2vh;">
|
||||
<view wx:if="{{ !open }}">当前大门暂不允许通行</view>
|
||||
<view>当前时间:{{ currentTime }}</view>
|
||||
<text wx:if="{{ finishOpen && !isForbidden }}">大门已为您开启,欢迎回家!</text>
|
||||
<text wx:if="{{ finishOpen && isForbidden }}" style="font-weight: bold;color: red;">
|
||||
{{ forbiddenMsg }}
|
||||
您无权进入该大门,请联系管理员
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view class="btnView">
|
||||
<!--按钮-->
|
||||
<!--按钮-->
|
||||
<view class="btnView" wx:if="{{ !finishOpen }}">
|
||||
<button disabled="{{ !open }}" class="btn" type="primary" bindtap="enterGate">确认进入</button>
|
||||
<button class="btn" type="warn" bindtap="navigateBack">不进入</button>
|
||||
</view>
|
||||
<view class="btnView" wx:else>
|
||||
<button class="btn" type="primary" bindtap="navigateBack">完成</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
|
Reference in New Issue
Block a user