fix(底部TabBar): 点击后,按钮激活状态下,不变颜色
This commit is contained in:
@@ -5,6 +5,58 @@ import {
|
||||
Weixin
|
||||
} from 'common/js/wx-jssdk.js';
|
||||
|
||||
|
||||
// 当前最新的tabBar.list (参见pages.json 中的tabBar.list 配置)
|
||||
export const systemTabBarList = [
|
||||
'/pages/index/index',
|
||||
'/pages_goods/category',
|
||||
'/pages_tool/contact/contact',
|
||||
'/pages_tool/member/index'
|
||||
];
|
||||
|
||||
/**
|
||||
* 适配子包路径
|
||||
* @param {string} url
|
||||
* @returns
|
||||
*/
|
||||
export const adaptSubpackageUrl = (url) => {
|
||||
/**
|
||||
* 特别注意:
|
||||
* 由于老版本或者后台系统服务未同步更新可以作为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; // 默认返回原匹配
|
||||
});
|
||||
}
|
||||
|
||||
return replacePrefix(url);
|
||||
}
|
||||
|
||||
export default {
|
||||
/**
|
||||
* 页面跳转
|
||||
@@ -15,52 +67,10 @@ export default {
|
||||
redirectTo(to, param, mode) {
|
||||
let url = to;
|
||||
|
||||
// 当前最新的tabBar.list (参见pages.json 中的tabBar.list 配置)
|
||||
const systemTabBarList = [
|
||||
'/pages/index/index',
|
||||
'/pages_goods/category',
|
||||
'/pages_tool/contact/contact',
|
||||
'/pages_tool/member/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);
|
||||
console.log('redirectTo', to, param, mode);
|
||||
url = adaptSubpackageUrl(url);
|
||||
console.log('adaptSubpackageUrl', url);
|
||||
|
||||
if (param != undefined) {
|
||||
Object.keys(param).forEach(function (key) {
|
||||
|
||||
Reference in New Issue
Block a user