TabBar.vue
3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
<div class="tab-bar" :class="{ 'in-mini-program': inMiniProgram }">
<van-tabbar
v-model="active"
z-index="99"
fixed
style="position: fixed"
:class="{ 'in-mini-program': inMiniProgram }"
@change="onChange"
>
<van-tabbar-item>
<span>首页</span>
<template #icon="props">
<i :class="props.active ? 'icon-shouye_sel' : 'icon-shouye_nor'" />
</template>
</van-tabbar-item>
<van-tabbar-item
:badge="msgbadge > 0 ? (msgbadge > 98 ? '99+' : msgbadge) : null"
>
<span>消息</span>
<template #icon="props">
<i :class="props.active ? 'icon-xiaoxi_sel' : 'icon-xiaoxi_nor'" />
</template>
</van-tabbar-item>
<van-tabbar-item>
<span>工作台</span>
<template #icon="props">
<i
:class="
props.active ? 'icon-gongzuotai_sel' : 'icon-gongzuotai_nor'
"
/>
</template>
</van-tabbar-item>
<van-tabbar-item>
<span>我的</span>
<template #icon="props">
<i :class="props.active ? 'icon-wode_sel' : 'icon-wode_nor'" />
</template>
</van-tabbar-item>
</van-tabbar>
</div>
</template>
<script>
export default {
props: ['activeIndex'],
data() {
return {
active: this.activeIndex,
msgbadge: 0,
inMiniProgram: false,
}
},
mounted() {
this.refreshMsgbadge()
this.$store.dispatch('user/loadCurrentUserDetail')
var userAgent = navigator.userAgent
if (/miniProgram/i.test(userAgent) || window.plus) {
this.inMiniProgram = true
}
},
methods: {
onChange(event) {
switch (this.active) {
case 0:
this.$router.push('/home')
break
case 1:
this.$router.push('/messageReceiverList')
break
case 2:
this.$router.push('/worker')
break
case 3:
this.$router.push('/personal')
break
default:
this.$router.push('/home')
break
}
},
refreshMsgbadge() {
let _this = this
this.$http
.get(
`${window.context.portal}/innermsg/messageReceiver/v1/getMsgbadge`
)
.then(
(response) => {
if (response.state) {
_this.msgbadge = response.value
}
},
(error) => {}
)
},
},
}
</script>
<style lang="scss" scoped>
.in-mini-program {
height: 80px !important;
}
.tab-bar {
// position: fixed !important;
// left: 0;
// right: 0;
// bottom: 0;
// width: 100%;
// z-index: 8;
// position: absolute;
// width: 100%;
// bottom: 49px;
// z-index: 8;
// // height: 49px;
height: 55px;
.van-tabbar {
height: 49px;
}
.van-tabbar-item {
margin: 3px 0 4px 0;
::v-deep {
.van-info {
margin-top: 0;
border-radius: 8px 8px 8px 8px;
top: 8px;
font-weight: 400;
font-size: 10px;
background: #e55555;
}
.van-tabbar-item__icon {
color: #bfbfbf;
margin-bottom: 1px;
i {
font-size: 24px;
}
}
.van-tabbar-item__text {
color: #bfbfbf;
font-size: 11px;
height: 16px;
line-height: 16px;
}
}
&.van-tabbar-item--active {
::v-deep {
.van-tabbar-item__icon,
.van-tabbar-item__text {
color: $--color-primary;
}
}
}
}
}
</style>