优化
This commit is contained in:
+37
-13
@@ -1,4 +1,5 @@
|
||||
// custom-tab-bar/index.js
|
||||
const app = getApp()
|
||||
Component({
|
||||
|
||||
/**
|
||||
@@ -10,55 +11,77 @@ Component({
|
||||
"backgroundColor": "#ffffff",
|
||||
"selectedColor": "#fff",
|
||||
"listAll": {
|
||||
"list2":[
|
||||
"list1":[
|
||||
{
|
||||
"pagePath": "/Pages/yaoshi/home/home",
|
||||
"text": "首页",
|
||||
"iconPath": "/static/images/yaoshi/tabbar_icon/home.png",
|
||||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/home_select.png"
|
||||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/home_select.png",
|
||||
"info": ""
|
||||
},
|
||||
{
|
||||
"pagePath": "/Pages/yaoshi/my/my",
|
||||
"text": "我的",
|
||||
"iconPath": "/static/images/yaoshi/tabbar_icon/my.png",
|
||||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/my_select.png"
|
||||
"selectedIconPath": "/static/images/yaoshi/tabbar_icon/my_select.png",
|
||||
"info": ""
|
||||
}],
|
||||
"list1":[
|
||||
"list2":[
|
||||
{
|
||||
"pagePath": "/Pages/yishi/index/index",
|
||||
"text": "首页(Y)",
|
||||
"iconPath": "/static/images/yishi/tabbar_icon/index.png",
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/index_select.png"
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/index_select.png",
|
||||
"info": ""
|
||||
},
|
||||
{
|
||||
"pagePath": "/Pages/yishi/wenzhen/wenzhen",
|
||||
"text": "问诊(Y)",
|
||||
"pagePath": "/Pages/yishi/wenzhen_v2/wenzhen",
|
||||
"text": "问诊(Z)",
|
||||
"iconPath": "/static/images/yishi/tabbar_icon/wenzhen.png",
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/wenzhen_select.png"
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/wenzhen_select.png",
|
||||
"info": "99"
|
||||
},
|
||||
{
|
||||
"pagePath": "/Pages/yishi/my/index",
|
||||
"text": "我的(Y)",
|
||||
"iconPath": "/static/images/yishi/tabbar_icon/my.png",
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/my_select.png"
|
||||
"selectedIconPath": "/static/images/yishi/tabbar_icon/my_select.png",
|
||||
"info": ""
|
||||
}]
|
||||
},
|
||||
items: [ ],
|
||||
dialog_visible: false,
|
||||
dialog_content: ""
|
||||
dialog_content: "",
|
||||
usertype: "",
|
||||
index_info: "",
|
||||
wenzhen_info: "",
|
||||
my_info: "",
|
||||
},
|
||||
attached() {
|
||||
const usertype = wx.getStorageSync('usertype')
|
||||
console.log("usertype: " ,usertype);
|
||||
if (usertype == 2) {
|
||||
this.setData({
|
||||
items: this.data.listAll.list1
|
||||
usertype: usertype,
|
||||
items: this.data.listAll.list2
|
||||
})
|
||||
}else{
|
||||
this.setData({
|
||||
items: this.data.listAll.list2
|
||||
usertype: usertype,
|
||||
items: this.data.listAll.list1
|
||||
})
|
||||
}
|
||||
let _this = this;
|
||||
setInterval(() => {
|
||||
let index_info = wx.getStorageSync('index_info');
|
||||
let wenzhen_info = wx.getStorageSync('wenzhen_info');
|
||||
let my_info = wx.getStorageSync('my_info');
|
||||
_this.setData({
|
||||
index_info: index_info,
|
||||
wenzhen_info: wenzhen_info,
|
||||
my_info: my_info,
|
||||
})
|
||||
}, 500);
|
||||
},
|
||||
methods: {
|
||||
// swichNav: function (e) {
|
||||
@@ -83,7 +106,8 @@ Component({
|
||||
// })
|
||||
console.log("custom tab bar onChange");
|
||||
// return;
|
||||
let url = this.data.items[e.detail].pagePath
|
||||
let url = this.data.items[e.detail].pagePath;
|
||||
console.log(url);
|
||||
wx.switchTab({
|
||||
url: url,
|
||||
})
|
||||
|
||||
+84
-13
@@ -1,26 +1,97 @@
|
||||
<!-- <view class="nav-tabs" wx:if="{{tabBarShow}}">
|
||||
<view class="tab-list {{currentTab == idx ? 'active' : 'default' }}" wx:for="{{items}}" wx:key="prototype" wx:for-index="idx" wx:for-item="item" data-current="{{idx}}" data-url="{{item.pagePath}}" bindtap="swichNav">
|
||||
<text class="tab-text" wx:for-index="idx" data-current="{{idx}}" src="{{currentTab == idx ? item.selectedIconPath : item.iconPath }}">{{item.text}}</text>
|
||||
<image class="iconPath" wx:for-index="idx" data-current="{{idx}}" src="{{currentTab == idx ? item.selectedIconPath : item.iconPath }}"></image>
|
||||
</view>
|
||||
</view> -->
|
||||
<van-tabbar active="{{ active }}" bind:change="onChange">
|
||||
<van-tabbar-item info="3" data-url="{{item.pagePath}}" url="{{item.pagePath}}" wx:for="{{items}}">
|
||||
|
||||
<van-tabbar active="{{ active }}" bind:change="onChange"
|
||||
active-color="#3CC7C0" inactive-color="#999999" wx:if="{{usertype == 2}}" >
|
||||
|
||||
<van-tabbar-item info="{{index_info}}" data-url="{{listAll.list2[0].pagePath}}" url="{{listAll.list2[0].pagePath}}">
|
||||
<image
|
||||
slot="icon"
|
||||
src="{{ item.iconPath }}"
|
||||
data-url="{{ item.pagePath }}"
|
||||
src="{{ listAll.list2[0].iconPath }}"
|
||||
data-url="{{ listAll.list2[0].pagePath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
/>
|
||||
<image
|
||||
slot="icon-active"
|
||||
src="{{ item.selectedIconPath }}"
|
||||
src="{{ listAll.list2[0].selectedIconPath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
data-url="{{ item.pagePath }}"
|
||||
data-url="{{ listAll.list2[0].pagePath }}"
|
||||
/>
|
||||
{{item.text}}
|
||||
{{listAll.list2[0].text}}
|
||||
</van-tabbar-item>
|
||||
|
||||
<van-tabbar-item info="{{wenzhen_info}}" data-url="{{listAll.list2[1].pagePath}}" url="{{listAll.list2[1].pagePath}}">
|
||||
<image
|
||||
slot="icon"
|
||||
src="{{ listAll.list2[1].iconPath }}"
|
||||
data-url="{{ listAll.list2[1].pagePath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
/>
|
||||
<image
|
||||
slot="icon-active"
|
||||
src="{{ listAll.list2[1].selectedIconPath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
data-url="{{ listAll.list2[1].pagePath }}"
|
||||
/>
|
||||
{{listAll.list2[1].text}}
|
||||
</van-tabbar-item>
|
||||
|
||||
<van-tabbar-item info="{{my_info}}" data-url="{{listAll.list2[2].pagePath}}" url="{{listAll.list2[2].pagePath}}">
|
||||
<image
|
||||
slot="icon"
|
||||
src="{{ listAll.list2[2].iconPath }}"
|
||||
data-url="{{ listAll.list2[2].pagePath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
/>
|
||||
<image
|
||||
slot="icon-active"
|
||||
src="{{ listAll.list2[2].selectedIconPath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
data-url="{{ listAll.list2[2].pagePath }}"
|
||||
/>
|
||||
{{listAll.list2[2].text}}
|
||||
</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
|
||||
<van-tabbar active="{{ active }}" bind:change="onChange"
|
||||
active-color="#74A2FA" inactive-color="#999999" wx:if="{{usertype == 3}}" >
|
||||
<van-tabbar-item info="{{my_info}}" data-url="{{listAll.list1[0].pagePath}}" url="{{listAll.list1[0].pagePath}}">
|
||||
<image
|
||||
slot="icon"
|
||||
src="{{ listAll.list1[0].iconPath }}"
|
||||
data-url="{{ listAll.list1[0].pagePath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
/>
|
||||
<image
|
||||
slot="icon-active"
|
||||
src="{{ listAll.list1[0].selectedIconPath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
data-url="{{ listAll.list1[0].pagePath }}"
|
||||
/>
|
||||
{{listAll.list1[0].text}}
|
||||
</van-tabbar-item>
|
||||
<van-tabbar-item info="{{my_info}}" data-url="{{listAll.list1[1].pagePath}}" url="{{listAll.list1[1].pagePath}}">
|
||||
<image
|
||||
slot="icon"
|
||||
src="{{ listAll.list1[1].iconPath }}"
|
||||
data-url="{{ listAll.list1[1].pagePath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
/>
|
||||
<image
|
||||
slot="icon-active"
|
||||
src="{{ listAll.list1[1].selectedIconPath }}"
|
||||
mode="aspectFit"
|
||||
style="width: 30px; height: 18px;"
|
||||
data-url="{{ listAll.list1[1].pagePath }}"
|
||||
/>
|
||||
{{listAll.list1[1].text}}
|
||||
</van-tabbar-item>
|
||||
</van-tabbar>
|
||||
<t-dialog
|
||||
|
||||
Reference in New Issue
Block a user