创建新的小程序,进出码,体温上报功能迁移基本完成
This commit is contained in:
111
weixin-miniprogram/pages/index/index.js
Normal file
111
weixin-miniprogram/pages/index/index.js
Normal file
@@ -0,0 +1,111 @@
|
||||
// pages/index/index.js
|
||||
const menuItemDict = require('../../utils/menuList.js')
|
||||
const getUserGroupByRole = require('../../utils/getUserGroupByRole.js')
|
||||
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
debugText: "调试",
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
console.log("index/index onLoad", options)
|
||||
// console.log("wx.getLaunchOptionsSync()", wx.getLaunchOptionsSync())
|
||||
this.setData({
|
||||
debugText: JSON.stringify(options, null, 4),
|
||||
})
|
||||
|
||||
|
||||
console.log("menuItemDict", menuItemDict)
|
||||
this.userInfo = wx.getStorageSync("userInfo")
|
||||
this.displayUsername = this.userInfo?.username ?? "请登录"
|
||||
if (!this.userInfo) {
|
||||
console.log("用户未登录")
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/login'
|
||||
})
|
||||
} else {
|
||||
// 用户已登录
|
||||
this.userGroup = getUserGroupByRole(this.userInfo.role)
|
||||
this.debugObject = {
|
||||
userGroup: this.userGroup
|
||||
}
|
||||
|
||||
//判断用户是否是通过扫小程序码进来的
|
||||
if (options.scene) {
|
||||
// 扫门禁的小程序码
|
||||
if (options.scene.split('%')[0] == "guard") {
|
||||
options.scene = null
|
||||
wx.navigateTo({
|
||||
url: "/pages/scan/entrance"
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 开发模式下自动跳转到指定页面,节省开发时间
|
||||
console.log("app.globalData", app.globalData)
|
||||
if (app.globalData.debugMode) {
|
||||
wx.switchTab({
|
||||
url: '/pages/residents/report'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
console.log("index/index onReady")
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
console.log("index/index onShow")
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
console.log("index/index onHide")
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
console.log("index/index onUnload")
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
console.log("index/index onPullDownRefresh")
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
console.log("index/index onReachBottom")
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
console.log("index/index onShareAppMessage")
|
||||
}
|
||||
})
|
Reference in New Issue
Block a user