15 changed files with 834 additions and 669 deletions
			
			
		@ -0,0 +1,32 @@ | 
				
			|||
Component({ | 
				
			|||
    data: { | 
				
			|||
        selected: 0, | 
				
			|||
        color: "#7A7E83", | 
				
			|||
        selectedColor: "#1070E8", | 
				
			|||
        list: [] | 
				
			|||
    }, | 
				
			|||
    attached () { | 
				
			|||
        let userRole = wx.getStorageSync('userRole'); | 
				
			|||
        // 0 表示普通用户 1表示管理员
 | 
				
			|||
        console.log('userRole', userRole); | 
				
			|||
        if (userRole && userRole.includes('管理')) { | 
				
			|||
            this.setData({ | 
				
			|||
                list: getApp().globalData.managerList | 
				
			|||
            }) | 
				
			|||
        } else { | 
				
			|||
            this.setData({ | 
				
			|||
                list: getApp().globalData.inspecterList | 
				
			|||
            }) | 
				
			|||
        } | 
				
			|||
    }, | 
				
			|||
    methods: { | 
				
			|||
        switchTab (e) { | 
				
			|||
            const data = e.currentTarget.dataset | 
				
			|||
            const url = data.path | 
				
			|||
            // this.setData({
 | 
				
			|||
            //     selected: data.index
 | 
				
			|||
            // })
 | 
				
			|||
            wx.switchTab({ url }) | 
				
			|||
        } | 
				
			|||
    } | 
				
			|||
}) | 
				
			|||
@ -0,0 +1,3 @@ | 
				
			|||
{ | 
				
			|||
    "component": true | 
				
			|||
} | 
				
			|||
@ -0,0 +1,8 @@ | 
				
			|||
<!-- miniprogram/custom-tab-bar/index.wxml --> | 
				
			|||
<view class="tab-bar"> | 
				
			|||
    <view class="tab-bar-border"></view> | 
				
			|||
    <view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab"> | 
				
			|||
        <image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></image> | 
				
			|||
        <view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</view> | 
				
			|||
    </view> | 
				
			|||
</view> | 
				
			|||
@ -0,0 +1,38 @@ | 
				
			|||
.tab-bar { | 
				
			|||
    position: fixed; | 
				
			|||
    bottom: 0; | 
				
			|||
    left: 0; | 
				
			|||
    right: 0; | 
				
			|||
    height: 48px; | 
				
			|||
    background: white; | 
				
			|||
    display: flex; | 
				
			|||
    padding-bottom: env(safe-area-inset-bottom); | 
				
			|||
} | 
				
			|||
 | 
				
			|||
.tab-bar-border { | 
				
			|||
    background-color: rgba(0, 0, 0, 0.33); | 
				
			|||
    position: absolute; | 
				
			|||
    left: 0; | 
				
			|||
    top: 0; | 
				
			|||
    width: 100%; | 
				
			|||
    height: 1px; | 
				
			|||
    transform: scaleY(0.5); | 
				
			|||
} | 
				
			|||
 | 
				
			|||
.tab-bar-item { | 
				
			|||
    flex: 1; | 
				
			|||
    text-align: center; | 
				
			|||
    display: flex; | 
				
			|||
    justify-content: center; | 
				
			|||
    align-items: center; | 
				
			|||
    flex-direction: column; | 
				
			|||
} | 
				
			|||
 | 
				
			|||
.tab-bar-item image { | 
				
			|||
    width: 27px; | 
				
			|||
    height: 27px; | 
				
			|||
} | 
				
			|||
 | 
				
			|||
.tab-bar-item view { | 
				
			|||
    font-size: 10px; | 
				
			|||
} | 
				
			|||
					Loading…
					
					
				
		Reference in new issue