最终版
This commit is contained in:
+18
-6
@@ -41,7 +41,8 @@ const captureIdentity = () => {
|
||||
uni.setStorageSync('oauthCode', decodeURIComponent(mCode[1]))
|
||||
console.log('[auth] oauth code recovered len=' + mCode[1].length)
|
||||
}
|
||||
console.log('[auth] captureIdentity orderInUrl=' + !!mOrder + ' codeInUrl=' + !!mCode + ' href=' + location.href)
|
||||
console.log('[auth] captureIdentity orderInUrl=' + !!mOrder + ' codeInUrl=' + !!mCode + ' href=' + location
|
||||
.href)
|
||||
// #endif
|
||||
}
|
||||
|
||||
@@ -65,7 +66,8 @@ const loginByOrder = (order) => {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
code: order
|
||||
code: order,
|
||||
openId: uni.getStorageSync('openId') || ''
|
||||
},
|
||||
success: (res) => {
|
||||
loggingIn = null
|
||||
@@ -90,7 +92,8 @@ const loginByOrder = (order) => {
|
||||
if (d.channel) uni.setStorageSync('channel', d.channel)
|
||||
if (d.userId) uni.setStorageSync('userId', d.userId)
|
||||
// d.isSubscribe=0
|
||||
if (d.isSubscribe !== undefined && d.isSubscribe !== null && d.isSubscribe !== '') {
|
||||
if (d.isSubscribe !== undefined && d.isSubscribe !== null && d.isSubscribe !==
|
||||
'') {
|
||||
uni.setStorageSync('isSubscribe', d.isSubscribe)
|
||||
}
|
||||
uni.setStorageSync('order', order)
|
||||
@@ -202,7 +205,10 @@ const requireLogin = (redirect) => {
|
||||
return Promise.resolve(false)
|
||||
}).catch((err) => {
|
||||
uni.removeStorageSync('oauthCode')
|
||||
uni.showToast({ icon: 'none', title: err.message || '授权失败,请稍后重试' })
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: err.message || '授权失败,请稍后重试'
|
||||
})
|
||||
return Promise.resolve(false)
|
||||
})
|
||||
}
|
||||
@@ -267,7 +273,10 @@ const resolveOrder = (order, freshOrder) => {
|
||||
return Promise.resolve(true)
|
||||
}
|
||||
if (!order) {
|
||||
uni.showToast({ icon: 'none', title: '缺少登录凭证' })
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '缺少登录凭证'
|
||||
})
|
||||
return Promise.resolve(false)
|
||||
}
|
||||
return loginByOrder(order).then(() => {
|
||||
@@ -277,7 +286,10 @@ const resolveOrder = (order, freshOrder) => {
|
||||
}
|
||||
return true
|
||||
}).catch((err) => {
|
||||
uni.showToast({ icon: 'none', title: err.message || '登录失败' })
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: err.message || '登录失败'
|
||||
})
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user