// pages/me/me.ts const app = getApp(); Page({ /** * 页面的初始数据 */ data: { loginStatus: true, userName: "未登录", userPic: './../../img/head_pic.png', nvabarData: { showCapsule: 0, //是否显示左上角图标 1表示显示 0表示不显示 title: '', //导航栏 中间的标题 }, islogin: false, }, /** * 生命周期函数--监听页面加载 */ onLoad() { // wx.getStorage("userInfo") const _this = this; wx.getStorage({ key: "userInfo", success(res) { if (!res.data.phone) { return; }; _this.setData({ userName: res.data.nickname || "", userPic: res.data.headUrl || "", islogin: true, }) } }) }, goabout() { wx.navigateTo({ url: './../about/about', }) }, gologin() { // const _this = this; if (this.data.islogin) { // 退出登录 wx.removeStorage({ key: 'userInfo', success(res) { _this.setData({ islogin: false, userName: "未登录", userPic: "./../../img/head_pic.png", }); wx.redirectTo({ url: '/pages/index/index' }); } }); wx.removeStorage({ key: 'token', }) } else { // 登录 wx.navigateTo({ url: './../login/login', }); } }, /** * 生命周期函数--监听页面显示 */ onShow() { this.onLoad(); }, goDownload() { wx.navigateTo({ url: './../download/download', }) } })