ToolBox.vue
5.26 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
<template>
<view class="tool-box" :style="toolStyle">
<view :class="['btn', { hideIcon: !show }]" @click="show = false">
<view class="icon sprite-icon icon-tool-file"></view>
文件夹
</view>
<view :class="['list', { showList: !show }]">
<view class="title" @click="show = true">文件夹</view>
<view class="list-body">
<template v-for="(i, index) in data">
<view :class="['item', { active: i[idKey] == id }]" :key="index" @click="jump(i)">
<image v-if="!show" class="icon" :src="i.shortTitleUrl" mode="scaleToFill" />
{{ i.shortTitle }}
</view>
</template>
</view>
<template v-if="showPayBtn">
<view class="item" @click="toPay">
<view class="icon">
<view class="sprite-icon icon-tool-pay"></view>
</view>
付款方式
</view>
</template>
<template v-if="type != 'preview'">
<view class="item" @click="finish">
<view class="icon">
<view class="sprite-icon icon-tool-finish"></view>
</view>
完成接待
</view>
</template>
</view>
</view>
</template>
<script type="text/ecmascript-6">
export default {
name: 'ToolBox',
props: {
type: String,
data: Array,
id: [String, Number],
showPayBtn: Boolean,
idKey: {
type: String,
default: 'id'
},
toolStyle:String
},
data () {
return {
show: true
}
},
computed: {
watchStatus () {
return this.$store.state.user.historyStatus
},
},
watch: {
show (hidden) {
this.$emit('visibility-change', !hidden)
},
watchStatus: {
immediate: true,
handler (newval) {
this.show = true
}
},
},
methods: {
hide () {
this.show = true
},
jump (item) {
this.show = true
this.$emit('choose', item)
},
finish () {
this.$emit('finish')
},
// 选择付款方式
toPay () {
this.$emit('toPay')
},
}
}
</script>
<style scoped lang="scss">
.tool-box {
position: fixed;
right: toRpx(40);
top: calc(5% + #{toRpx(140)});
z-index: 998;
width: toRpx(120);
.btn {
width: 100%;
height: toRpx(120);
background-image: linear-gradient(180deg, #ffffff 0%, #f8f9fb 100%);
border: toRpx(2) solid #ffffff;
box-shadow: 0 toRpx(8) toRpx(24) 0 #00000033;
border-radius: toRpx(16);
font-size: toRpx(24);
color: #292d33;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.icon {
width: toRpx(60);
height: toRpx(60);
margin-bottom: toRpx(8);
transition: all 0.05s;
}
}
.hideIcon {
height: 0;
overflow: hidden;
opacity: 0;
.icon {
height: 0;
margin-bottom: 0;
}
}
.list {
width: 100%;
border: toRpx(2) solid #ffffff;
box-shadow: 0 toRpx(8) toRpx(22) 0 #0000001a;
border-radius: toRpx(16);
flex-direction: column;
align-items: center;
overflow: hidden;
position: relative;
background: rgba(255, 255, 255, 0.95); // 增加不透明度,提升质感
backdrop-filter: blur(10px); // 添加毛玻璃效果,更高级
// 初始状态
max-height: 0;
opacity: 0;
transform: translateY(-20rpx) scale(0.95); // 稍微上移并缩小,制造弹出感
transform-origin: top center;
// 优化动画曲线:更干脆利落 (cubic-bezier)
// 缩短时间:0.4s -> 0.3s,更跟手不拖沓
transition:
max-height 0.3s cubic-bezier(0.215, 0.61, 0.355, 1),
opacity 0.2s linear,
transform 0.3s cubic-bezier(0.215, 0.61, 0.355, 1);
&::after {
position: absolute;
content: '';
background: inherit;
top: 0;
left: 0;
right: 0;
bottom: 0;
// filter: blur(toRpx(8)); // 移除原来的模糊,改用 backdrop-filter
z-index: -1;
}
// ... 其他原有样式保持不变
.title {
width: toRpx(120);
height: toRpx(56);
background: #f4f4f5;
border: toRpx(2) solid #ffffff;
border-radius: toRpx(16) toRpx(16) 0 0;
display: flex;
align-items: center;
justify-content: center;
}
.list-body {
max-height: 60vh;
overflow-y: auto;
}
// ... item 样式
.item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: toRpx(20);
color: #666666;
// height: toRpx(120);
width: 100%;
padding-top: toRpx(16);
.icon {
width: toRpx(60);
height: toRpx(60);
margin-bottom: toRpx(8);
}
}
.active {
color: #2c66f7;
}
}
.showList {
display: flex;
// 展开状态:给予足够大的max-height
max-height: toRpx(1000); // 预估一个足够大的值,或者使用 100vh
opacity: 1;
transform: translateY(0) scale(1); // 恢复原位原大小
padding-bottom: toRpx(16);
// 移除之前的 animation
// animation: scale-up-top-right 0.4s;
// visibility: visible; // 不需要 visibility,因为 height 0 已经隐藏了内容
// height: auto; // 使用 max-height 做动画
}
// 移除之前的 keyframes
// @keyframes scale-up-top-right { ... }
}
</style>