小程序:首页按钮功能完成;个人中心、生活物资页框架;体温上报定位权限获取失败提示信息;删除部分无用代码;
This commit is contained in:
@@ -1,11 +1,26 @@
|
||||
// pages/person/person.js
|
||||
|
||||
const {
|
||||
user
|
||||
} = require("../../utils/const")
|
||||
|
||||
const app = getApp()
|
||||
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
|
||||
avatarUrl: defaultAvatarUrl,
|
||||
nickName: "请登录",
|
||||
displayUserId: "",
|
||||
menuList: [{
|
||||
id: "logout",
|
||||
color: 'red',
|
||||
title: "退出登录",
|
||||
}]
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -26,7 +41,20 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
let userInfo = wx.getStorageSync("userInfo")
|
||||
if (!userInfo) {
|
||||
console.log("用户未登录")
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/login'
|
||||
})
|
||||
return
|
||||
} else {
|
||||
console.log("userInfo", userInfo)
|
||||
this.setData({
|
||||
nickName: userInfo.realname,
|
||||
displayUserId: "用户名: " + userInfo.username,
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -62,5 +90,37 @@ Page({
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
},
|
||||
|
||||
onChooseAvatar(e) {
|
||||
this.setData({
|
||||
avatarUrl: e.detail.avatarUrl,
|
||||
})
|
||||
},
|
||||
|
||||
onGetUserInfo(e) {
|
||||
let userInfo = JSON.parse(e.detail.rawData)
|
||||
console.log("e", userInfo)
|
||||
this.setData({
|
||||
avatarUrl: userInfo.avatarUrl,
|
||||
|
||||
})
|
||||
},
|
||||
|
||||
menuTap: function (event) {
|
||||
console.log("event.target", event.target)
|
||||
let menuId = event.target.id
|
||||
switch (menuId) {
|
||||
case "logout":
|
||||
wx.clearStorageSync()
|
||||
app.globalData.userInfo = null
|
||||
console.log("userInfo", wx.getStorageSync("userInfo"))
|
||||
wx.redirectTo({
|
||||
url: '/pages/index/login'
|
||||
})
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user