添加微博登录
This commit is contained in:
parent
ea90eac506
commit
8520e5567a
@ -13,6 +13,7 @@ export default {
|
||||
async mounted () {
|
||||
const code = this.$route.query.code
|
||||
const type = this.$route.query.type
|
||||
const state = this.$route.query.state.split('-')
|
||||
|
||||
if (!code) { this.notice = '<p style="color: #999">非法访问,缺少授权参数"code"。<p><br><br> <a href="https://www.wyr.me" target="_blank">返回首页<a>'; this.$finishLoad(); return }
|
||||
|
||||
@ -32,7 +33,29 @@ export default {
|
||||
try {
|
||||
window.localStorage.visitorToken = data.result.token
|
||||
window.localStorage.visitorInfo = JSON.stringify(data.result.visitorInfo)
|
||||
window.location.href = 'https://www.wyr.me/post/' + this.$route.query.state.split('-')[1] + '?hash=comment'
|
||||
window.location.href = 'https://www.wyr.me/post/' + state[1] + '?hash=comment'
|
||||
} catch (_) { }
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (state[0] === 'weibo') {
|
||||
const { data } = await this.$axios.post(`${process.env.baseURL}/visitor/user/weibo`, {
|
||||
code
|
||||
})
|
||||
|
||||
if (data.status !== 1) {
|
||||
this.$toasted.show('微博登录失败,请重试或换用其它登录方式。', {
|
||||
position: 'top-center',
|
||||
duration: 5000
|
||||
})
|
||||
return
|
||||
} else {
|
||||
try {
|
||||
window.localStorage.visitorToken = data.result.token
|
||||
window.localStorage.visitorInfo = JSON.stringify(data.result.visitorInfo)
|
||||
window.location.href = 'https://www.wyr.me/post/' + state[1] + '?hash=comment'
|
||||
} catch (_) { }
|
||||
}
|
||||
|
||||
|
@ -702,6 +702,8 @@ export default {
|
||||
duration: 5000
|
||||
})
|
||||
}
|
||||
} else if (type === 'weibo') {
|
||||
window.location.href = 'https://api.weibo.com/oauth2/authorize?client_id=4159322735&redirect_uri=https://wyr.me/auth&response_type=code&state=weibo-' + this.postID
|
||||
} else {
|
||||
this.$toasted.show('敬请期待', {
|
||||
position: 'top-center',
|
||||
|
Loading…
Reference in New Issue
Block a user