chore(test): 测试代码
This commit is contained in:
5
App.vue
5
App.vue
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import auth from 'common/js/auth.js';
|
import auth from 'common/js/auth.js';
|
||||||
import colorList from 'common/js/style_color.js'
|
import { themeConfig } from 'common/js/config-external.js'
|
||||||
|
import configExternal from 'common/js/config-external.js'
|
||||||
import {
|
import {
|
||||||
Weixin
|
Weixin
|
||||||
} from 'common/js/wx-jssdk.js';
|
} from 'common/js/wx-jssdk.js';
|
||||||
@@ -62,7 +63,7 @@
|
|||||||
|
|
||||||
// 主题风格
|
// 主题风格
|
||||||
if (uni.getStorageSync('themeStyle')) {
|
if (uni.getStorageSync('themeStyle')) {
|
||||||
this.$store.commit('setThemeStyle', colorList[uni.getStorageSync('themeStyle')]);
|
this.$store.commit('setThemeStyle', configExternal.loadThemeSync(uni.getStorageSync('themeStyle')));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 插件是否存在
|
// 插件是否存在
|
||||||
|
|||||||
152
common/js/config-external.js
Normal file
152
common/js/config-external.js
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
// 外置配置管理
|
||||||
|
// 用于管理需要外置的配置项,如语言包、主题配置等
|
||||||
|
|
||||||
|
// 语言包配置
|
||||||
|
export const langConfig = {
|
||||||
|
// 语言列表
|
||||||
|
langList: ['zh-cn', 'en-us'],
|
||||||
|
// 默认语言
|
||||||
|
defaultLang: 'zh-cn',
|
||||||
|
// 语言包加载方式:'lazy'(按需加载)或 'preload'(预加载)
|
||||||
|
loadMode: 'lazy'
|
||||||
|
};
|
||||||
|
|
||||||
|
// 主题配置
|
||||||
|
export const themeConfig = {
|
||||||
|
// 主题列表
|
||||||
|
themeList: ['default', 'red', 'green', 'blue'],
|
||||||
|
// 默认主题
|
||||||
|
defaultTheme: 'default'
|
||||||
|
};
|
||||||
|
|
||||||
|
// API配置
|
||||||
|
export const apiConfig = {
|
||||||
|
// API请求超时时间
|
||||||
|
timeout: 30000,
|
||||||
|
// 是否开启重试
|
||||||
|
retry: true,
|
||||||
|
// 重试次数
|
||||||
|
retryCount: 3,
|
||||||
|
// 重试间隔时间(毫秒)
|
||||||
|
retryDelay: 1000
|
||||||
|
};
|
||||||
|
|
||||||
|
// 配置外置管理类
|
||||||
|
class ConfigExternal {
|
||||||
|
constructor() {
|
||||||
|
this.loadedConfigs = {};
|
||||||
|
this.loadPromises = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载语言包
|
||||||
|
* @param {string} lang - 语言类型
|
||||||
|
* @returns {Promise} - 加载结果
|
||||||
|
*/
|
||||||
|
async loadLang(lang = langConfig.defaultLang) {
|
||||||
|
if (this.loadedConfigs[`lang_${lang}`]) {
|
||||||
|
return this.loadedConfigs[`lang_${lang}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.loadPromises[`lang_${lang}`]) {
|
||||||
|
return this.loadPromises[`lang_${lang}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadPromises[`lang_${lang}`] = new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
// 动态加载语言包
|
||||||
|
const langData = require(`@/lang/${lang}/common.js`).lang;
|
||||||
|
this.loadedConfigs[`lang_${lang}`] = langData;
|
||||||
|
resolve(langData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`加载语言包 ${lang} 失败:`, error);
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.loadPromises[`lang_${lang}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载页面语言包
|
||||||
|
* @param {string} lang - 语言类型
|
||||||
|
* @param {string} pagePath - 页面路径
|
||||||
|
* @returns {Promise} - 加载结果
|
||||||
|
*/
|
||||||
|
async loadPageLang(lang = langConfig.defaultLang, pagePath) {
|
||||||
|
const key = `page_${lang}_${pagePath}`;
|
||||||
|
if (this.loadedConfigs[key]) {
|
||||||
|
return this.loadedConfigs[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.loadPromises[key]) {
|
||||||
|
return this.loadPromises[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadPromises[key] = new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
// 动态加载页面语言包
|
||||||
|
const pageLangData = require(`@/lang/${lang}/${pagePath}.js`).lang;
|
||||||
|
this.loadedConfigs[key] = pageLangData;
|
||||||
|
resolve(pageLangData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`加载页面语言包 ${lang}/${pagePath} 失败:`, error);
|
||||||
|
resolve({});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.loadPromises[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载主题配置(同步方式)
|
||||||
|
* @param {string} theme - 主题名称
|
||||||
|
* @returns {object} - 主题配置
|
||||||
|
*/
|
||||||
|
loadThemeSync(theme = themeConfig.defaultTheme) {
|
||||||
|
if (this.loadedConfigs[`theme_${theme}`]) {
|
||||||
|
return this.loadedConfigs[`theme_${theme}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 动态加载主题配置
|
||||||
|
const themeData = require(`@/common/js/style_color.js`)[theme];
|
||||||
|
this.loadedConfigs[`theme_${theme}`] = themeData;
|
||||||
|
return themeData;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`加载主题 ${theme} 失败:`, error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载主题配置(异步方式)
|
||||||
|
* @param {string} theme - 主题名称
|
||||||
|
* @returns {Promise} - 加载结果
|
||||||
|
*/
|
||||||
|
async loadTheme(theme = themeConfig.defaultTheme) {
|
||||||
|
if (this.loadedConfigs[`theme_${theme}`]) {
|
||||||
|
return this.loadedConfigs[`theme_${theme}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.loadPromises[`theme_${theme}`]) {
|
||||||
|
return this.loadPromises[`theme_${theme}`];
|
||||||
|
}
|
||||||
|
|
||||||
|
this.loadPromises[`theme_${theme}`] = new Promise((resolve, reject) => {
|
||||||
|
try {
|
||||||
|
// 动态加载主题配置
|
||||||
|
const themeData = require(`@/common/js/style_color.js`)[theme];
|
||||||
|
this.loadedConfigs[`theme_${theme}`] = themeData;
|
||||||
|
resolve(themeData);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`加载主题 ${theme} 失败:`, error);
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return this.loadPromises[`theme_${theme}`];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new ConfigExternal();
|
||||||
@@ -1,9 +1,61 @@
|
|||||||
const langList = ['zh-cn', 'en-us'];
|
import { langConfig } from './config-external.js';
|
||||||
|
|
||||||
var locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
|
var locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
|
||||||
|
// 缓存已加载的语言包
|
||||||
|
var loadedLangPacks = {};
|
||||||
|
|
||||||
|
// 处理页面目录映射
|
||||||
|
function processRoutePath(route) {
|
||||||
|
let routeParts = route.split("/");
|
||||||
|
|
||||||
|
// ---- 处理页面目录映射 <begin> 分包造成的,需要根据实际目录结构进行映射----
|
||||||
|
// 先处理特殊的分包路径
|
||||||
|
if (routeParts[0] === 'pages_tool') {
|
||||||
|
// pages_tool 分包下的页面,直接使用子目录作为语言包路径
|
||||||
|
routeParts = [routeParts[1], ...routeParts.slice(2)];
|
||||||
|
} else if (routeParts[0] === 'pages_goods') {
|
||||||
|
// pages_goods 分包映射到 goods 目录
|
||||||
|
routeParts[0] = 'goods';
|
||||||
|
} else if (routeParts[0] === 'pages_member') {
|
||||||
|
// pages_member 分包映射到 member 目录
|
||||||
|
routeParts[0] = 'member';
|
||||||
|
} else if (routeParts[0] === 'pages_order') {
|
||||||
|
// pages_order 分包映射到 order 目录
|
||||||
|
routeParts[0] = 'order';
|
||||||
|
} else if (routeParts[0] === 'pages_promotion') {
|
||||||
|
// pages_promotion 分包特殊处理
|
||||||
|
const promotionModules = ['point', 'fenxiao', 'merch'];
|
||||||
|
if (routeParts[1] && promotionModules.includes(routeParts[1])) {
|
||||||
|
routeParts = [routeParts[1], ...routeParts.slice(2)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ---- 处理页面目录映射 <end>----
|
||||||
|
|
||||||
|
// 去掉pages目录,只保留子目录
|
||||||
|
if (routeParts[0] === 'pages') {
|
||||||
|
routeParts = routeParts.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return routeParts.join("/");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载语言包(同步方式)
|
||||||
|
function loadLangPackSync(lang, path) {
|
||||||
|
try {
|
||||||
|
if (loadedLangPacks[`${lang}_${path}`]) {
|
||||||
|
return loadedLangPacks[`${lang}_${path}`];
|
||||||
|
}
|
||||||
|
const langData = require(`@/lang/${lang}/${path}.js`).lang;
|
||||||
|
loadedLangPacks[`${lang}_${path}`] = langData;
|
||||||
|
return langData;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`加载语言包 ${lang}/${path} 失败:`, error);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
langList: ['zh-cn', 'en-us'],
|
langList: langConfig.langList,
|
||||||
/**
|
/**
|
||||||
* * 解析多语言
|
* * 解析多语言
|
||||||
* @param {Object} field
|
* @param {Object} field
|
||||||
@@ -13,51 +65,25 @@ export default {
|
|||||||
if (!_this) return;
|
if (!_this) return;
|
||||||
|
|
||||||
var value = '';
|
var value = '';
|
||||||
let newRoute;
|
|
||||||
try {
|
try {
|
||||||
//公共语言包
|
//公共语言包(同步加载)
|
||||||
var lang = require('@/lang/' + locale + '/common.js').lang;
|
var lang = loadLangPackSync(locale, 'common');
|
||||||
|
|
||||||
//当前页面语言包
|
//当前页面语言包(同步加载)
|
||||||
let route = _this.route;
|
let route = _this.route;
|
||||||
let routeParts = route.split("/");
|
let langPath = processRoutePath(route);
|
||||||
|
|
||||||
console.log(`当前路由: ${route}`)
|
|
||||||
|
|
||||||
// ---- 处理页面目录映射 <begin> 分包造成的,需要根据实际目录结构进行映射----
|
// 加载当前页面语言包
|
||||||
if (routeParts[0] === 'pages_goods') routeParts[0] = 'goods';
|
let currentPageLang = loadLangPackSync(locale, langPath);
|
||||||
if (routeParts[0] === 'pages_member') routeParts[0] = 'member';
|
|
||||||
if (routeParts[0] === 'pages_order') routeParts[0] = 'order';
|
|
||||||
|
|
||||||
if (routeParts[0] === 'pages_promotion') {
|
|
||||||
const promotionModules = ['point', 'fenxiao', 'merch'];
|
|
||||||
if (promotionModules.includes(routeParts[1])) {
|
|
||||||
routeParts = [routeParts[1], ...routeParts.slice(2)];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (routeParts[0] === 'pages_tool') {
|
// 合并语言包
|
||||||
routeParts = [routeParts[1], ...routeParts.slice(2)];
|
let mergedLang = { ...lang, ...currentPageLang };
|
||||||
}
|
|
||||||
// ---- 处理页面目录映射 <end>----
|
|
||||||
|
|
||||||
// 去掉pages目录,只保留子目录
|
|
||||||
if (routeParts[0] === 'pages') {
|
|
||||||
routeParts = routeParts.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let langPath = routeParts.join("/");
|
|
||||||
console.log(`当前页面语言文件路径: ${'@/lang/' + locale + '/' + langPath + '.js'}`)
|
|
||||||
let currentPageLang = require('@/lang/' + locale + '/' + langPath + '.js').lang;
|
|
||||||
|
|
||||||
for (let f in currentPageLang) {
|
|
||||||
lang[f] = currentPageLang[f];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// 解析字段
|
||||||
var arr = field.split(".");
|
var arr = field.split(".");
|
||||||
if (arr.length > 1) {
|
if (arr.length > 1) {
|
||||||
// 处理嵌套属性,如 common.currencySymbol
|
// 处理嵌套属性,如 common.currencySymbol
|
||||||
let temp = lang;
|
let temp = mergedLang;
|
||||||
let found = true;
|
let found = true;
|
||||||
for (let key of arr) {
|
for (let key of arr) {
|
||||||
if (temp[key] !== undefined) {
|
if (temp[key] !== undefined) {
|
||||||
@@ -69,16 +95,12 @@ export default {
|
|||||||
}
|
}
|
||||||
value = found ? temp : field;
|
value = found ? temp : field;
|
||||||
} else {
|
} else {
|
||||||
value = lang[field] !== undefined ? lang[field] : field;
|
value = mergedLang[field] !== undefined ? mergedLang[field] : field;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (field.indexOf("common.") != -1 || field.indexOf("tabBar.") != -1) {
|
console.error('解析语言包失败:', e);
|
||||||
value = lang[field];
|
value = field;
|
||||||
} else {
|
|
||||||
value = field;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arguments.length > 1) {
|
if (arguments.length > 1) {
|
||||||
@@ -98,13 +120,16 @@ export default {
|
|||||||
* @param {String} value 语言值
|
* @param {String} value 语言值
|
||||||
* @param {String} url 切换后跳转的页面url
|
* @param {String} url 切换后跳转的页面url
|
||||||
*/
|
*/
|
||||||
change(value, url = '/pages/member/index') {
|
change(value, url = '/pages_tool/member/index') {
|
||||||
let _this = getCurrentPages()[getCurrentPages().length - 1];
|
let _this = getCurrentPages()[getCurrentPages().length - 1];
|
||||||
if (!_this) return;
|
if (!_this) return;
|
||||||
|
|
||||||
uni.setStorageSync("lang", value);
|
uni.setStorageSync("lang", value);
|
||||||
locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
|
locale = uni.getStorageSync('lang') || "zh-cn"; //设置语言
|
||||||
|
|
||||||
|
// 清空已加载的语言包缓存
|
||||||
|
loadedLangPacks = {};
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
@@ -153,15 +178,16 @@ export default {
|
|||||||
var list = [];
|
var list = [];
|
||||||
try {
|
try {
|
||||||
//公共语言包
|
//公共语言包
|
||||||
for (var i = 0; i < langList.length; i++) {
|
for (var i = 0; i < langConfig.langList.length; i++) {
|
||||||
let item = require('../../lang/' + langList[i] + '/common.js').lang;
|
let langType = langConfig.langList[i];
|
||||||
|
let item = loadLangPackSync(langType, 'common');
|
||||||
list.push({
|
list.push({
|
||||||
name: item.common.name,
|
name: item.common ? item.common.name : langType,
|
||||||
value: langList[i]
|
value: langType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// "没有找到语言包:", '../../lang/' + locale + '/common.js'
|
console.error('获取语言包列表失败:', e);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,55 @@ export default {
|
|||||||
*/
|
*/
|
||||||
redirectTo(to, param, mode) {
|
redirectTo(to, param, mode) {
|
||||||
let url = to;
|
let url = to;
|
||||||
let tabbarList = ['/pages/index/index', '/pages/goods/category', '/pages/vr/index', '/pages/contact/contact', '/pages/member/index'];
|
|
||||||
|
// 当前最新的tabBar.list (参见pages.json 中的tabBar.list 配置)
|
||||||
|
const systemTabBarList = [
|
||||||
|
'/pages/index/index',
|
||||||
|
'/pages_goods/category',
|
||||||
|
'/pages_tool/contact/contact',
|
||||||
|
'/pages_tool/member/index',
|
||||||
|
'/pages_tool/vr/index'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 特别注意:
|
||||||
|
* 由于老版本或者后台系统服务未同步更新可以作为tabBarList的最新分包路径。历史遗留问题,需要与当前最新分包机制版本保持一致。
|
||||||
|
* 系统当前的支持tarbarList(包含动态tabBar),注意这是实际分包后的路径
|
||||||
|
* 根据匹配映射关系,修改url为实际分包后的路径
|
||||||
|
*/
|
||||||
|
// 定义前缀映射表
|
||||||
|
const urlPrefixMap = {
|
||||||
|
'/pages/goods/': '/pages_goods/',
|
||||||
|
'/pages/contact/': '/pages_tool/contact/',
|
||||||
|
'/pages/member/': '/pages_tool/member/',
|
||||||
|
'/pages/vr': '/pages_tool/vr/'
|
||||||
|
};
|
||||||
|
|
||||||
|
// 构建正则表达式
|
||||||
|
const regex = new RegExp(
|
||||||
|
Object.keys(urlPrefixMap).map(key =>
|
||||||
|
key.replace(/\//g, '\\/').replace(/\*/g, '.*')
|
||||||
|
).join('|'),
|
||||||
|
'g'
|
||||||
|
);
|
||||||
|
|
||||||
|
// 替换函数
|
||||||
|
function replacePrefix(str) {
|
||||||
|
return str.replace(regex, match => {
|
||||||
|
for (const [oldPrefix, newPrefix] of Object.entries(urlPrefixMap)) {
|
||||||
|
if (match.startsWith(oldPrefix)) {
|
||||||
|
return match.replace(oldPrefix, newPrefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return match; // 默认返回原匹配
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('redirectTo', to, param, mode);
|
||||||
|
// 替换url中的前缀
|
||||||
|
url = replacePrefix(url);
|
||||||
|
console.log('replacePrefix', url);
|
||||||
|
|
||||||
if (param != undefined) {
|
if (param != undefined) {
|
||||||
Object.keys(param).forEach(function (key) {
|
Object.keys(param).forEach(function (key) {
|
||||||
if (url.indexOf('?') != -1) {
|
if (url.indexOf('?') != -1) {
|
||||||
@@ -24,14 +72,19 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for (let i = 0; i < tabbarList.length; i++) {
|
|
||||||
if (url.indexOf(tabbarList[i]) == 0) {
|
// 针对tabBar.list中的路径,直接切换tabBar
|
||||||
|
for (let i = 0; i < systemTabBarList.length; i++) {
|
||||||
|
const tabBarUrl = systemTabBarList[i];
|
||||||
|
if (url.indexOf(tabBarUrl) == 0) {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url
|
url
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 如果url不包含tabBarList中的路径,根据mode判断跳转方式
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 'tabbar':
|
case 'tabbar':
|
||||||
// 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。
|
// 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面。
|
||||||
@@ -57,6 +110,8 @@ export default {
|
|||||||
url
|
url
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('无任何处理', url);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 图片路径转换
|
* 图片路径转换
|
||||||
@@ -64,8 +119,8 @@ export default {
|
|||||||
* @param {Object} params 参数,针对商品、相册里面的图片区分大中小,size: big、mid、small
|
* @param {Object} params 参数,针对商品、相册里面的图片区分大中小,size: big、mid、small
|
||||||
*/
|
*/
|
||||||
img(img_path, params) {
|
img(img_path, params) {
|
||||||
|
|
||||||
|
|
||||||
var path = "";
|
var path = "";
|
||||||
if (img_path != undefined && img_path != "") {
|
if (img_path != undefined && img_path != "") {
|
||||||
if (img_path.split(',').length > 1) {
|
if (img_path.split(',').length > 1) {
|
||||||
@@ -81,7 +136,7 @@ export default {
|
|||||||
// if(img_path.indexOf('attachment') == -1){
|
// if(img_path.indexOf('attachment') == -1){
|
||||||
// img_path = arr.join(".");
|
// img_path = arr.join(".");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
if (img_path.indexOf("http://") == -1 && img_path.indexOf("https://") == -1) {
|
if (img_path.indexOf("http://") == -1 && img_path.indexOf("https://") == -1) {
|
||||||
path = Config.imgDomain + "/" + img_path;
|
path = Config.imgDomain + "/" + img_path;
|
||||||
@@ -90,7 +145,7 @@ export default {
|
|||||||
path = img_path;
|
path = img_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// path += '?t=' + parseInt(new Date().getTime() / 1000);
|
// path += '?t=' + parseInt(new Date().getTime() / 1000);
|
||||||
return path;
|
return path;
|
||||||
},
|
},
|
||||||
@@ -385,14 +440,14 @@ export default {
|
|||||||
*/
|
*/
|
||||||
isWeChatMiniProgram() {
|
isWeChatMiniProgram() {
|
||||||
const userAgent = navigator.userAgent.toLowerCase();
|
const userAgent = navigator.userAgent.toLowerCase();
|
||||||
|
|
||||||
// 微信小程序的web-view User-Agent会包含以下特征之一
|
// 微信小程序的web-view User-Agent会包含以下特征之一
|
||||||
const miniProgramIndicators = [
|
const miniProgramIndicators = [
|
||||||
'miniprogram', // 普通微信小程序
|
'miniprogram', // 普通微信小程序
|
||||||
'wxwork', // 企业微信小程序
|
'wxwork', // 企业微信小程序
|
||||||
'micromessenger/[0-9]+\.[0-9]+\.[0-9]+ nettype/wifi wxwebviewtype/1'
|
'micromessenger/[0-9]+\.[0-9]+\.[0-9]+ nettype/wifi wxwebviewtype/1'
|
||||||
];
|
];
|
||||||
|
|
||||||
return miniProgramIndicators.some(indicator => {
|
return miniProgramIndicators.some(indicator => {
|
||||||
if (typeof indicator === 'string' && indicator.includes('/')) {
|
if (typeof indicator === 'string' && indicator.includes('/')) {
|
||||||
// 正则表达式匹配
|
// 正则表达式匹配
|
||||||
@@ -466,11 +521,11 @@ export default {
|
|||||||
* @param {Object} link
|
* @param {Object} link
|
||||||
*/
|
*/
|
||||||
diyRedirectTo(link) {
|
diyRedirectTo(link) {
|
||||||
|
|
||||||
//if (link == null || Object.keys(link).length == 1) return;
|
//if (link == null || Object.keys(link).length == 1) return;
|
||||||
|
|
||||||
// 外部链接
|
// 外部链接
|
||||||
if (link.wap_url && link.wap_url.indexOf('http') != -1 || link.wap_url && link.wap_url.indexOf('http') != -1) {
|
if (link.wap_url && link.wap_url.indexOf('http') != -1) {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
window.location.href = link.wap_url;
|
window.location.href = link.wap_url;
|
||||||
// #endif
|
// #endif
|
||||||
@@ -786,7 +841,7 @@ export default {
|
|||||||
if (!path) {
|
if (!path) {
|
||||||
let route = this.getCurrentRoute();
|
let route = this.getCurrentRoute();
|
||||||
path = route.path;
|
path = route.path;
|
||||||
if (path == '/pages/member/index') {
|
if (path == '/pages_tool/member/index') {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve({})
|
resolve({})
|
||||||
});
|
});
|
||||||
@@ -951,11 +1006,11 @@ export default {
|
|||||||
var points_E = [];
|
var points_E = [];
|
||||||
const DIST_AB = Math.sqrt(Math.pow(points[1]['x'] - points[0]['x'], 2) + Math.pow(points[1]['y'] - points[0][
|
const DIST_AB = Math.sqrt(Math.pow(points[1]['x'] - points[0]['x'], 2) + Math.pow(points[1]['y'] - points[0][
|
||||||
'y'
|
'y'
|
||||||
], 2));
|
], 2));
|
||||||
// 邻控制BC点间距
|
// 邻控制BC点间距
|
||||||
const DIST_BC = Math.sqrt(Math.pow(points[2]['x'] - points[1]['x'], 2) + Math.pow(points[2]['y'] - points[1][
|
const DIST_BC = Math.sqrt(Math.pow(points[2]['x'] - points[1]['x'], 2) + Math.pow(points[2]['y'] - points[1][
|
||||||
'y'
|
'y'
|
||||||
], 2));
|
], 2));
|
||||||
// D每次在AB方向上移动的距离
|
// D每次在AB方向上移动的距离
|
||||||
if (points[0]['x'] > points[2]['x']) {
|
if (points[0]['x'] > points[2]['x']) {
|
||||||
var EACH_MOVE_AD = -(DIST_AB / times);
|
var EACH_MOVE_AD = -(DIST_AB / times);
|
||||||
|
|||||||
@@ -229,7 +229,7 @@
|
|||||||
<text class="limit" :style="{ color: value.limitColor }" v-else>无门槛使用</text>
|
<text class="limit" :style="{ color: value.limitColor }" v-else>无门槛使用</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<div v-if="computedCouponList.length <= 2" @click="$util.redirectTo('/pages/goods/category')"
|
<div v-if="computedCouponList.length <= 2" @click="$util.redirectTo('/pages_goods/category')"
|
||||||
class="coupon coupon-null" :style="{
|
class="coupon coupon-null" :style="{
|
||||||
color: value.moneyColor,
|
color: value.moneyColor,
|
||||||
backgroundImage: 'url(' + $util.img('public/uniapp/coupon/style6-bg-2.png') + ')',
|
backgroundImage: 'url(' + $util.img('public/uniapp/coupon/style6-bg-2.png') + ')',
|
||||||
|
|||||||
4
lang/en-us/vr/index.js
Normal file
4
lang/en-us/vr/index.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const lang = {
|
||||||
|
//title为每个页面的标题
|
||||||
|
title: 'VR'
|
||||||
|
}
|
||||||
4
lang/zh-cn/vr/index.js
Normal file
4
lang/zh-cn/vr/index.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const lang = {
|
||||||
|
//title为每个页面的标题
|
||||||
|
title: 'VR'
|
||||||
|
}
|
||||||
59
pages.json
59
pages.json
@@ -7,35 +7,25 @@
|
|||||||
// "navigationStyle": "custom",
|
// "navigationStyle": "custom",
|
||||||
"enablePullDownRefresh": true
|
"enablePullDownRefresh": true
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "pages/contact/contact",
|
|
||||||
"style": {
|
|
||||||
"navigationBarTitleText": "电子名片"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//******************商品模块(11)******************
|
|
||||||
{
|
|
||||||
"path": "pages/goods/category",
|
|
||||||
"style": {
|
|
||||||
"disableScroll": true,
|
|
||||||
"navigationBarTitleText": "商品分类",
|
|
||||||
"enablePullDownRefresh": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//******************会员模块(20)******************
|
|
||||||
{
|
|
||||||
"path": "pages/member/index",
|
|
||||||
"style": {
|
|
||||||
"enablePullDownRefresh": true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"subPackages": [
|
"subPackages": [
|
||||||
|
{
|
||||||
|
"root": "components-diy",
|
||||||
|
"pages": []
|
||||||
|
},
|
||||||
{
|
{
|
||||||
//******************商品模块分包******************
|
//******************商品模块分包******************
|
||||||
"root": "pages_goods",
|
"root": "pages_goods",
|
||||||
"pages": [
|
"pages": [
|
||||||
|
{
|
||||||
|
"path": "category",
|
||||||
|
"style": {
|
||||||
|
"disableScroll": true,
|
||||||
|
"navigationBarTitleText": "商品分类",
|
||||||
|
"enablePullDownRefresh": true
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "cart",
|
"path": "cart",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -332,6 +322,12 @@
|
|||||||
"navigationBarTitleText": ""
|
"navigationBarTitleText": ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "contact/contact",
|
||||||
|
"style": {
|
||||||
|
"navigationBarTitleText": "电子名片"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "webview/webview",
|
"path": "webview/webview",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -350,6 +346,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
//******************会员模块(20)******************
|
//******************会员模块(20)******************
|
||||||
|
{
|
||||||
|
"path": "member/index",
|
||||||
|
"style": {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
// #endif
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "member/modify_face",
|
"path": "member/modify_face",
|
||||||
"style": {
|
"style": {
|
||||||
@@ -928,21 +932,24 @@
|
|||||||
"text": ""
|
"text": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/goods/category",
|
"pagePath": "pages_goods/category",
|
||||||
"text": ""
|
"text": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/contact/contact",
|
"pagePath": "pages_tool/contact/contact",
|
||||||
"text": ""
|
"text": ""
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"pagePath": "pages/member/index",
|
"pagePath": "pages_tool/member/index",
|
||||||
"text": ""
|
"text": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"easycom": {
|
"easycom": {
|
||||||
"diy-*(\\W.*)": "@/components/diy-components/diy$1.vue"
|
"autoscan": true,
|
||||||
|
"custom": {
|
||||||
|
"diy-*(\\W.*)": "@/components-diy/diy$1.vue"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"preloadRule": {
|
"preloadRule": {
|
||||||
"pages/index/index": {
|
"pages/index/index": {
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
toLogin() {
|
toLogin() {
|
||||||
this.$refs.login.open('/pages/goods/category')
|
this.$refs.login.open('/pages_goods/category')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPullDownRefresh() {
|
onPullDownRefresh() {
|
||||||
@@ -216,7 +216,7 @@
|
|||||||
|
|
||||||
},
|
},
|
||||||
toLogin() {
|
toLogin() {
|
||||||
this.$refs.login.open('/pages/goods/category')
|
this.$refs.login.open('/pages_goods/category')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// onPullDownRefresh() {
|
// onPullDownRefresh() {
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import Vuex from 'vuex'
|
|||||||
Vue.use(Vuex)
|
Vue.use(Vuex)
|
||||||
|
|
||||||
import Http from '../common/js/http.js'
|
import Http from '../common/js/http.js'
|
||||||
import colorList from '../common/js/style_color.js'
|
import { themeConfig } from '../common/js/config-external.js'
|
||||||
|
import configExternal from '../common/js/config-external.js'
|
||||||
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
state: {
|
state: {
|
||||||
@@ -251,7 +252,7 @@ const store = new Vuex.Store({
|
|||||||
success: res => {
|
success: res => {
|
||||||
var data = res.data;
|
var data = res.data;
|
||||||
if (data) {
|
if (data) {
|
||||||
this.commit('setThemeStyle', colorList[data.style_theme.name]);
|
this.commit('setThemeStyle', configExternal.loadThemeSync(data.style_theme.name));
|
||||||
|
|
||||||
// 底部导航
|
// 底部导航
|
||||||
this.commit('setTabBarList', data.diy_bottom_nav);
|
this.commit('setTabBarList', data.diy_bottom_nav);
|
||||||
|
|||||||
45
vue.config.js
Normal file
45
vue.config.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
module.exports = {
|
||||||
|
productionSourceMap: false,
|
||||||
|
configureWebpack: config => {
|
||||||
|
if (process.env.NODE_ENV === 'production') {
|
||||||
|
config.optimization.minimizer[0].options.terserOptions = {
|
||||||
|
compress: {
|
||||||
|
drop_console: true, // 去除所有console语句
|
||||||
|
drop_debugger: true, // 去除debugger语句
|
||||||
|
dead_code: true, // 移除死代码
|
||||||
|
unused: true, // 移除未使用的变量
|
||||||
|
toplevel: true, // 清理顶层作用域未使用的变量
|
||||||
|
passes: 3, // 大幅增加压缩次数
|
||||||
|
reduce_funcs: true, // 合并或移除未使用的函数
|
||||||
|
collapse_vars: true, // 折叠定义后不再修改的变量
|
||||||
|
sequences: true, // 合并连续的变量声明
|
||||||
|
evaluate: true, // 提前计算常量表达式
|
||||||
|
unsafe: true, // 已压缩代码启用更激进的压缩策略
|
||||||
|
unsafe_comps: true, // 优化比较操作
|
||||||
|
reduce_vars: true, // 合并或移除变量
|
||||||
|
join_vars: true, // 合并变量声明
|
||||||
|
side_effects: false, // 假设函数调用没有副作用
|
||||||
|
pure_funcs: ['console.log', 'console.warn', 'console.error', 'console.info', 'console.debug'], // 标记这些函数为纯函数,可以安全移除
|
||||||
|
pure_getters: true, // 假设getter函数没有副作用
|
||||||
|
unsafe_math: true, // 允许不安全的数学优化
|
||||||
|
unsafe_proto: true, // 允许不安全的原型优化
|
||||||
|
unsafe_regexp: true, // 允许不安全的正则表达式优化
|
||||||
|
conditionals: true, // 优化条件表达式
|
||||||
|
comparisons: true, // 优化比较操作
|
||||||
|
booleans: true, // 优化布尔表达式
|
||||||
|
typeofs: true // 优化typeof操作
|
||||||
|
},
|
||||||
|
format: {
|
||||||
|
ascii_only: true, // 确保输出ASCII字符
|
||||||
|
comments: false, // 去除所有注释
|
||||||
|
beautify: false // 不美化输出
|
||||||
|
},
|
||||||
|
// 为已压缩代码启用更严格的处理
|
||||||
|
parse: {
|
||||||
|
bare_returns: true, // 允许顶级return语句
|
||||||
|
expression: false // 禁用表达式模式
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user