mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-11-06 17:09:01 +08:00
refactor: 优化购物车与订单页面逻辑
- 更新购物车页面,增强商品展示与交互体验。 - 调整订单页面的状态反馈与用户操作逻辑,确保信息清晰。 - 改进组件样式与布局,提升整体用户体验。 - 修复多个页面中的样式与功能问题,确保一致性与流畅性。
This commit is contained in:
@@ -35,14 +35,35 @@ export function loadCachedTheme() {
|
||||
}
|
||||
}
|
||||
|
||||
export function applyTabBarStyle(mainColor) {
|
||||
if (!mainColor) return;
|
||||
try {
|
||||
uni.setTabBarStyle({
|
||||
selectedColor: mainColor,
|
||||
});
|
||||
} catch (e) {
|
||||
// 非 tabBar 页面可能报错,忽略
|
||||
const TAB_BAR_ROUTES = [
|
||||
"pages/tabbar/home/index",
|
||||
"pages/tabbar/category/category",
|
||||
"pages/tabbar/cart/cartList",
|
||||
"pages/tabbar/user/my",
|
||||
];
|
||||
|
||||
function normalizeRoute(route = "") {
|
||||
return String(route).replace(/^\//, "").split("?")[0];
|
||||
}
|
||||
|
||||
function currentRoute() {
|
||||
const pages = typeof getCurrentPages === "function" ? getCurrentPages() : [];
|
||||
const page = pages[pages.length - 1];
|
||||
return (page && page.route) || "";
|
||||
}
|
||||
|
||||
export function isTabBarRoute(route) {
|
||||
return TAB_BAR_ROUTES.includes(normalizeRoute(route || currentRoute()));
|
||||
}
|
||||
|
||||
export function applyTabBarStyle(mainColor, route) {
|
||||
if (!mainColor || !isTabBarRoute(route)) return;
|
||||
const task = uni.setTabBarStyle({
|
||||
selectedColor: mainColor,
|
||||
fail() {},
|
||||
});
|
||||
if (task && typeof task.catch === "function") {
|
||||
task.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user