分享者:小春,原文地址
app.js
var userState = {
isLogin: false,
userInfo: {
nickName: "登录过期",
avatarUrl: "/pages/images/loginLogo.png"
},
identity: "",
status: -2
}
App({
onLaunch: function () {
console.log("--onLaunch------------------------")
}, onHide: function () {
//console.log("--onHide------------------------")
}, onShow() {
console.log("--onShow-----------------------")
wx.checkSession({
success: function () {
//读取本地userState
userState = wx.getStorageSync('StorageUserState') || userState;
}, fail: function () {
}
})
},
getUserState:function(){
return userState
},
setUserState:function(state){