2023-03-17 04:55:02 +08:00
|
|
|
// pages/scan/entrance.js
|
2023-04-15 23:47:18 +08:00
|
|
|
|
|
|
|
const gateService = require("../../services/gate")
|
|
|
|
|
2023-03-17 04:55:02 +08:00
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
2023-04-15 23:47:18 +08:00
|
|
|
// 传入参数
|
|
|
|
gateId: "",
|
|
|
|
|
|
|
|
// 接口返回数据
|
|
|
|
gateDetail: "",
|
|
|
|
|
|
|
|
// UI显示用
|
|
|
|
gateName: "未知",
|
|
|
|
open: false,
|
|
|
|
|
|
|
|
currentTime: "",
|
2023-03-17 04:55:02 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
2023-03-20 00:24:19 +08:00
|
|
|
console.log(options)
|
2023-04-15 23:47:18 +08:00
|
|
|
let scene = options.scene
|
|
|
|
if (!scene) {
|
|
|
|
wx.navigateBack()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
scene = decodeURIComponent(scene) // %26 == &
|
|
|
|
if (scene.indexOf('&') == -1) {
|
|
|
|
wx.navigateBack()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let gateId = scene.split('&')[1]
|
2023-03-20 00:24:19 +08:00
|
|
|
this.setData({
|
2023-04-15 23:47:18 +08:00
|
|
|
gateId: gateId,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.loadPageData()
|
2023-03-17 04:55:02 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh() {
|
2023-04-15 23:47:18 +08:00
|
|
|
this.loadPageData()
|
2023-03-17 04:55:02 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage() {
|
|
|
|
|
2023-04-15 23:47:18 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
loadPageData() {
|
|
|
|
let gateId = this.data.gateId;
|
|
|
|
(async () => {
|
|
|
|
let gateDetail = await gateService.getGateDetail(gateId)
|
|
|
|
console.log("gateDetail", gateDetail)
|
|
|
|
this.setData({
|
|
|
|
gateDetail: JSON.stringify(gateDetail),
|
|
|
|
gateName: gateDetail.name,
|
|
|
|
open: gateDetail.open,
|
|
|
|
currentTime: new Date(Date.now() + 8 * 3600 * 1000).toISOString().replace('T', ' ').substring(0, 19)
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
},
|
|
|
|
|
|
|
|
navigateBack: function () {
|
|
|
|
wx.navigateBack()
|
2023-03-17 04:55:02 +08:00
|
|
|
}
|
|
|
|
})
|