底部导航

This commit is contained in:
18631081161 2026-03-12 18:18:46 +08:00
parent a3177737db
commit 1bc7e4a098
12 changed files with 18 additions and 29 deletions

View File

@ -1,31 +1,24 @@
<script> <script>
export default { export default {
onLaunch: function() { onLaunch: function() {
// //
const token = uni.getStorageSync('token') const token = uni.getStorageSync('token')
if (!token) { if (!token) return
//
uni.reLaunch({ url: '/pages/login/login' })
return
}
// JWT
try { try {
const parts = token.split('.') const parts = token.split('.')
if (parts.length === 3) { if (parts.length === 3) {
const payload = JSON.parse(atob(parts[1])) const payload = JSON.parse(atob(parts[1]))
if (payload.exp && payload.exp * 1000 < Date.now()) { if (payload.exp && payload.exp * 1000 < Date.now()) {
// token // token
uni.removeStorageSync('token') uni.removeStorageSync('token')
uni.removeStorageSync('userInfo') uni.removeStorageSync('userInfo')
uni.reLaunch({ url: '/pages/login/login' })
} }
} }
} catch (e) { } catch (e) {
// token // token
uni.removeStorageSync('token') uni.removeStorageSync('token')
uni.removeStorageSync('userInfo') uni.removeStorageSync('userInfo')
uni.reLaunch({ url: '/pages/login/login' })
} }
}, },
onShow: function() {}, onShow: function() {},

View File

@ -178,26 +178,26 @@
{ {
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"text": "首页", "text": "首页",
"iconPath": "static/tab/home.png", "iconPath": "static/tab/ic_home.png",
"selectedIconPath": "static/tab/home-active.png" "selectedIconPath": "static/tab/ic_home_s.png"
}, },
{ {
"pagePath": "pages/order-hall/order-hall", "pagePath": "pages/order-hall/order-hall",
"text": "订单大厅", "text": "订单大厅",
"iconPath": "static/tab/hall.png", "iconPath": "static/tab/ic_orders.png",
"selectedIconPath": "static/tab/hall-active.png" "selectedIconPath": "static/tab/ic_orders_s.png"
}, },
{ {
"pagePath": "pages/message/message", "pagePath": "pages/message/message",
"text": "消息", "text": "消息",
"iconPath": "static/tab/message.png", "iconPath": "static/tab/ic_message.png",
"selectedIconPath": "static/tab/message-active.png" "selectedIconPath": "static/tab/ic_message_s.png"
}, },
{ {
"pagePath": "pages/mine/mine", "pagePath": "pages/mine/mine",
"text": "我的", "text": "我的",
"iconPath": "static/tab/mine.png", "iconPath": "static/tab/ic_me.png",
"selectedIconPath": "static/tab/mine-active.png" "selectedIconPath": "static/tab/ic_me_s.png"
} }
] ]
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -38,15 +38,11 @@ export const useUserStore = defineStore('user', () => {
} }
/** /**
* 检查登录状态未登录则跳转登录页 * 检查登录状态
* @returns {boolean} 是否已登录 * @returns {boolean} 是否已登录
*/ */
function checkLogin() { function checkLogin() {
if (!isLoggedIn.value) { return isLoggedIn.value
uni.reLaunch({ url: '/pages/login/login' })
return false
}
return true
} }
return { return {

View File

@ -65,10 +65,10 @@ function request(options) {
return return
} }
// 未登录或 token 过期,跳转登录页 // 未登录或 token 过期,静默清除凭证,不自动跳转
if (statusCode === 401) { if (statusCode === 401) {
redirectToLogin() clearAuth()
reject(new Error('登录已过期,请重新登录')) reject(new Error('未登录或登录已过期'))
return return
} }
@ -113,8 +113,8 @@ function uploadFile(filePath, url = '/api/upload/image') {
header, header,
success: (res) => { success: (res) => {
if (res.statusCode === 401) { if (res.statusCode === 401) {
redirectToLogin() clearAuth()
reject(new Error('登录已过期,请重新登录')) reject(new Error('未登录或登录已过期'))
return return
} }
const data = JSON.parse(res.data) const data = JSON.parse(res.data)