This commit is contained in:
@@ -113,8 +113,11 @@ export default {
|
||||
});
|
||||
|
||||
const data = res.data || {};
|
||||
console.log('[loading] login response:', JSON.stringify(data, null, 2));
|
||||
|
||||
if (data.code === 0 && data.data) {
|
||||
const result = data.data;
|
||||
console.log('[loading] login result:', JSON.stringify(result, null, 2));
|
||||
|
||||
// 清除 URL 中的 code 参数,避免刷新重复处理
|
||||
const url = new URL(window.location.href);
|
||||
@@ -126,11 +129,13 @@ export default {
|
||||
// 已注册 → 缓存 JWT → 跳转首页
|
||||
uni.setStorageSync('token', result.token);
|
||||
uni.setStorageSync('user_info', result.user_info);
|
||||
console.log('[loading] stored user_info:', JSON.stringify(result.user_info, null, 2));
|
||||
this.goToHome();
|
||||
} else {
|
||||
// 未注册 → 缓存临时数据 → 跳转注册页
|
||||
uni.setStorageSync('temp_token', result.temp_token);
|
||||
uni.setStorageSync('auth_info', result.auth_info);
|
||||
console.log('[loading] stored auth_info:', JSON.stringify(result.auth_info, null, 2));
|
||||
this.goToRegister();
|
||||
}
|
||||
} else {
|
||||
@@ -152,6 +157,14 @@ export default {
|
||||
},
|
||||
|
||||
goToRegister() {
|
||||
// 记录扫码时的原始 URL,注册完成后跳回
|
||||
const scanUrl = this.deviceId
|
||||
? `/pages/index/index?device_id=${this.deviceId}`
|
||||
: '';
|
||||
if (scanUrl) {
|
||||
uni.setStorageSync('__scan_redirect_url', scanUrl);
|
||||
}
|
||||
|
||||
const url = this.deviceId
|
||||
? `/pages/register/register?device_id=${this.deviceId}`
|
||||
: '/pages/register/register';
|
||||
|
||||
Reference in New Issue
Block a user