fix(底部TabBar): 点击后,按钮激活状态下,不变颜色
This commit is contained in:
@@ -59,6 +59,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { adaptSubpackageUrl } from '@/common/js/util.js'
|
||||
import DiyMinx from './minx.js'
|
||||
// 底部导航栏
|
||||
export default {
|
||||
@@ -82,10 +83,7 @@ export default {
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
let currentPage = getCurrentPages()[getCurrentPages().length - 1];
|
||||
if (currentPage && currentPage.route) {
|
||||
this.currentRoute = currentPage.route;
|
||||
}
|
||||
this.updateCurrentRoute();
|
||||
this.$nextTick(() => {
|
||||
if (!this.$store.state.cartPosition) {
|
||||
let query = uni.createSelectorQuery().in(this);
|
||||
@@ -101,6 +99,10 @@ export default {
|
||||
}).exec();
|
||||
}
|
||||
});
|
||||
// 监听页面显示事件,更新当前路由
|
||||
this.$on('hook:onShow', () => {
|
||||
this.updateCurrentRoute();
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
cartChange() {
|
||||
@@ -124,24 +126,34 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 更新当前路由
|
||||
updateCurrentRoute() {
|
||||
let currentPage = getCurrentPages()[getCurrentPages().length - 1];
|
||||
if (currentPage && currentPage.route) {
|
||||
this.currentRoute = currentPage.route;
|
||||
}
|
||||
},
|
||||
redirectTo(link) {
|
||||
this.$emit('callback');
|
||||
this.$util.diyRedirectTo(link);
|
||||
},
|
||||
verify(link) {
|
||||
if (link == null || link == '' || !link.wap_url) return false;
|
||||
if (this.name) {
|
||||
var url = this.currentRoute + '?name=' + this.name;
|
||||
} else {
|
||||
var url = this.currentRoute;
|
||||
}
|
||||
|
||||
// 标准化路径格式,确保比较的一致性
|
||||
let currentPageRoute = this.currentRoute ? '/' + this.currentRoute : '';
|
||||
let linkUrl = link.wap_url;
|
||||
|
||||
// 首页特殊处理
|
||||
if (link.wap_url == '/pages/index/index' && this.name == 'DIY_VIEW_INDEX') {
|
||||
return true;
|
||||
} else if (url && link.wap_url.indexOf(url) != -1) {
|
||||
if (linkUrl === '/pages/index/index' && this.name === 'DIY_VIEW_INDEX') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 精确匹配当前路径
|
||||
if (adaptSubpackageUrl(linkUrl) === currentPageRoute) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user