1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee
epp/weixin-miniprogram/pages/scan/entrance.js

115 lines
1.8 KiB
JavaScript
Raw Normal View History

// pages/scan/entrance.js
const gateService = require("../../services/gate")
Page({
/**
* 页面的初始数据
*/
data: {
// 传入参数
gateId: "",
// 接口返回数据
gateDetail: "",
// UI显示用
gateName: "未知",
open: false,
currentTime: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options)
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]
this.setData({
gateId: gateId,
});
this.loadPageData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
this.loadPageData()
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
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()
}
})