小程序:首页按钮功能完成;个人中心、生活物资页框架;体温上报定位权限获取失败提示信息;删除部分无用代码;
This commit is contained in:
@@ -11,6 +11,9 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
debugText: "调试",
|
||||
displayUsername: "",
|
||||
userGroup: "unknown",
|
||||
filterMenuItems: [],
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -19,15 +22,9 @@ Page({
|
||||
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) {
|
||||
let userInfo = wx.getStorageSync("userInfo")
|
||||
if (!userInfo) {
|
||||
console.log("用户未登录")
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/login'
|
||||
@@ -35,13 +32,19 @@ Page({
|
||||
return
|
||||
} else {
|
||||
// 用户已登录
|
||||
this.userGroup = getUserGroupByRole(this.userInfo.role)
|
||||
this.debugObject = {
|
||||
userGroup: this.userGroup
|
||||
}
|
||||
let userGroup = getUserGroupByRole(userInfo.role)
|
||||
this.setData({
|
||||
debugText: JSON.stringify(options, null, 4),
|
||||
userInfo: userInfo,
|
||||
userGroup: userGroup,
|
||||
displayUsername: userInfo?.username ?? "请登录",
|
||||
filterMenuItems: this.getFilterMenuItems(menuItemDict, userGroup)
|
||||
})
|
||||
console.log("menuItemDict", menuItemDict)
|
||||
console.log("filterMenuItems", this.data.filterMenuItems)
|
||||
|
||||
//判断用户是否是通过扫小程序码进来的
|
||||
if (options.scene) {
|
||||
if (options && options.scene) {
|
||||
// 扫门禁的小程序码
|
||||
if (options.scene.split('%')[0] == "guard") {
|
||||
options.scene = null
|
||||
@@ -52,14 +55,16 @@ Page({
|
||||
}
|
||||
}
|
||||
|
||||
// // 开发模式下自动跳转到指定页面,节省开发时间
|
||||
// console.log("app.globalData", app.globalData)
|
||||
// if (app.globalData.debugMode) {
|
||||
// wx.switchTab({
|
||||
// url: '/pages/residents/report'
|
||||
// })
|
||||
// return
|
||||
// }
|
||||
// 开发模式下自动跳转到指定页面,节省开发时间
|
||||
console.log("app.globalData", app.globalData)
|
||||
if (app.globalData.debugMode) {
|
||||
wx.switchTab({
|
||||
// url: '/pages/residents/report'
|
||||
// url: '/pages/person/person'
|
||||
url: '/pages/shop/shop'
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -110,5 +115,62 @@ Page({
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
console.log("index/index onShareAppMessage")
|
||||
},
|
||||
|
||||
|
||||
getFilterMenuItems(menuItemDict, userGroup) {
|
||||
return Object.values(menuItemDict)
|
||||
.filter((item) => item.for.indexOf(userGroup) != -1)
|
||||
},
|
||||
|
||||
|
||||
switchTo(event) {
|
||||
let dataset = event.target.dataset
|
||||
console.log("dataset", dataset)
|
||||
switch (dataset.switchfunc) {
|
||||
case 'switchTab':
|
||||
wx.switchTab({
|
||||
url: dataset.pageurl
|
||||
})
|
||||
break;
|
||||
case 'navigateTo':
|
||||
wx.navigateTo({
|
||||
url: dataset.pageurl
|
||||
})
|
||||
break;
|
||||
case 'redirectTo':
|
||||
wx.redirectTo({
|
||||
url: dataset.pageurl
|
||||
})
|
||||
break;
|
||||
default:
|
||||
console.log("切换页面失败", dataset)
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
goCode() {
|
||||
wx.switchTab({
|
||||
url: '/pages/residents/code'
|
||||
})
|
||||
},
|
||||
|
||||
toggleDot(event, ownerInstance, iconName = 'code', status = undefined) {
|
||||
console.log("menuItemDict[iconName]", menuItemDict[iconName])
|
||||
console.log("this.data.userGroup", this.data.userGroup)
|
||||
if (typeof (status) === 'undefined') {
|
||||
menuItemDict[iconName].addDot = !menuItemDict[iconName].addDot;
|
||||
} else {
|
||||
menuItemDict[iconName].addDot = !!status;
|
||||
}
|
||||
this.setData({
|
||||
filterMenuItems: this.getFilterMenuItems(menuItemDict, this.data.userGroup)
|
||||
})
|
||||
},
|
||||
|
||||
magicButton() {
|
||||
wx.navigateTo({
|
||||
url: "/pages/scan/entrance"
|
||||
})
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user