主题底部菜单设置

master
gongfuxiang 2023-09-26 14:54:51 +08:00
parent ef330f7c7a
commit 5ea9d3db88
2 changed files with 78 additions and 35 deletions

103
App.vue
View File

@ -92,7 +92,7 @@
// blue #1677ff // blue #1677ff
// brown #8B4513 // brown #8B4513
// purple #623cec // purple #623cec
default_theme: 'purple', default_theme: 'brown',
}, },
/** /**
* 启动参数处理 * 启动参数处理
@ -1749,6 +1749,37 @@
}, 100); }, 100);
} }
}, },
//
// is_light false, true
get_theme_color(is_light = false) {
let color_obj = {
//
yellow: '#f6c133', //
red: '#ff0036', //
black: '#333333', //
blue: '#1677ff', //
green: '#20a53a', // 绿
orange: '#fe6f04', //
brown: '#8B4513', //
purple: '#623cec', //
//
yellow_light: '#ffebd2', //
red_light: '#ffdbe2', //
black_light: '#dcdcdc', //
blue_light: '#d1e4ff', //
green_light: '#cce8d2', // 绿
orange_light: '#fde4d1', //
brown_light: '#eadcd2', //
purple_light: '#d6cbfb', //
};
var theme = this.get_theme_value();
if (is_light) {
theme += '_light';
}
return color_obj[theme];
},
// //
get_theme_value() { get_theme_value() {
@ -1807,35 +1838,45 @@
} }
}, },
// //
// is_light false, true set_tabbar() {
get_theme_color(is_light = false) { //
let color_obj = {
//
yellow: '#f6c133', //
red: '#ff0036', //
black: '#333333', //
blue: '#1677ff', //
green: '#20a53a', // 绿
orange: '#fe6f04', //
brown: '#8B4513', //
purple: '#623cec', //
//
yellow_light: '#ffebd2', //
red_light: '#ffdbe2', //
black_light: '#dcdcdc', //
blue_light: '#d1e4ff', //
green_light: '#cce8d2', // 绿
orange_light: '#fde4d1', //
brown_light: '#eadcd2', //
purple_light: '#d6cbfb', //
};
var theme = this.get_theme_value(); var theme = this.get_theme_value();
if (is_light) {
theme += '_light'; //
} uni.setTabBarStyle({
return color_obj[theme]; selectedColor: this.get_theme_color(),
});
//
uni.setTabBarItem({
index: 0,
pagePath: 'pages/index/index',
iconPath: 'static/images/common/tabbar/home.png',
selectedIconPath: 'static/images/'+theme+'/tabbar/home.png',
text: '首页'
});
uni.setTabBarItem({
index: 1,
pagePath: 'pages/goods-category/goods-category',
iconPath: 'static/images/common/tabbar/category.png',
selectedIconPath: 'static/images/'+theme+'/tabbar/category.png',
text: '分类'
});
uni.setTabBarItem({
index: 2,
pagePath: 'pages/cart/cart',
iconPath: 'static/images/common/tabbar/cart.png',
selectedIconPath: 'static/images/'+theme+'/tabbar/cart.png',
text: '购物车'
});
uni.setTabBarItem({
index: 3,
pagePath: 'pages/user/user',
iconPath: 'static/images/common/tabbar/user.png',
selectedIconPath: 'static/images/'+theme+'/tabbar/user.png',
text: '我的'
});
}, },
// //
@ -1889,7 +1930,7 @@
} else { } else {
return uri + separator + key + '=' + value; return uri + separator + key + '=' + value;
} }
}, }
}, },
// //
onLaunch(params) {}, onLaunch(params) {},
@ -1909,6 +1950,8 @@
// #endif // #endif
// //
this.globalData.require_theme(); this.globalData.require_theme();
//
this.globalData.set_tabbar();
}, },
// //
onHide() { onHide() {

View File

@ -973,30 +973,30 @@
}, },
"tabBar": { "tabBar": {
"color": "#8a8a8a", "color": "#8a8a8a",
"selectedColor": "#f6c133", "selectedColor": "#8a8a8a",
"backgroundColor": "#fff", "backgroundColor": "#fff",
"list": [{ "list": [{
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"iconPath": "static/images/common/tabbar/home.png", "iconPath": "static/images/common/tabbar/home.png",
"selectedIconPath": "static/images/yellow/tabbar/home.png", "selectedIconPath": "static/images/common/tabbar/home.png",
"text": "首页" "text": "首页"
}, },
{ {
"pagePath": "pages/goods-category/goods-category", "pagePath": "pages/goods-category/goods-category",
"iconPath": "static/images/common/tabbar/category.png", "iconPath": "static/images/common/tabbar/category.png",
"selectedIconPath": "static/images/yellow/tabbar/category.png", "selectedIconPath": "static/images/common/tabbar/category.png",
"text": "分类" "text": "分类"
}, },
{ {
"pagePath": "pages/cart/cart", "pagePath": "pages/cart/cart",
"iconPath": "static/images/common/tabbar/cart.png", "iconPath": "static/images/common/tabbar/cart.png",
"selectedIconPath": "static/images/yellow/tabbar/cart.png", "selectedIconPath": "static/images/common/tabbar/cart.png",
"text": "购物车" "text": "购物车"
}, },
{ {
"pagePath": "pages/user/user", "pagePath": "pages/user/user",
"iconPath": "static/images/common/tabbar/user.png", "iconPath": "static/images/common/tabbar/user.png",
"selectedIconPath": "static/images/yellow/tabbar/user.png", "selectedIconPath": "static/images/common/tabbar/user.png",
"text": "我的" "text": "我的"
} }
] ]