Skip to content

Commit

Permalink
fix: login auth fail
Browse files Browse the repository at this point in the history
  • Loading branch information
yigger committed Apr 21, 2019
1 parent 9bd0ac0 commit 877782a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
20 changes: 11 additions & 9 deletions src/pages/setting.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
async getUserInfo (e) {
if(e.detail.errMsg != 'getUserInfo:ok') return false
const userInfo = e.detail.userInfo
await wxRequest.Put('users/update_user', { user: userInfo })
await wxRequest.Put('users/update_user', { user: userInfo, already_login: true })
this.getCurrentUser()
this.$apply()
},
Expand All @@ -213,21 +213,14 @@
path: '/pages/index',
imageUrl: 'https://xiaoyounger.com/covers/default-11.jpeg',
success: async function (res) {
console.log(res)
tip.toast('感谢支持')
await wxRequest.Post('settings/recommend', { ticket: res['shareTickets'][0] })
}
}
}

async getCurrentUser () {
const cacheData = Session.get('user_load_cache')
if (cacheData) {
this.user = cacheData.user
this.version = cacheData.version
this.$apply()
}

this.loadByCache()
const data = await wxRequest.Get('settings')
Session.set('user_load_cache', data)
if (data.user) {
Expand All @@ -236,6 +229,15 @@
this.version = data.version
this.$apply()
}

loadByCache() {
const cacheData = Session.get('user_load_cache')
if (cacheData) {
this.user = cacheData.user
this.version = cacheData.version
this.$apply()
}
}
}
</script>
<style lang="scss" src="../public/styles/setting.scss"></style>
23 changes: 15 additions & 8 deletions src/pages/settings/user_info.wpy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
</view>
</view>
</view>

<div class="cancel-login-btn" @tap="cancelLoginStatus()">退出登录</div>
</view>
</template>

Expand All @@ -46,14 +48,6 @@
}

methods = {
logout () {
let key = Session.key.alreadyLogin
Session.clear(key)
this.alreadyLogin = false
wx.navigateBack({
delta: 1
})
},
async uploadUserAvatar () {
const choseImages = await wepy.chooseImage({
count: 1,
Expand Down Expand Up @@ -82,6 +76,12 @@
async changeRemind ({detail}) {
this.user.remind = detail.value
await wxRequest.Put('users/update_remind', { remind: detail.value ? 1 : 0 })
},
async cancelLoginStatus() {
await wxRequest.Put('users/cancel_login_status')
wx.navigateBack({
delta: 1
})
}
}

Expand Down Expand Up @@ -118,4 +118,11 @@
color: #ccc;
}
}
.cancel-login-btn {
font-size: 14px;
text-align: center;
margin: 21px;
display: block;
color: blue;
}
</style>

0 comments on commit 877782a

Please sign in to comment.