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() { 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,34 +60,37 @@
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++) {
uni.setTabBarItem({ if (res.data[i].hide == 1) {
index: 0, if (res.data[i].type == "home") {
text: res.data[i].title, uni.setTabBarItem({
"visible": true index: 0,
}); text: res.data[i].title,
} "visible": true
if(res.data[i].type == "scan") { });
uni.setTabBarItem({ }
index: 1, if (res.data[i].type == "scan") {
text: res.data[i].title, uni.setTabBarItem({
"visible": true index: 1,
}); text: res.data[i].title,
} "visible": true
if(res.data[i].type == "know") { });
uni.setTabBarItem({ }
index: 2, if (res.data[i].type == "know") {
text: res.data[i].title, uni.setTabBarItem({
"visible": true index: 2,
}); text: res.data[i].title,
} "visible": true
if(res.data[i].type == "my") { });
uni.setTabBarItem({ }
index: 3, if (res.data[i].type == "my") {
text: res.data[i].title, uni.setTabBarItem({
"visible": true index: 3,
}); text: res.data[i].title,
"visible": true
});
}
} }
} }
}).catch((e) => console.log(e)); //捕获异常 }).catch((e) => console.log(e)); //捕获异常

Loading…
Cancel
Save