diff --git a/App.vue b/App.vue index 64d8e34..95bc6b6 100644 --- a/App.vue +++ b/App.vue @@ -67,6 +67,7 @@ // 主题风格 if (uni.getStorageSync('themeStyle')) { this.$store.commit('setThemeStyle', configExternal.loadThemeSync(uni.getStorageSync('themeStyle'))); + this.$store.dispatch('themeColorSet'); } // 插件是否存在 diff --git a/common/js/config-external.js b/common/js/config-external.js index 3fd174e..26cc8f1 100644 --- a/common/js/config-external.js +++ b/common/js/config-external.js @@ -111,6 +111,7 @@ class ConfigExternal { try { // 动态加载主题配置 const themeData = require(`@/common/js/style_color.js`)['default'][theme]; + console.log('sync themeData => ', themeData); this.loadedConfigs[`theme_${theme}`] = themeData; return themeData; } catch (error) { @@ -136,7 +137,8 @@ class ConfigExternal { this.loadPromises[`theme_${theme}`] = new Promise((resolve, reject) => { try { // 动态加载主题配置 - const themeData = require(`@/common/js/style_color.js`)[theme]; + const themeData = require(`@/common/js/style_color.js`)['default'][theme]; + console.log('async themeData => ', themeData); this.loadedConfigs[`theme_${theme}`] = themeData; resolve(themeData); } catch (error) { diff --git a/common/js/golbalConfig.js b/common/js/golbalConfig.js index 8363dbf..27a27d4 100644 --- a/common/js/golbalConfig.js +++ b/common/js/golbalConfig.js @@ -1,21 +1,8 @@ export default { - data() { - return { - // 页面样式,动态设置主色调 - themeColor: '' //''--base-color:#fa5d14;--base-help-color:#ff7e00;' - } - }, onLoad() { }, onShow() { // 刷新多语言 this.$langConfig.refresh(); - let time = setInterval(() => { - let theme = this.themeStyle; - if (theme && theme.main_color) { - this.themeColorSet(); - clearInterval(time); - } - }, 50); }, computed: { // 是否是英文环境 @@ -24,6 +11,9 @@ export default { }, themeStyle() { return this.$store.state.themeStyle; + }, + themeColor() { + return this.$store.state.themeColor; }, // 插件是否存在 addonIsExist() { @@ -111,25 +101,7 @@ export default { } }, methods: { - themeColorSet() { - 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};` - Object.keys(theme).forEach(key => { - let data = theme[key]; - if (typeof (data) == "object") { - Object.keys(data).forEach(k => { - this.themeColor += '--' + k.replace(/_/g, "-") + ':' + data[k] + ';'; - }); - } else if (typeof (key) == "string" && key) { - this.themeColor += '--' + key.replace(/_/g, "-") + ':' + data + ';'; - } - }); - for (let i = 9; i >= 5; i--) { - let color = this.$util.colourBlend(theme.main_color, '#ffffff', (i / 10)); - this.themeColor += `--base-color-light-${i}:${color};`; - } - }, + // 颜色变浅(>0)、变深函数(<0) lightenDarkenColor(color, amount) { diff --git a/common/js/lang.js b/common/js/lang.js index 7d3ff47..bc03c0b 100644 --- a/common/js/lang.js +++ b/common/js/lang.js @@ -72,7 +72,7 @@ export default { //当前页面语言包(同步加载) let route = _this.route; let langPath = processRoutePath(route); - console.log(`当前页面语言包路径: ${langPath}`); + // console.log(`当前页面语言包路径: ${langPath}`); // 加载当前页面语言包 let currentPageLang = loadLangPackSync(locale, langPath); @@ -113,7 +113,7 @@ export default { if (value == undefined || (value == 'title' && field == 'title')) value = ''; // field // 多语言调试,注释后可以关闭控制台输出 - console.log(`字段: ${field}, 值: ${value}`) + // console.log(`字段: ${field}, 值: ${value}`) return value; }, /** diff --git a/lang/zh-cn/goods/detail.js b/lang/zh-cn/goods/detail.js index 24c57da..34efc9b 100644 --- a/lang/zh-cn/goods/detail.js +++ b/lang/zh-cn/goods/detail.js @@ -2,7 +2,7 @@ export const lang = { //title为每个页面的标题 title: '', select: '选择', - details:'商品详情', + details:'资源详情', params: '参数', service: '商品服务', allGoods: '全部商品', diff --git a/pages.json b/pages.json index 19936b6..4e2c1e6 100644 --- a/pages.json +++ b/pages.json @@ -43,7 +43,7 @@ { "path": "detail", "style": { - "navigationBarTitleText": "商品详情" + "navigationBarTitleText": "资源详情" } }, { diff --git a/pages_goods/cart.vue b/pages_goods/cart.vue index 7a8eca5..87ddee9 100644 --- a/pages_goods/cart.vue +++ b/pages_goods/cart.vue @@ -1,6 +1,6 @@