|
@@ -10,20 +10,12 @@ const tabbarPathList=['pages/activity/activity','pages/buy/buy','pages/chart/cha
|
|
|
|
|
|
module.exports = {
|
|
module.exports = {
|
|
watch: {
|
|
watch: {
|
|
- tabbar(){
|
|
|
|
- const page = this.$mp&&this.$mp.page;
|
|
|
|
- if(page&&tabbarPathList.includes(page.route)){
|
|
|
|
- if (page&&typeof page.getTabBar === "function" && page.getTabBar()){;
|
|
|
|
- page.getTabBar().setData({
|
|
|
|
- list: this.tabbar,
|
|
|
|
- selected:this.tabbar[0].pagePath
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ tabbarList(){
|
|
|
|
+ this.handleSetTabBarItem()
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
- tabbar(){
|
|
|
|
|
|
+ tabbarList(){
|
|
return store.state.user.tabbarList
|
|
return store.state.user.tabbarList
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -49,22 +41,32 @@ module.exports = {
|
|
globalBgMusic:uni.getBackgroundAudioManager()
|
|
globalBgMusic:uni.getBackgroundAudioManager()
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- onLoad() {
|
|
|
|
- this.handleSetTabBarItem()
|
|
|
|
- },
|
|
|
|
|
|
+ onLoad() {},
|
|
onShow(){
|
|
onShow(){
|
|
this.userInfo=this.$store.state.user.userInfo
|
|
this.userInfo=this.$store.state.user.userInfo
|
|
this.handleActivityListPageRefresh()
|
|
this.handleActivityListPageRefresh()
|
|
|
|
+ this.$store.dispatch('getTabBar')
|
|
|
|
+ this.handleSetTabBarItem()
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
// 设置tabbar的选中态
|
|
// 设置tabbar的选中态
|
|
handleSetTabBarItem(){
|
|
handleSetTabBarItem(){
|
|
const page = this.$mp&&this.$mp.page;
|
|
const page = this.$mp&&this.$mp.page;
|
|
const tabbarList=this.$store.state.user.tabbarList
|
|
const tabbarList=this.$store.state.user.tabbarList
|
|
|
|
+ if(!page||tabbarList.length==0) return
|
|
|
|
+
|
|
|
|
+ let selected=page.route
|
|
|
|
+ // 如果用户的tabbar 改变了 并且他点击的tabbar选项正好不存在了 则重定向到第一个tabbar
|
|
|
|
+ let temarr=tabbarList.map(item=>item.pagePath)
|
|
|
|
+ if(tabbarPathList.includes(selected)&&!temarr.includes(selected)){
|
|
|
|
+ selected=tabbarList[0].pagePath
|
|
|
|
+ uni.switchTab({ url: `/${selected}` })
|
|
|
|
+ }
|
|
|
|
+
|
|
if(tabbarPathList.includes(page.route)){
|
|
if(tabbarPathList.includes(page.route)){
|
|
if (page&&typeof page.getTabBar === "function" && page.getTabBar()) {
|
|
if (page&&typeof page.getTabBar === "function" && page.getTabBar()) {
|
|
page.getTabBar().setData({
|
|
page.getTabBar().setData({
|
|
- selected: page.route,
|
|
|
|
|
|
+ selected: selected,
|
|
list:tabbarList
|
|
list:tabbarList
|
|
});
|
|
});
|
|
}
|
|
}
|