fix(app): 解决页面跳转冲突和登录重定向问题
- 在App.vue中延迟引导页跳转以避免首页未就绪导致的timeout错误 - 添加401跳登录页防重锁机制,防止多个接口同时返回401时的并发冲突 - 移除index.vue中的重复跳转逻辑,统一由App.vue处理首次启动跳转 - 优化record.vue中的品牌选择界面,添加"更多"展开功能和视觉改进 - 改进用量和度数输入框的样式和交互体验
This commit is contained in:
+17
-1
@@ -9,6 +9,22 @@ import UniAppWebSocket from './uni-websocket'
|
||||
// ==========================================
|
||||
export const API_HOST = 'https://dev.wash-painting.cn'
|
||||
|
||||
// ==========================================
|
||||
// 401 跳登录页防重锁:token 失效时多个接口会同时返回 401,
|
||||
// 各自 reLaunch 会并发冲突导致 reLaunch:fail timeout,只放行第一次
|
||||
// ==========================================
|
||||
let authRedirectLock = false
|
||||
function redirectToLogin() {
|
||||
if (authRedirectLock) return
|
||||
authRedirectLock = true
|
||||
setTimeout(() => { authRedirectLock = false }, 3000)
|
||||
const pages = getCurrentPages()
|
||||
const current = pages.length ? pages[pages.length - 1].route : ''
|
||||
// 已在登录页则不重复跳转
|
||||
if (current === 'pages/login/login') return
|
||||
uni.reLaunch({ url: '/pages/login/login', fail: () => {} })
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// HTTP 请求函数(供 SDK 内部调用)
|
||||
// 参考 goodBooth 项目的 fetchsomething
|
||||
@@ -49,7 +65,7 @@ function httpRequest(url, params) {
|
||||
uni.removeStorageSync('refresh_token')
|
||||
uni.removeStorageSync('is_logged_in')
|
||||
if (!silent) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
redirectToLogin()
|
||||
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none', duration: 2500 })
|
||||
}
|
||||
reject({ msg: '登录已过期,请重新登录', code })
|
||||
|
||||
+32
-4
@@ -38,16 +38,44 @@ export const BRANDS = {
|
||||
{ name: '江小白', product: '表达瓶', degree: 40 }
|
||||
],
|
||||
beer: [
|
||||
// 国产主流
|
||||
{ name: '青岛啤酒', product: '经典', degree: 4.3 },
|
||||
{ name: '青岛啤酒', product: '全麦白啤', degree: 4.7 },
|
||||
{ name: '青岛啤酒', product: '黑啤', degree: 5.5 },
|
||||
{ name: '雪花', product: '勇闯天涯', degree: 3.3 },
|
||||
{ name: '雪花', product: '纯生', degree: 3.6 },
|
||||
{ name: '雪花', product: 'superX', degree: 4.0 },
|
||||
{ name: '百威', product: '经典', degree: 5.0 },
|
||||
{ name: '百威', product: '锦兔', degree: 5.0 },
|
||||
{ name: '哈尔滨', product: '冰纯', degree: 4.5 },
|
||||
{ name: '哈尔滨', product: '小麦王', degree: 3.6 },
|
||||
{ name: '燕京', product: 'U8', degree: 2.5 },
|
||||
{ name: '燕京', product: '原浆白啤', degree: 4.8 },
|
||||
{ name: '乌苏', product: '大乌苏', degree: 4.0 },
|
||||
{ name: '珠江', product: '纯生', degree: 3.6 },
|
||||
{ name: '泰山', product: '7天原浆', degree: 4.7 },
|
||||
// 国际品牌
|
||||
{ name: '喜力', product: '星银', degree: 5.0 },
|
||||
{ name: '科罗娜', product: 'Extra', degree: 4.5 },
|
||||
{ name: '嘉士伯', product: '特醇', degree: 5.0 },
|
||||
{ name: '燕京', product: 'U8', degree: 2.5 },
|
||||
{ name: '哈尔滨', product: '冰纯', degree: 4.5 },
|
||||
{ name: '精酿', product: '自选', degree: 6.0 },
|
||||
{ name: '朝日', product: '超爽', degree: 5.0 }
|
||||
{ name: '朝日', product: '超爽', degree: 5.0 },
|
||||
{ name: '麒麟', product: '一番榨', degree: 5.0 },
|
||||
{ name: '三得利', product: '高端麦芽', degree: 5.5 },
|
||||
{ name: '札幌', product: '黑标', degree: 5.0 },
|
||||
{ name: '虎牌', product: '经典', degree: 5.0 },
|
||||
{ name: '生力', product: '清爽', degree: 5.0 },
|
||||
// 德式/白啤
|
||||
{ name: '福佳', product: '白啤', degree: 4.9 },
|
||||
{ name: '1664', product: '白啤', degree: 5.0 },
|
||||
{ name: '柏龙', product: '小麦啤', degree: 5.5 },
|
||||
{ name: '艾丁格', product: '小麦啤', degree: 5.3 },
|
||||
// 精酿
|
||||
{ name: '鹅岛', product: 'IPA', degree: 5.9 },
|
||||
{ name: '熊猫精酿', product: '蜂蜜生姜艾尔', degree: 5.0 },
|
||||
{ name: '京A', product: '工人淡色艾尔', degree: 5.0 },
|
||||
{ name: '拳击猫', product: 'TKO IPA', degree: 6.5 },
|
||||
{ name: '高大师', product: '婴儿肥IPA', degree: 5.6 },
|
||||
{ name: '精酿', product: '自选', degree: 6.0 }
|
||||
],
|
||||
wine: [
|
||||
{ name: '拉菲', product: '传奇', degree: 13 },
|
||||
|
||||
Reference in New Issue
Block a user