描述: 扫码开门

This commit is contained in:
SelfRidicule 2024-08-24 17:25:46 +08:00
parent fc232f8e8a
commit d9068e21fb
3 changed files with 71 additions and 17 deletions

View File

@ -3,10 +3,10 @@ import {
} from '../selfRequest';
// 用户信息
// 开门
export function callScanUrl(data) {
return request({
url: '/api/equipment/scanOpenDoor',
url: '/api/equipment/scanChangyangOpenDoor',
method: "get",
data
});

View File

@ -169,6 +169,18 @@ Page({
onLoad(options) {
console.log('onLoad options', options);
let _this = this;
// 获取到二维码原始链接内容
if (options.q) {
let url = decodeURIComponent(options.q)
let urlParam = getUrlParamsObj(url);
// 是否携带其他参数
if (!urlParam.noParam) {
_this.setData({
qrcodeParam: urlParam
})
}
}
},
// 切换tabbar
@ -213,6 +225,11 @@ Page({
bannerList
})
})
// 判断是否开门
if (_this.data.qrcodeParam) {
// 扫码调用地址
_this.scanCallUrl()
}
} else {
app.selfShowMsg(res.msg, '/pages/login/login')
}
@ -240,22 +257,59 @@ Page({
}
},
// 成功通知
showSuccessMsg(msg) {
Notify({
type: 'success',
top: '160rpx',
message: msg
});
// 扫一扫
jumpScan() {
let _this = this;
wx.scanCode({
scanType: 'qrCode',
success(res) {
console.log('success', res)
let url = res.result;
// 判断二维码是否符合规范
if (url.indexOf(app.DOMAIN_NAME_PREFIX) != -1) {
let urlParam = getUrlParamsObj(url);
// 判断是否有设备参数
if (!urlParam.noParam) {
_this.setData({
qrcodeParam: urlParam
})
// 扫码调用地址
_this.scanCallUrl()
} else {
// 危险通知
app.vantNotifyErrTop(Notify, '请预约会议!')
}
} else {
// 危险通知
app.vantNotifyErrTop(Notify, '二维码不正确!')
}
},
fail(res) {
console.log('fail', res)
// 危险通知
app.vantNotifyErrTop(Notify, '扫码失败!')
}
})
},
// 危险通知
showErrMsg(msg) {
Notify({
type: 'danger',
top: '160rpx',
message: msg
});
// 扫码调用地址
scanCallUrl() {
let _this = this;
let qrcodeParam = _this.data.qrcodeParam;
qrcodeParam.userId = wx.getStorageSync('userId')
callScanUrl(qrcodeParam).then(res => {
// 清空扫码数据
_this.setData({
qrcodeParam: null
})
if (res.code == 0) {
// 成功通知
app.vantNotifySuccessTop(Notify, res.msg)
} else {
// 危险通知
app.vantNotifyErrTop(Notify, res.msg)
}
})
},
})

View File

@ -1,7 +1,7 @@
<view class="containerView public">
<view class="topHead">
<!-- <image class="scanImg" src="{{IMG_NAME + '/profile/static/index/scan.png'}}" mode="aspectFill" bind:tap="jumpScan"></image> -->
<image class="scanImg" src="{{IMG_NAME + '/profile/static/index/scan.png'}}" mode="aspectFill" bind:tap="jumpScan"></image>
<view class="title ellipsisFont">{{parkName}}</view>
</view>