//index.js //获取应用实例 const app = getApp() Page({ data: { userInfo: {}, avatar_url: 'http://m.henhaojie.com/images/KX0004.png', nick_name: '点击授权登录' }, onLoad: function () { this.initInfo(); }, initInfo() { var token = wx.getStorageSync('user').token, data = {}, that = this; console.log(token); if (token) { that.getInfo(token) } else { app.login(that, that.getInfo); } }, getInfo(token) { var that = this, token = token || wx.getStorageSync('user').token, data = null; wx.request({ url: app.globalData.HOST + '/user/wx/personalCenter', method: 'POST', data: { token: token }, success: function (res) { if (res.data.errno == '0') { data = res.data.rst that.setData({ userInfo: data, avatar_url: data.user.avatar_url, nick_name: data.user.nick_name}) } else if (res.data.errno == '90001') { } } }); }, goApplication() { var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0'; console.log(user_id); console.log(tel); if (tel != '0' || user_id != '0') { wx.navigateTo({ url: "/pages/application/application" }) } else { wx.navigateTo({ url: "/pages/getPhone/getPhone?from=mine" }) } }, goFeedback: function (e) { var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0'; if (tel != '0' || user_id != '0') { wx.navigateTo({ url: "/pages/feedback/feedback" }) } else { wx.navigateTo({ url: "/pages/getPhone/getPhone?from=mineFeedback" }) } }, onShareAppMessage: function () { return { title: app.globalData.title, imageUrl: app.globalData.img, path: '/pages/index/index', success: function(res) { app.noticeModal('分享成功') }, fail: function(res) { app.noticeModal('您取消了分享') } } } })