chore: 将wxworkConfig放到全局配置中

This commit is contained in:
2025-12-16 14:41:15 +08:00
parent 23e81114e9
commit 9d12b02463

View File

@@ -1,186 +1,190 @@
export default { export default {
data() { data() {
return { return {
// 页面样式,动态设置主色调 // 页面样式,动态设置主色调
themeColor: '' //''--base-color:#fa5d14;--base-help-color:#ff7e00;' themeColor: '' //''--base-color:#fa5d14;--base-help-color:#ff7e00;'
} }
}, },
onLoad() {}, onLoad() {},
onShow() { onShow() {
// 刷新多语言 // 刷新多语言
this.$langConfig.refresh(); this.$langConfig.refresh();
let time = setInterval(() => { let time = setInterval(() => {
let theme = this.themeStyle; let theme = this.themeStyle;
if (theme && theme.main_color) { if (theme && theme.main_color) {
this.themeColorSet(); this.themeColorSet();
clearInterval(time); clearInterval(time);
} }
}, 50); }, 50);
}, },
computed: { computed: {
themeStyle() { themeStyle() {
return this.$store.state.themeStyle; return this.$store.state.themeStyle;
}, },
// 插件是否存在 // 插件是否存在
addonIsExist() { addonIsExist() {
return this.$store.state.addonIsExist; return this.$store.state.addonIsExist;
}, },
tabBarList() { tabBarList() {
return this.$store.state.tabBarList; return this.$store.state.tabBarList;
}, },
siteInfo() { siteInfo() {
return this.$store.state.siteInfo; return this.$store.state.siteInfo;
}, },
memberInfo() { memberInfo() {
return this.$store.state.memberInfo; return this.$store.state.memberInfo;
}, },
storeToken() { storeToken() {
return this.$store.state.token; return this.$store.state.token;
}, },
bottomNavHidden() { bottomNavHidden() {
return this.$store.state.bottomNavHidden; return this.$store.state.bottomNavHidden;
}, },
globalStoreConfig() { globalStoreConfig() {
return this.$store.state.globalStoreConfig; return this.$store.state.globalStoreConfig;
}, },
globalStoreInfo() { globalStoreInfo() {
return this.$store.state.globalStoreInfo; return this.$store.state.globalStoreInfo;
}, },
// 定位信息 // 定位信息
location() { location() {
return this.$store.state.location; return this.$store.state.location;
}, },
// 定位信息(缓存) // 定位信息(缓存)
locationStorage() { locationStorage() {
let data = uni.getStorageSync('location'); let data = uni.getStorageSync('location');
if (data) { if (data) {
var date = new Date(); var date = new Date();
if (this.mapConfig.wap_valid_time > 0) { if (this.mapConfig.wap_valid_time > 0) {
data.is_expired = (date.getTime() / 1000) > data.valid_time; // 是否过期 data.is_expired = (date.getTime() / 1000) > data.valid_time; // 是否过期
} else { } else {
data.is_expired = false; data.is_expired = false;
} }
} }
return data; return data;
}, },
// 默认总店(定位失败后使用) // 默认总店(定位失败后使用)
defaultStoreInfo() { defaultStoreInfo() {
return this.$store.state.defaultStoreInfo; return this.$store.state.defaultStoreInfo;
}, },
// 组件刷新计数 // 组件刷新计数
componentRefresh() { componentRefresh() {
return this.$store.state.componentRefresh; return this.$store.state.componentRefresh;
}, },
// 客服配置 // 客服配置
servicerConfig() { servicerConfig() {
return this.$store.state.servicerConfig; return this.$store.state.servicerConfig;
}, },
diySeckillInterval() { // 企业微信配置
return this.$store.state.diySeckillInterval; wxworkConfig() {
}, return this.$store.state.wxworkConfig;
tabBarHeight() { },
return this.$store.state.tabBarHeight; diySeckillInterval() {
}, return this.$store.state.diySeckillInterval;
mapConfig() { },
return this.$store.state.mapConfig; tabBarHeight() {
}, return this.$store.state.tabBarHeight;
copyright() { },
let copyright = this.$store.state.copyright; mapConfig() {
// 判断是否授权 return this.$store.state.mapConfig;
if (copyright && !copyright.auth) { },
copyright.logo = ''; copyright() {
copyright.copyright_link = ''; let copyright = this.$store.state.copyright;
} // 判断是否授权
return copyright; if (copyright && !copyright.auth) {
}, copyright.logo = '';
cartList() { copyright.copyright_link = '';
return this.$store.state.cartList; }
}, return copyright;
cartIds() { },
return this.$store.state.cartIds; cartList() {
}, return this.$store.state.cartList;
cartNumber() { },
return this.$store.state.cartNumber; cartIds() {
}, return this.$store.state.cartIds;
cartMoney() { },
return this.$store.state.cartMoney; cartNumber() {
} return this.$store.state.cartNumber;
}, },
methods: { cartMoney() {
themeColorSet() { return this.$store.state.cartMoney;
let theme = this.themeStyle; }
this.themeColor = `--base-color:${theme.main_color};--base-help-color:${theme.aux_color};`; },
if (this.tabBarHeight != '56px') this.themeColor += `--tab-bar-height:${this.tabBarHeight};` methods: {
Object.keys(theme).forEach(key => { themeColorSet() {
let data = theme[key]; let theme = this.themeStyle;
if (typeof(data) == "object") { this.themeColor = `--base-color:${theme.main_color};--base-help-color:${theme.aux_color};`;
Object.keys(data).forEach(k => { if (this.tabBarHeight != '56px') this.themeColor += `--tab-bar-height:${this.tabBarHeight};`
this.themeColor += '--' + k.replace(/_/g, "-") + ':' + data[k] + ';'; Object.keys(theme).forEach(key => {
}); let data = theme[key];
} else if (typeof(key) == "string" && key) { if (typeof(data) == "object") {
this.themeColor += '--' + key.replace(/_/g, "-") + ':' + data + ';'; Object.keys(data).forEach(k => {
} this.themeColor += '--' + k.replace(/_/g, "-") + ':' + data[k] + ';';
}); });
for (let i = 9; i >= 5; i--) { } else if (typeof(key) == "string" && key) {
let color = this.$util.colourBlend(theme.main_color, '#ffffff', (i / 10)); this.themeColor += '--' + key.replace(/_/g, "-") + ':' + data + ';';
this.themeColor += `--base-color-light-${i}:${color};`; }
} });
}, for (let i = 9; i >= 5; i--) {
// 颜色变浅(>0、变深函数<0 let color = this.$util.colourBlend(theme.main_color, '#ffffff', (i / 10));
lightenDarkenColor(color, amount) { this.themeColor += `--base-color-light-${i}:${color};`;
}
var usePound = false; },
// 颜色变浅(>0、变深函数<0
if (color[0] == "#") { lightenDarkenColor(color, amount) {
color = color.slice(1);
usePound = true; var usePound = false;
}
if (color[0] == "#") {
var num = parseInt(color, 16); color = color.slice(1);
usePound = true;
var r = (num >> 16) + amount; }
if (r > 255) r = 255; var num = parseInt(color, 16);
else if (r < 0) r = 0;
var r = (num >> 16) + amount;
var b = ((num >> 8) & 0x00FF) + amount;
if (r > 255) r = 255;
if (b > 255) b = 255; else if (r < 0) r = 0;
else if (b < 0) b = 0;
var b = ((num >> 8) & 0x00FF) + amount;
var g = (num & 0x0000FF) + amount;
if (b > 255) b = 255;
if (g > 255) g = 255; else if (b < 0) b = 0;
else if (g < 0) g = 0;
var g = (num & 0x0000FF) + amount;
return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
if (g > 255) g = 255;
}, else if (g < 0) g = 0;
/**
* 切换门店 return (usePound ? "#" : "") + (g | (b << 8) | (r << 16)).toString(16);
* @param {Object} info 门店信息
* @param {Object} isJump 是否跳转到首页 },
*/ /**
changeStore(info, isJump) { * 切换门店
if (info) { * @param {Object} info 门店信息
this.$store.commit('setGlobalStoreInfo', info); * @param {Object} isJump 是否跳转到首页
} */
let route = this.$util.getCurrRoute(); changeStore(info, isJump) {
if (isJump && route != 'pages/index/index') { if (info) {
uni.setStorageSync('manual_change_store', true); // 手动切换门店 this.$store.commit('setGlobalStoreInfo', info);
this.$store.dispatch('getCartNumber'); //重新获取购物车数据 }
this.$util.redirectTo('/pages/index/index'); let route = this.$util.getCurrRoute();
} if (isJump && route != 'pages/index/index') {
} uni.setStorageSync('manual_change_store', true); // 手动切换门店
}, this.$store.dispatch('getCartNumber'); //重新获取购物车数据
filters: { this.$util.redirectTo('/pages/index/index');
/** }
* 金额格式化输出 }
* @param {Object} money },
*/ filters: {
moneyFormat(money) { /**
if (isNaN(parseFloat(money))) return money; * 金额格式化输出
return parseFloat(money).toFixed(2); * @param {Object} money
} */
} moneyFormat(money) {
if (isNaN(parseFloat(money))) return money;
return parseFloat(money).toFixed(2);
}
}
} }