主题优化

master
gongfuxiang 2023-09-26 11:01:22 +08:00
parent 598130a90a
commit bc28ab2323
2 changed files with 34 additions and 10 deletions

42
App.vue
View File

@ -92,7 +92,7 @@
// blue #1677ff
// brown #8B4513
// purple #623cec
default_theme: 'yellow',
default_theme: 'purple',
},
/**
* 启动参数处理
@ -1620,10 +1620,12 @@
}
return false;
},
//
currency_symbol() {
return this.get_config('currency_symbol') || this.data.currency_symbol;
},
//
get_location_check(type, object, method) {
// #ifdef MP-WEIXIN || MP-BAIDU || MP-TOUTIAO || MP-QQ
@ -1709,6 +1711,7 @@
});
}
},
//
start_location_update_change(object, method) {
uni.onLocationChange((res) => {
@ -1722,6 +1725,7 @@
}
});
},
//
weixin_privacy_setting() {
if (this.data.is_weixin_privacy_setting == 1) {
@ -1745,6 +1749,7 @@
}, 100);
}
},
//
get_theme_value() {
//
@ -1756,18 +1761,29 @@
// blue #1677ff
// brown #8B4513
// purple #623cec
var default_theme = 'purple';
return uni.getStorageSync('theme') || default_theme;
return uni.getStorageSync('theme') || this.data.default_theme;
},
//
set_theme_value() {
//
set_theme_value(value) {
//
uni.setStorageSync('theme', value);
//
this.require_theme();
},
//
require_theme() {
let theme = this.get_theme_value();
// import `@/common/theme/theme-${mode}.scss`; //import
require(`./common/css/theme/${theme}.css`);
},
//
get_theme_color(obj) {
// is_light false, true
get_theme_color(is_light = false) {
let color_obj = {
//
yellow: '#f6c133', //
red: '#ff0036', //
black: '#333333', //
@ -1777,6 +1793,7 @@
brown: '#8B4513', //
purple: '#623cec', //
//
yellow_light: '#ffebd2', //
red_light: '#ffdbe2', //
black_light: '#dcdcdc', //
@ -1786,9 +1803,13 @@
brown_light: '#eadcd2', //
purple_light: '#d6cbfb', //
};
let theme = obj ? this.get_theme_value() + '_' + obj : this.get_theme_value();
var theme = this.get_theme_value();
if(is_light) {
theme += '_light';
}
return color_obj[theme];
},
//
group_arry(arry, sub_group_length) {
let index = 0;
@ -1802,6 +1823,7 @@
}
return new_arry;
},
// rgba hexValue alpha
hex_rgba(hexValue, alpha) {
const rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
@ -1815,6 +1837,7 @@
b = parseInt(rgb[3], 16);
return `rgba(${r},${g},${b},${alpha})`;
},
//
some_arry(arr, val, params) {
return arr.some(function (arrVal) {
@ -1825,6 +1848,7 @@
}
});
},
// url
updateQueryStringParameter(uri, key, value) {
if (!value) {
@ -1855,8 +1879,8 @@
//
this.globalData.weixin_privacy_setting();
// #endif
//
this.globalData.set_theme_value();
//
this.globalData.require_theme();
},
//
onHide() {

View File

@ -59,7 +59,7 @@ const app = getApp();
import componentNoData from "../../components/no-data/no-data";
import componentBottomLine from "../../components/bottom-line/bottom-line";
const theme_color = app.globalData.get_theme_color();
const theme_color_light = app.globalData.get_theme_color("light");
const theme_color_light = app.globalData.get_theme_color(true);
var common_static_url = app.globalData.get_static_url("common");
export default {