103 lines
2.7 KiB
JavaScript
103 lines
2.7 KiB
JavaScript
// custom-tab-bar/index.js
|
||
Component({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
tabBarShow: true,
|
||
active: 0,
|
||
"backgroundColor": "#ffffff",
|
||
"selectedColor": "#fff",
|
||
"listAll": {
|
||
"list2":[
|
||
{
|
||
"pagePath": "/Pages/yaoshi/home/home",
|
||
"text": "首页",
|
||
"iconPath": "/static/images/yaoshi/tabbar_icon/home.png",
|
||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/home_select.png"
|
||
},
|
||
{
|
||
"pagePath": "/Pages/yaoshi/my/my",
|
||
"text": "我的",
|
||
"iconPath": "/static/images/yaoshi/tabbar_icon/my.png",
|
||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/my_select.png"
|
||
}],
|
||
"list1":[
|
||
{
|
||
"pagePath": "/Pages/yishi/index/index",
|
||
"text": "首页(Y)",
|
||
"iconPath": "/static/images/yishi/tabbar_icon/index.png",
|
||
"selectedIconPath": "/static/images/yishi/tabbar_icon/index_select.png"
|
||
},
|
||
{
|
||
"pagePath": "/Pages/yishi/wenzhen/wenzhen",
|
||
"text": "问诊(Y)",
|
||
"iconPath": "/static/images/yishi/tabbar_icon/wenzhen.png",
|
||
"selectedIconPath": "/static/images/yishi/tabbar_icon/wenzhen_select.png"
|
||
},
|
||
{
|
||
"pagePath": "/Pages/yishi/my/index",
|
||
"text": "我的(Y)",
|
||
"iconPath": "/static/images/yishi/tabbar_icon/my.png",
|
||
"selectedIconPath": "/static/images/yishi/tabbar_icon/my_select.png"
|
||
}]
|
||
},
|
||
items: [ ],
|
||
dialog_visible: false,
|
||
dialog_content: ""
|
||
},
|
||
attached() {
|
||
const usertype = wx.getStorageSync('usertype')
|
||
console.log("usertype: " ,usertype);
|
||
if (usertype == 2) {
|
||
this.setData({
|
||
items: this.data.listAll.list1
|
||
})
|
||
}else{
|
||
this.setData({
|
||
items: this.data.listAll.list2
|
||
})
|
||
}
|
||
},
|
||
methods: {
|
||
// swichNav: function (e) {
|
||
// console.log(123);
|
||
// let that = this;
|
||
// if (this.data.currentTab === e.target.dataset.current) {
|
||
// return false;
|
||
// } else {
|
||
// that.setData({
|
||
// currentTab: e.target.dataset.current
|
||
// })
|
||
// let url = e.currentTarget.dataset.url; // 点击tabbar时,跳转对应的页面
|
||
// wx.switchTab({
|
||
// url: url,
|
||
// })
|
||
// }
|
||
// },
|
||
onChange(e) {
|
||
// this.setData({
|
||
// dialog_visible: true,
|
||
// dialog_content: "测试"
|
||
// })
|
||
console.log("custom tab bar onChange");
|
||
// return;
|
||
let url = this.data.items[e.detail].pagePath
|
||
wx.switchTab({
|
||
url: url,
|
||
})
|
||
},
|
||
confirmDialog(){
|
||
this.setData({
|
||
dialog_visible: false
|
||
})
|
||
},
|
||
cancelDialog(){
|
||
this.setData({
|
||
dialog_visible: false
|
||
})
|
||
},
|
||
}
|
||
|
||
}) |