首次提交
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
const api = require('../../../services/api')
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
data: { user: null },
|
||||
onShow() {
|
||||
if (!app.globalData.token) { wx.reLaunch({ url: '/pages/login/index' }); return }
|
||||
this.loadProfile()
|
||||
},
|
||||
async loadProfile() {
|
||||
try {
|
||||
const user = await api.get('/api/users/profile')
|
||||
app.globalData.user = user
|
||||
this.setData({ user })
|
||||
} catch(e) {}
|
||||
},
|
||||
goEdit() { wx.navigateTo({ url: '/pages/profile/edit/index' }) },
|
||||
goAchievements() { wx.navigateTo({ url: '/pages/achievements/index' }) },
|
||||
onLogout() {
|
||||
wx.showModal({ title: '确认退出', content: '确定要退出登录吗?', success: (res) => {
|
||||
if (res.confirm) {
|
||||
app.globalData.token = ''; app.globalData.user = null
|
||||
wx.removeStorageSync('token'); wx.removeStorageSync('user')
|
||||
wx.reLaunch({ url: '/pages/login/index' })
|
||||
}
|
||||
}})
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user