fix(TabBar): 从商品分类TabBar项点击进入的都算商品分类
This commit is contained in:
@@ -61,6 +61,35 @@ export const adaptSubpackageUrl = (url) => {
|
|||||||
return replacePrefix(url);
|
return replacePrefix(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查tabBar是否激活
|
||||||
|
* @param {string} linkUrl 链接路径 /pages/goods/category
|
||||||
|
* @param {string} currentPageRoute 当前页面路径 /pages_goods/category
|
||||||
|
* @returns {boolean} 是否激活
|
||||||
|
*/
|
||||||
|
export const checkTabBarActive = (linkUrl, currentPageRoute) => {
|
||||||
|
const linkUrlParts = adaptSubpackageUrl(linkUrl).split('/');
|
||||||
|
const currentPageRouteParts = currentPageRoute.split('/');
|
||||||
|
|
||||||
|
console.log('diy-bottom-nav verify:', { linkUrlParts, currentPageRouteParts});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 二级页面
|
||||||
|
if (linkUrlParts[2] === currentPageRouteParts[2]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 一级页面,限定只能是goods相关
|
||||||
|
if (linkUrlParts[1] === currentPageRouteParts[1] && linkUrlParts[1] === 'pages_goods') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('diy-bottom-nav verify error:', error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
/**
|
/**
|
||||||
* 页面跳转
|
* 页面跳转
|
||||||
@@ -130,8 +159,6 @@ 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) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { adaptSubpackageUrl } from '@/common/js/util.js'
|
import { adaptSubpackageUrl, checkTabBarActive } from '@/common/js/util.js'
|
||||||
import DiyMinx from './minx.js'
|
import DiyMinx from './minx.js'
|
||||||
// 底部导航栏
|
// 底部导航栏
|
||||||
export default {
|
export default {
|
||||||
@@ -149,23 +149,12 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('diy-bottom-nav verify:', { likkUrl: adaptSubpackageUrl(linkUrl), currentPageRoute: currentPageRoute});
|
|
||||||
|
|
||||||
// 精确匹配当前路径
|
// 精确匹配当前路径
|
||||||
if (adaptSubpackageUrl(linkUrl) === currentPageRoute) {
|
if (adaptSubpackageUrl(linkUrl) === currentPageRoute) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同属于一个子包的路径,也认为是匹配的
|
return checkTabBarActive(linkUrl, currentPageRoute);
|
||||||
try {
|
|
||||||
if (adaptSubpackageUrl(linkUrl).split('/')[1] === currentPageRoute.split('/')[1]) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('diy-bottom-nav verify error:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user