wangfukang 2 days ago
parent
commit
b7c40f390b
  1. 42
      package2/login/login.vue

42
package2/login/login.vue

@ -99,9 +99,7 @@
this.customId = option.customId this.customId = option.customId
} }
if (uni.getStorageSync('hiver_token')) { if (uni.getStorageSync('hiver_token')) {
uni.reLaunch({ this.goAfterLogin(false)
url: '/pages/index/index'
})
} }
}, },
methods: { methods: {
@ -127,7 +125,7 @@
that.loginLoading = false that.loginLoading = false
if (res.code == 200) { if (res.code == 200) {
that.saveLoginResult(res.result) that.saveLoginResult(res.result)
if (!res.result.user || res.result.user.mobile == null || res.result.user.mobile === '') { if (!res.result || !res.result.user || res.result.user.mobile == null || res.result.user.mobile === '') {
that.needPhoneAuth = true that.needPhoneAuth = true
that.tui.toast('绑定手机号,解锁完整半径') that.tui.toast('绑定手机号,解锁完整半径')
} else { } else {
@ -219,18 +217,42 @@
enterHome() { enterHome() {
this.tui.toast('登录成功', 2000, true) this.tui.toast('登录成功', 2000, true)
setTimeout(() => { setTimeout(() => {
this.goAfterLogin(true)
}, 200)
},
goAfterLogin(clearRedirect) {
const pendingPath = this.redirectKey ? uni.getStorageSync(this.redirectKey) : '' const pendingPath = this.redirectKey ? uni.getStorageSync(this.redirectKey) : ''
if (pendingPath) { const targetUrl = pendingPath || '/pages/index/index'
const done = () => {
if (clearRedirect && pendingPath) {
uni.removeStorageSync(this.redirectKey) uni.removeStorageSync(this.redirectKey)
uni.redirectTo({ }
url: pendingPath }
const fallbackHome = () => {
uni.reLaunch({
url: '/pages/index/index',
success: done,
fail: () => {
uni.switchTab({
url: '/pages/index/index',
success: done
})
}
}) })
return
} }
if (targetUrl.indexOf('/pages/index/index') === 0 || targetUrl.indexOf('pages/index/index') === 0) {
uni.reLaunch({ uni.reLaunch({
url: '/pages/index/index' url: targetUrl,
success: done,
fail: fallbackHome
})
return
}
uni.redirectTo({
url: targetUrl,
success: done,
fail: fallbackHome
}) })
}, 200)
}, },
protocol(num) { protocol(num) {
uni.navigateTo({ uni.navigateTo({

Loading…
Cancel
Save