async onShow() {
if (
typeof this.$root.$mp.page.getTabBar === "function" &&
this.$root.$mp.page.getTabBar()
) {
this.$root.$mp.page.getTabBar().setData({
activeIndex: 2 //对应页面的index
});
}
this.fnobjlist = wx.getStorageSync("userInfo");
// 通过openId 去本地缓存查看是否有用户缓存数据
let openid = await getStorage("openid");
let userInfo = await getStorage(openid);
this.isLogin = wx.getStorageSync("userInfo").token && true;
if (userInfo) {
// 本地有缓存数据
this.userInfo = userInfo;
} else {
// wx.getUserInfo获取用户登录信息
let result = await getUserInfo();
this.userInfo = result.userInfo;
// 通过openId将对应的用户信息缓存到本地
setStorage(this.openid, userInfo);
}
},