menuBtn.vue
4.33 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<template>
<view>
<view
class="menuBtn"
v-if="list.length > 0"
@click="showMenu"
>
<text class="menuText">{{ title }}</text>
<text class="menuText">{{ list[value].title }}</text>
<image
src="@/devTools/page/static/menu.png"
class="menuIcon"
/>
</view>
<view
v-if="showMenuList"
class="menuMock"
:style="{
height: height + 'px',
}"
@click.stop
>
<view
class="closeBtn"
@click="close"
>
<text class="closeText">关闭</text>
</view>
<scroll-view
:style="{
maxHeight: height * 0.7 + 'px',
}"
scroll-y
class="scrollList"
>
<view
v-for="(item, index) in list"
:key="item.title"
class="menuSelectItem"
:class="[index > 0 ? 'tl' : '', index == 0 ? 'i-s' : '', index == list.length ? 'i-e' : '']"
@click="menuSelect(index)"
>
<text
class="menuSelectText"
:style="{
color: index == value ? '#ff2d55' : '#333333',
}"
>
{{ item.title }}
</text>
<view v-if="item.msg">
<text class="menuSelectMsg">{{ item.msg }}</text>
</view>
</view>
</scroll-view>
</view>
</view>
</template>
<script>
export default {
props: {
/**
* 按钮列表
*/
list: {
type: Array,
default: () => [],
},
/**
* 当前选中的按钮索引
*/
value: {
type: Number,
default: 0,
},
/**
* 标题
*/
title: {
type: String,
default: "",
},
},
data() {
return {
/**
* 屏幕高度
*/
height: uni.getSystemInfoSync().windowHeight,
/**
* 是否展示菜单列表
*/
showMenuList: false,
};
},
methods: {
/**
* 展示菜单
*/
showMenu() {
this.showMenuList = true;
},
/**
* 点击菜单选择事件
*/
menuSelect(index) {
this.$emit("indexChange", index);
this.showMenuList = false;
},
/**
* 关闭菜单弹窗
*/
close() {
this.showMenuList = false;
},
},
};
</script>
<style lang="scss" scoped>
.menuBtn {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
border-radius: 8rpx;
height: 40rpx;
border: 1px solid rgba(0, 0, 0, 0.05);
padding: 0 8rpx;
&:active {
background-color: rgba(0, 0, 0, 0.05);
}
.menuText {
font-size: 20rpx;
line-height: 40rpx;
color: #333;
}
.menuIcon {
margin-left: 8rpx;
width: 28rpx;
height: 28rpx;
}
}
.menuMock {
position: fixed;
z-index: 90;
width: 750rpx;
left: 0;
top: 0;
flex: 1;
/* #ifndef APP-PLUS */
height: 100vh;
backdrop-filter: blur(2px);
/* #endif */
display: flex;
flex-direction: column-reverse;
align-items: center;
background-color: rgba(0, 0, 0, 0.3);
.closeBtn {
width: 710rpx;
height: 80rpx;
margin-bottom: 80rpx;
border-radius: 20rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
background-color: #fff;
transition: background-color 200ms ease-in-out;
&:active {
background-color: #dcdcdc;
}
.closeText {
font-size: 24rpx;
color: #333;
line-height: 24rpx;
}
}
}
.scrollList {
display: flex;
flex-direction: column;
align-items: center;
width: 710rpx;
margin-bottom: 30rpx;
border-radius: 20rpx;
overflow: hidden;
.menuSelectItem {
width: 710rpx;
/* #ifndef APP-PLUS */
min-height: 80rpx;
/* #endif */
padding: 15rpx 0;
background-color: #fff;
transition: background-color 200ms ease-in-out;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
&.tl {
border-top: 1px solid rgba(0, 0, 0, 0.1);
}
&.i-s {
border-radius: 20rpx 20rpx 0 0;
}
&.i-e {
border-radius: 0 0 20rpx 20rpx;
}
&:active {
background-color: #dcdcdc;
}
.menuSelectText {
font-size: 24rpx;
line-height: 24rpx;
color: #333;
}
.menuSelectMsg {
font-size: 20rpx;
line-height: 20rpx;
margin-top: 10rpx;
color: #999999;
}
}
}
</style>