Browse Source

自定义tabbar数量和数据库同步

h5_css
蟑螂恶霸 3 years ago
parent
commit
073430973d
  1. 29
      pages/index/index.vue

29
pages/index/index.vue

@ -37,6 +37,22 @@
}; };
}, },
onLoad() { onLoad() {
uni.setTabBarItem({
index: 1,
"visible": false
});
uni.setTabBarItem({
index: 2,
"visible": false
});
uni.setTabBarItem({
index: 3,
"visible": false
});
uni.setTabBarItem({
index: 4,
"visible": false
});
this.listTabbar(); this.listTabbar();
this.getSwiperList() this.getSwiperList()
}, },
@ -44,29 +60,31 @@
listTabbar() { listTabbar() {
this.$api.listTabbar({}) this.$api.listTabbar({})
.then(res => { .then(res => {
for(var i=0; i<res.data.length; i++) { console.log(res)
if(res.data[i].type == "home") { for (var i = 0; i < res.data.length; i++) {
if (res.data[i].hide == 1) {
if (res.data[i].type == "home") {
uni.setTabBarItem({ uni.setTabBarItem({
index: 0, index: 0,
text: res.data[i].title, text: res.data[i].title,
"visible": true "visible": true
}); });
} }
if(res.data[i].type == "scan") { if (res.data[i].type == "scan") {
uni.setTabBarItem({ uni.setTabBarItem({
index: 1, index: 1,
text: res.data[i].title, text: res.data[i].title,
"visible": true "visible": true
}); });
} }
if(res.data[i].type == "know") { if (res.data[i].type == "know") {
uni.setTabBarItem({ uni.setTabBarItem({
index: 2, index: 2,
text: res.data[i].title, text: res.data[i].title,
"visible": true "visible": true
}); });
} }
if(res.data[i].type == "my") { if (res.data[i].type == "my") {
uni.setTabBarItem({ uni.setTabBarItem({
index: 3, index: 3,
text: res.data[i].title, text: res.data[i].title,
@ -74,6 +92,7 @@
}); });
} }
} }
}
}).catch((e) => console.log(e)); //捕获异常 }).catch((e) => console.log(e)); //捕获异常
}, },

Loading…
Cancel
Save