Browse Source

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

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

75
pages/index/index.vue

@ -37,6 +37,22 @@
};
},
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.getSwiperList()
},
@ -44,34 +60,37 @@
listTabbar() {
this.$api.listTabbar({})
.then(res => {
for(var i=0; i<res.data.length; i++) {
if(res.data[i].type == "home") {
uni.setTabBarItem({
index: 0,
text: res.data[i].title,
"visible": true
});
}
if(res.data[i].type == "scan") {
uni.setTabBarItem({
index: 1,
text: res.data[i].title,
"visible": true
});
}
if(res.data[i].type == "know") {
uni.setTabBarItem({
index: 2,
text: res.data[i].title,
"visible": true
});
}
if(res.data[i].type == "my") {
uni.setTabBarItem({
index: 3,
text: res.data[i].title,
"visible": true
});
console.log(res)
for (var i = 0; i < res.data.length; i++) {
if (res.data[i].hide == 1) {
if (res.data[i].type == "home") {
uni.setTabBarItem({
index: 0,
text: res.data[i].title,
"visible": true
});
}
if (res.data[i].type == "scan") {
uni.setTabBarItem({
index: 1,
text: res.data[i].title,
"visible": true
});
}
if (res.data[i].type == "know") {
uni.setTabBarItem({
index: 2,
text: res.data[i].title,
"visible": true
});
}
if (res.data[i].type == "my") {
uni.setTabBarItem({
index: 3,
text: res.data[i].title,
"visible": true
});
}
}
}
}).catch((e) => console.log(e)); //

Loading…
Cancel
Save