底部导航
|
|
@ -1,31 +1,24 @@
|
|||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
// 检查本地登录凭证是否存在
|
||||
// 检查本地登录凭证,过期则静默清除,不跳转登录页
|
||||
const token = uni.getStorageSync('token')
|
||||
if (!token) {
|
||||
// 未登录,跳转登录页
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return
|
||||
}
|
||||
if (!token) return
|
||||
|
||||
// 简单检查 JWT 是否过期
|
||||
try {
|
||||
const parts = token.split('.')
|
||||
if (parts.length === 3) {
|
||||
const payload = JSON.parse(atob(parts[1]))
|
||||
if (payload.exp && payload.exp * 1000 < Date.now()) {
|
||||
// token 已过期,清除并跳转登录页
|
||||
// token 已过期,静默清除
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// 解析失败,清除无效 token
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userInfo')
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
}
|
||||
},
|
||||
onShow: function() {},
|
||||
|
|
|
|||
|
|
@ -178,26 +178,26 @@
|
|||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "static/tab/home.png",
|
||||
"selectedIconPath": "static/tab/home-active.png"
|
||||
"iconPath": "static/tab/ic_home.png",
|
||||
"selectedIconPath": "static/tab/ic_home_s.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/order-hall/order-hall",
|
||||
"text": "订单大厅",
|
||||
"iconPath": "static/tab/hall.png",
|
||||
"selectedIconPath": "static/tab/hall-active.png"
|
||||
"iconPath": "static/tab/ic_orders.png",
|
||||
"selectedIconPath": "static/tab/ic_orders_s.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/message/message",
|
||||
"text": "消息",
|
||||
"iconPath": "static/tab/message.png",
|
||||
"selectedIconPath": "static/tab/message-active.png"
|
||||
"iconPath": "static/tab/ic_message.png",
|
||||
"selectedIconPath": "static/tab/ic_message_s.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mine/mine",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tab/mine.png",
|
||||
"selectedIconPath": "static/tab/mine-active.png"
|
||||
"iconPath": "static/tab/ic_me.png",
|
||||
"selectedIconPath": "static/tab/ic_me_s.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
BIN
miniapp/static/tab/ic_home.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
miniapp/static/tab/ic_home_s.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
miniapp/static/tab/ic_me.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
miniapp/static/tab/ic_me_s.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
miniapp/static/tab/ic_message.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
BIN
miniapp/static/tab/ic_message_s.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
miniapp/static/tab/ic_orders.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
miniapp/static/tab/ic_orders_s.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
|
|
@ -38,15 +38,11 @@ export const useUserStore = defineStore('user', () => {
|
|||
}
|
||||
|
||||
/**
|
||||
* 检查登录状态,未登录则跳转登录页
|
||||
* 检查登录状态
|
||||
* @returns {boolean} 是否已登录
|
||||
*/
|
||||
function checkLogin() {
|
||||
if (!isLoggedIn.value) {
|
||||
uni.reLaunch({ url: '/pages/login/login' })
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return isLoggedIn.value
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -65,10 +65,10 @@ function request(options) {
|
|||
return
|
||||
}
|
||||
|
||||
// 未登录或 token 过期,跳转登录页
|
||||
// 未登录或 token 过期,静默清除凭证,不自动跳转
|
||||
if (statusCode === 401) {
|
||||
redirectToLogin()
|
||||
reject(new Error('登录已过期,请重新登录'))
|
||||
clearAuth()
|
||||
reject(new Error('未登录或登录已过期'))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -113,8 +113,8 @@ function uploadFile(filePath, url = '/api/upload/image') {
|
|||
header,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 401) {
|
||||
redirectToLogin()
|
||||
reject(new Error('登录已过期,请重新登录'))
|
||||
clearAuth()
|
||||
reject(new Error('未登录或登录已过期'))
|
||||
return
|
||||
}
|
||||
const data = JSON.parse(res.data)
|
||||
|
|
|
|||