@ruixinkeji/prism-ui 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components/PrismAIAssist/PrismAIAssist.vue +98 -98
- package/components/PrismAddressInput/PrismAddressInput.vue +597 -597
- package/components/PrismCityCascadeSelect/PrismCityCascadeSelect.vue +793 -793
- package/components/PrismCityPicker/PrismCityPicker.vue +1008 -1008
- package/components/PrismCitySelect/PrismCitySelect.vue +435 -435
- package/components/PrismCode/PrismCode.vue +749 -749
- package/components/PrismCodeInput/PrismCodeInput.vue +156 -156
- package/components/PrismDateTimePicker/PrismDateTimePicker.vue +953 -953
- package/components/PrismDropdown/PrismDropdown.vue +77 -77
- package/components/PrismGroupSticky/PrismGroupSticky.vue +352 -352
- package/components/PrismIdCardInput/PrismIdCardInput.vue +253 -253
- package/components/PrismImagePicker/PrismImagePicker.vue +457 -457
- package/components/PrismIndexBar/PrismIndexBar.vue +243 -243
- package/components/PrismLicensePlateInput/PrismLicensePlateInput.vue +1100 -1100
- package/components/PrismMusicPlayer/PrismMusicPlayer.vue +530 -530
- package/components/PrismNavBar/PrismNavBar.vue +199 -199
- package/components/PrismSecureInput/PrismSecureInput.vue +360 -360
- package/components/PrismSticky/PrismSticky.vue +173 -173
- package/components/PrismSwiper/PrismSwiper.vue +338 -338
- package/components/PrismSwitch/PrismSwitch.vue +202 -202
- package/components/PrismTabBar/PrismTabBar.vue +147 -147
- package/components/PrismTabs/PrismTabs.vue +49 -49
- package/components/PrismVoiceInput/PrismVoiceInput.vue +529 -529
- package/fonts/fa-brands-400.woff2 +0 -0
- package/fonts/fa-regular-400.woff2 +0 -0
- package/fonts/fa-solid-900.woff2 +0 -0
- package/fonts/fa-v4compatibility.woff2 +0 -0
- package/fonts/font-awesome.css +913 -0
- package/fonts/iconfont.woff2 +0 -0
- package/package.json +7 -1
- package/store/app.d.ts +21 -0
- package/store/app.js +68 -0
- package/styles/base.scss +2 -2
|
@@ -1,352 +1,352 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="prism-group-sticky-wrapper" :style="{ height: height }">
|
|
3
|
-
<scroll-view
|
|
4
|
-
class="prism-group-sticky"
|
|
5
|
-
scroll-y
|
|
6
|
-
:scroll-top="scrollTop"
|
|
7
|
-
:enhanced="true"
|
|
8
|
-
:show-scrollbar="false"
|
|
9
|
-
style="height: 100%"
|
|
10
|
-
@scroll="onScroll"
|
|
11
|
-
>
|
|
12
|
-
<slot></slot>
|
|
13
|
-
</scroll-view>
|
|
14
|
-
|
|
15
|
-
<!-- 右侧索引条 -->
|
|
16
|
-
<view
|
|
17
|
-
v-if="showIndexBar && indexList.length"
|
|
18
|
-
class="prism-index-bar"
|
|
19
|
-
@touchstart="onIndexTouchStart"
|
|
20
|
-
@touchmove.stop.prevent="onIndexTouchMove"
|
|
21
|
-
@touchend="onIndexTouchEnd"
|
|
22
|
-
>
|
|
23
|
-
<view
|
|
24
|
-
v-for="item in indexList"
|
|
25
|
-
:key="item"
|
|
26
|
-
class="index-item"
|
|
27
|
-
:class="{ active: currentIndex === item }"
|
|
28
|
-
>{{ item }}</view>
|
|
29
|
-
</view>
|
|
30
|
-
|
|
31
|
-
<!-- 气泡提示(移到索引条外部) -->
|
|
32
|
-
<view
|
|
33
|
-
v-if="showIndicator"
|
|
34
|
-
class="index-indicator"
|
|
35
|
-
:style="{ top: indicatorTop + 'px' }"
|
|
36
|
-
>{{ currentIndex }}</view>
|
|
37
|
-
</view>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<script setup>
|
|
41
|
-
import { ref, nextTick, getCurrentInstance } from 'vue';
|
|
42
|
-
|
|
43
|
-
const props = defineProps({
|
|
44
|
-
// 索引列表
|
|
45
|
-
indexList: {
|
|
46
|
-
type: Array,
|
|
47
|
-
default: () => []
|
|
48
|
-
},
|
|
49
|
-
// 是否显示索引条
|
|
50
|
-
showIndexBar: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
default: false
|
|
53
|
-
},
|
|
54
|
-
// 容器高度
|
|
55
|
-
height: {
|
|
56
|
-
type: String,
|
|
57
|
-
default: '100%'
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const emit = defineEmits(['index-change']);
|
|
62
|
-
const instance = getCurrentInstance();
|
|
63
|
-
|
|
64
|
-
// 当前选中的索引
|
|
65
|
-
const currentIndex = ref('');
|
|
66
|
-
// 是否显示气泡
|
|
67
|
-
const showIndicator = ref(false);
|
|
68
|
-
// 气泡位置
|
|
69
|
-
const indicatorTop = ref(0);
|
|
70
|
-
// 滚动位置
|
|
71
|
-
const scrollTop = ref(0);
|
|
72
|
-
// 当前实际滚动位置
|
|
73
|
-
let currentScrollTop = 0;
|
|
74
|
-
// 索引条位置信息
|
|
75
|
-
let indexBarRect = null;
|
|
76
|
-
// 各分组位置缓存
|
|
77
|
-
let groupPositions = {};
|
|
78
|
-
|
|
79
|
-
// 根据触摸位置计算当前字母
|
|
80
|
-
const getLetterByTouch = (touchY) => {
|
|
81
|
-
if (!indexBarRect || !props.indexList.length) return '';
|
|
82
|
-
const itemHeight = indexBarRect.height / props.indexList.length;
|
|
83
|
-
const relativeY = touchY - indexBarRect.top;
|
|
84
|
-
const index = Math.floor(relativeY / itemHeight);
|
|
85
|
-
if (index < 0) return props.indexList[0];
|
|
86
|
-
if (index >= props.indexList.length) return props.indexList[props.indexList.length - 1];
|
|
87
|
-
return props.indexList[index];
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
// 计算各分组位置
|
|
91
|
-
const calculateGroupPositions = () => {
|
|
92
|
-
groupPositions = {};
|
|
93
|
-
props.indexList.forEach(letter => {
|
|
94
|
-
const el = document.getElementById(`group-${letter}`);
|
|
95
|
-
if (el) {
|
|
96
|
-
groupPositions[letter] = el.offsetTop;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// 滚动到指定字母
|
|
102
|
-
const scrollToLetter = (letter) => {
|
|
103
|
-
// 确保位置已计算
|
|
104
|
-
if (!groupPositions[letter]) {
|
|
105
|
-
calculateGroupPositions();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const targetTop = groupPositions[letter];
|
|
109
|
-
if (targetTop !== undefined) {
|
|
110
|
-
// 需要设置一个不同的值才能触发滚动
|
|
111
|
-
scrollTop.value = targetTop + 0.1;
|
|
112
|
-
nextTick(() => {
|
|
113
|
-
scrollTop.value = targetTop;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// 滚动事件
|
|
119
|
-
const onScroll = (e) => {
|
|
120
|
-
currentScrollTop = e.detail.scrollTop;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// 更新选中字母
|
|
124
|
-
const updateLetter = (touchY) => {
|
|
125
|
-
// 更新气泡位置
|
|
126
|
-
indicatorTop.value = touchY;
|
|
127
|
-
|
|
128
|
-
const letter = getLetterByTouch(touchY);
|
|
129
|
-
if (letter) {
|
|
130
|
-
// 每次都更新 currentIndex,确保激活状态及时变化
|
|
131
|
-
currentIndex.value = letter;
|
|
132
|
-
scrollToLetter(letter);
|
|
133
|
-
emit('index-change', letter);
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
// 触摸开始
|
|
138
|
-
const onIndexTouchStart = (e) => {
|
|
139
|
-
showIndicator.value = true;
|
|
140
|
-
const touchY = e.touches[0].clientY;
|
|
141
|
-
indicatorTop.value = touchY;
|
|
142
|
-
|
|
143
|
-
// 获取索引条位置并更新字母
|
|
144
|
-
uni.createSelectorQuery()
|
|
145
|
-
.in(instance)
|
|
146
|
-
.select('.prism-index-bar')
|
|
147
|
-
.boundingClientRect((rect) => {
|
|
148
|
-
if (rect) {
|
|
149
|
-
indexBarRect = rect;
|
|
150
|
-
const letter = getLetterByTouch(touchY);
|
|
151
|
-
if (letter) {
|
|
152
|
-
currentIndex.value = letter;
|
|
153
|
-
scrollToLetter(letter);
|
|
154
|
-
emit('index-change', letter);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
.exec();
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// 触摸移动
|
|
162
|
-
const onIndexTouchMove = (e) => {
|
|
163
|
-
const touchY = e.touches[0].clientY;
|
|
164
|
-
if (indexBarRect) {
|
|
165
|
-
updateLetter(touchY);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
// 触摸结束
|
|
170
|
-
const onIndexTouchEnd = () => {
|
|
171
|
-
showIndicator.value = false;
|
|
172
|
-
};
|
|
173
|
-
</script>
|
|
174
|
-
|
|
175
|
-
<style lang="scss">
|
|
176
|
-
.prism-group-sticky-wrapper {
|
|
177
|
-
position: relative;
|
|
178
|
-
height: 100%;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.prism-group-sticky {
|
|
182
|
-
height: 100%;
|
|
183
|
-
|
|
184
|
-
// H5 环境下让 scroll-view 内部容器支持 sticky
|
|
185
|
-
:deep(.uni-scroll-view-content) {
|
|
186
|
-
height: auto !important;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// 分组索引头(吸顶)
|
|
190
|
-
:deep(.group-index) {
|
|
191
|
-
position: -webkit-sticky;
|
|
192
|
-
position: sticky;
|
|
193
|
-
top: -1px;
|
|
194
|
-
z-index: 10;
|
|
195
|
-
margin: 0;
|
|
196
|
-
padding: 12rpx 24rpx;
|
|
197
|
-
padding-top: calc(12rpx + 1px);
|
|
198
|
-
font-size: 26rpx;
|
|
199
|
-
font-weight: 600;
|
|
200
|
-
color: var(--prism-primary-color, #3478F6);
|
|
201
|
-
background: var(--prism-bg-color-page, #F7F8FA);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.dark-mode & :deep(.group-index) {
|
|
205
|
-
background: var(--prism-bg-color-page, #121212);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 分组内容项
|
|
209
|
-
:deep(.group-item) {
|
|
210
|
-
display: flex;
|
|
211
|
-
align-items: center;
|
|
212
|
-
min-height: 88rpx;
|
|
213
|
-
padding: 24rpx 32rpx;
|
|
214
|
-
background: var(--prism-bg-color-card, #FFFFFF);
|
|
215
|
-
border-bottom: 1rpx solid var(--prism-border-color-light, #F2F3F5);
|
|
216
|
-
font-size: 28rpx;
|
|
217
|
-
color: var(--prism-text-primary, #1D2129);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
.dark-mode & :deep(.group-item) {
|
|
221
|
-
background: var(--prism-bg-color-card, #242424);
|
|
222
|
-
border-bottom-color: var(--prism-border-color-light, #2D2D2D);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// 每个分组的最后一个 item(后面紧跟 group-index 或者是最后一个)
|
|
226
|
-
:deep(.group-item:has(+ .group-index)),
|
|
227
|
-
:deep(.group-item:last-child) {
|
|
228
|
-
border-radius: 0 0 16rpx 16rpx;
|
|
229
|
-
border-bottom: none;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
:deep(.group-item:active) {
|
|
233
|
-
background: var(--prism-bg-color, #F2F2F2);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
.dark-mode & :deep(.group-item:active) {
|
|
237
|
-
background: var(--prism-bg-color, #1A1A1A);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// 第一个 group-item(紧跟在 group-index 后面)- 顶部圆角
|
|
241
|
-
:deep(.group-index + .group-item) {
|
|
242
|
-
border-radius: 16rpx 16rpx 0 0;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// 分组只有一个 item 时 - 全圆角
|
|
246
|
-
:deep(.group-index + .group-item:has(+ .group-index)),
|
|
247
|
-
:deep(.group-index + .group-item:last-child) {
|
|
248
|
-
border-radius: 16rpx;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// 头像(可选)
|
|
252
|
-
.group-avatar {
|
|
253
|
-
width: 80rpx;
|
|
254
|
-
height: 80rpx;
|
|
255
|
-
border-radius: 50%;
|
|
256
|
-
margin-right: 24rpx;
|
|
257
|
-
background: var(--prism-primary-light, #EBF2FF);
|
|
258
|
-
display: flex;
|
|
259
|
-
align-items: center;
|
|
260
|
-
justify-content: center;
|
|
261
|
-
font-size: 28rpx;
|
|
262
|
-
font-weight: 600;
|
|
263
|
-
color: var(--prism-primary-color, #3478F6);
|
|
264
|
-
flex-shrink: 0;
|
|
265
|
-
|
|
266
|
-
.dark-mode & {
|
|
267
|
-
background: rgba(52, 120, 246, 0.15);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
// 信息区(可选)
|
|
272
|
-
.group-info {
|
|
273
|
-
flex: 1;
|
|
274
|
-
min-width: 0;
|
|
275
|
-
|
|
276
|
-
.group-title {
|
|
277
|
-
font-size: 30rpx;
|
|
278
|
-
font-weight: 500;
|
|
279
|
-
color: var(--prism-text-primary, #1D2129);
|
|
280
|
-
margin-bottom: 4rpx;
|
|
281
|
-
|
|
282
|
-
.dark-mode & {
|
|
283
|
-
color: var(--prism-text-primary, #E5E6EB);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
.group-desc {
|
|
288
|
-
font-size: 24rpx;
|
|
289
|
-
color: var(--prism-text-secondary, #86909C);
|
|
290
|
-
overflow: hidden;
|
|
291
|
-
text-overflow: ellipsis;
|
|
292
|
-
white-space: nowrap;
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
// 右侧索引条
|
|
298
|
-
.prism-index-bar {
|
|
299
|
-
position: absolute;
|
|
300
|
-
right: 0;
|
|
301
|
-
top: 50%;
|
|
302
|
-
transform: translateY(-50%);
|
|
303
|
-
z-index: 100;
|
|
304
|
-
display: flex;
|
|
305
|
-
flex-direction: column;
|
|
306
|
-
align-items: center;
|
|
307
|
-
padding: 12rpx 16rpx 12rpx 24rpx;
|
|
308
|
-
background: rgba(255, 255, 255, 0.02);
|
|
309
|
-
border-radius: 20rpx 0 0 20rpx;
|
|
310
|
-
-webkit-backdrop-filter: blur(8px);
|
|
311
|
-
backdrop-filter: blur(8px);
|
|
312
|
-
|
|
313
|
-
.index-item {
|
|
314
|
-
width: 36rpx;
|
|
315
|
-
height: 36rpx;
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
justify-content: center;
|
|
319
|
-
font-size: 22rpx;
|
|
320
|
-
color: var(--prism-text-primary, #1D2129);
|
|
321
|
-
font-weight: 500;
|
|
322
|
-
background: transparent;
|
|
323
|
-
|
|
324
|
-
&:active,
|
|
325
|
-
&.active {
|
|
326
|
-
color: var(--prism-primary-color, #3478F6);
|
|
327
|
-
font-weight: 600;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
// 气泡提示
|
|
333
|
-
.index-indicator {
|
|
334
|
-
position: fixed;
|
|
335
|
-
right: 120rpx;
|
|
336
|
-
width: 100rpx;
|
|
337
|
-
height: 100rpx;
|
|
338
|
-
margin-top: -50rpx;
|
|
339
|
-
border-radius: 50%;
|
|
340
|
-
background: rgba(52, 120, 246, 0.8);
|
|
341
|
-
-webkit-backdrop-filter: blur(10px);
|
|
342
|
-
backdrop-filter: blur(10px);
|
|
343
|
-
color: #FFFFFF;
|
|
344
|
-
font-size: 48rpx;
|
|
345
|
-
font-weight: 600;
|
|
346
|
-
display: flex;
|
|
347
|
-
align-items: center;
|
|
348
|
-
justify-content: center;
|
|
349
|
-
box-shadow: 0 8rpx 32rpx rgba(52, 120, 246, 0.3);
|
|
350
|
-
z-index: 1000;
|
|
351
|
-
}
|
|
352
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="prism-group-sticky-wrapper" :style="{ height: height }">
|
|
3
|
+
<scroll-view
|
|
4
|
+
class="prism-group-sticky"
|
|
5
|
+
scroll-y
|
|
6
|
+
:scroll-top="scrollTop"
|
|
7
|
+
:enhanced="true"
|
|
8
|
+
:show-scrollbar="false"
|
|
9
|
+
style="height: 100%"
|
|
10
|
+
@scroll="onScroll"
|
|
11
|
+
>
|
|
12
|
+
<slot></slot>
|
|
13
|
+
</scroll-view>
|
|
14
|
+
|
|
15
|
+
<!-- 右侧索引条 -->
|
|
16
|
+
<view
|
|
17
|
+
v-if="showIndexBar && indexList.length"
|
|
18
|
+
class="prism-index-bar"
|
|
19
|
+
@touchstart="onIndexTouchStart"
|
|
20
|
+
@touchmove.stop.prevent="onIndexTouchMove"
|
|
21
|
+
@touchend="onIndexTouchEnd"
|
|
22
|
+
>
|
|
23
|
+
<view
|
|
24
|
+
v-for="item in indexList"
|
|
25
|
+
:key="item"
|
|
26
|
+
class="index-item"
|
|
27
|
+
:class="{ active: currentIndex === item }"
|
|
28
|
+
>{{ item }}</view>
|
|
29
|
+
</view>
|
|
30
|
+
|
|
31
|
+
<!-- 气泡提示(移到索引条外部) -->
|
|
32
|
+
<view
|
|
33
|
+
v-if="showIndicator"
|
|
34
|
+
class="index-indicator"
|
|
35
|
+
:style="{ top: indicatorTop + 'px' }"
|
|
36
|
+
>{{ currentIndex }}</view>
|
|
37
|
+
</view>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup>
|
|
41
|
+
import { ref, nextTick, getCurrentInstance } from 'vue';
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
// 索引列表
|
|
45
|
+
indexList: {
|
|
46
|
+
type: Array,
|
|
47
|
+
default: () => []
|
|
48
|
+
},
|
|
49
|
+
// 是否显示索引条
|
|
50
|
+
showIndexBar: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
// 容器高度
|
|
55
|
+
height: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: '100%'
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const emit = defineEmits(['index-change']);
|
|
62
|
+
const instance = getCurrentInstance();
|
|
63
|
+
|
|
64
|
+
// 当前选中的索引
|
|
65
|
+
const currentIndex = ref('');
|
|
66
|
+
// 是否显示气泡
|
|
67
|
+
const showIndicator = ref(false);
|
|
68
|
+
// 气泡位置
|
|
69
|
+
const indicatorTop = ref(0);
|
|
70
|
+
// 滚动位置
|
|
71
|
+
const scrollTop = ref(0);
|
|
72
|
+
// 当前实际滚动位置
|
|
73
|
+
let currentScrollTop = 0;
|
|
74
|
+
// 索引条位置信息
|
|
75
|
+
let indexBarRect = null;
|
|
76
|
+
// 各分组位置缓存
|
|
77
|
+
let groupPositions = {};
|
|
78
|
+
|
|
79
|
+
// 根据触摸位置计算当前字母
|
|
80
|
+
const getLetterByTouch = (touchY) => {
|
|
81
|
+
if (!indexBarRect || !props.indexList.length) return '';
|
|
82
|
+
const itemHeight = indexBarRect.height / props.indexList.length;
|
|
83
|
+
const relativeY = touchY - indexBarRect.top;
|
|
84
|
+
const index = Math.floor(relativeY / itemHeight);
|
|
85
|
+
if (index < 0) return props.indexList[0];
|
|
86
|
+
if (index >= props.indexList.length) return props.indexList[props.indexList.length - 1];
|
|
87
|
+
return props.indexList[index];
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// 计算各分组位置
|
|
91
|
+
const calculateGroupPositions = () => {
|
|
92
|
+
groupPositions = {};
|
|
93
|
+
props.indexList.forEach(letter => {
|
|
94
|
+
const el = document.getElementById(`group-${letter}`);
|
|
95
|
+
if (el) {
|
|
96
|
+
groupPositions[letter] = el.offsetTop;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// 滚动到指定字母
|
|
102
|
+
const scrollToLetter = (letter) => {
|
|
103
|
+
// 确保位置已计算
|
|
104
|
+
if (!groupPositions[letter]) {
|
|
105
|
+
calculateGroupPositions();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const targetTop = groupPositions[letter];
|
|
109
|
+
if (targetTop !== undefined) {
|
|
110
|
+
// 需要设置一个不同的值才能触发滚动
|
|
111
|
+
scrollTop.value = targetTop + 0.1;
|
|
112
|
+
nextTick(() => {
|
|
113
|
+
scrollTop.value = targetTop;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// 滚动事件
|
|
119
|
+
const onScroll = (e) => {
|
|
120
|
+
currentScrollTop = e.detail.scrollTop;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// 更新选中字母
|
|
124
|
+
const updateLetter = (touchY) => {
|
|
125
|
+
// 更新气泡位置
|
|
126
|
+
indicatorTop.value = touchY;
|
|
127
|
+
|
|
128
|
+
const letter = getLetterByTouch(touchY);
|
|
129
|
+
if (letter) {
|
|
130
|
+
// 每次都更新 currentIndex,确保激活状态及时变化
|
|
131
|
+
currentIndex.value = letter;
|
|
132
|
+
scrollToLetter(letter);
|
|
133
|
+
emit('index-change', letter);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// 触摸开始
|
|
138
|
+
const onIndexTouchStart = (e) => {
|
|
139
|
+
showIndicator.value = true;
|
|
140
|
+
const touchY = e.touches[0].clientY;
|
|
141
|
+
indicatorTop.value = touchY;
|
|
142
|
+
|
|
143
|
+
// 获取索引条位置并更新字母
|
|
144
|
+
uni.createSelectorQuery()
|
|
145
|
+
.in(instance)
|
|
146
|
+
.select('.prism-index-bar')
|
|
147
|
+
.boundingClientRect((rect) => {
|
|
148
|
+
if (rect) {
|
|
149
|
+
indexBarRect = rect;
|
|
150
|
+
const letter = getLetterByTouch(touchY);
|
|
151
|
+
if (letter) {
|
|
152
|
+
currentIndex.value = letter;
|
|
153
|
+
scrollToLetter(letter);
|
|
154
|
+
emit('index-change', letter);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
.exec();
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// 触摸移动
|
|
162
|
+
const onIndexTouchMove = (e) => {
|
|
163
|
+
const touchY = e.touches[0].clientY;
|
|
164
|
+
if (indexBarRect) {
|
|
165
|
+
updateLetter(touchY);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// 触摸结束
|
|
170
|
+
const onIndexTouchEnd = () => {
|
|
171
|
+
showIndicator.value = false;
|
|
172
|
+
};
|
|
173
|
+
</script>
|
|
174
|
+
|
|
175
|
+
<style lang="scss">
|
|
176
|
+
.prism-group-sticky-wrapper {
|
|
177
|
+
position: relative;
|
|
178
|
+
height: 100%;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.prism-group-sticky {
|
|
182
|
+
height: 100%;
|
|
183
|
+
|
|
184
|
+
// H5 环境下让 scroll-view 内部容器支持 sticky
|
|
185
|
+
:deep(.uni-scroll-view-content) {
|
|
186
|
+
height: auto !important;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// 分组索引头(吸顶)
|
|
190
|
+
:deep(.group-index) {
|
|
191
|
+
position: -webkit-sticky;
|
|
192
|
+
position: sticky;
|
|
193
|
+
top: -1px;
|
|
194
|
+
z-index: 10;
|
|
195
|
+
margin: 0;
|
|
196
|
+
padding: 12rpx 24rpx;
|
|
197
|
+
padding-top: calc(12rpx + 1px);
|
|
198
|
+
font-size: 26rpx;
|
|
199
|
+
font-weight: 600;
|
|
200
|
+
color: var(--prism-primary-color, #3478F6);
|
|
201
|
+
background: var(--prism-bg-color-page, #F7F8FA);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.dark-mode & :deep(.group-index) {
|
|
205
|
+
background: var(--prism-bg-color-page, #121212);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 分组内容项
|
|
209
|
+
:deep(.group-item) {
|
|
210
|
+
display: flex;
|
|
211
|
+
align-items: center;
|
|
212
|
+
min-height: 88rpx;
|
|
213
|
+
padding: 24rpx 32rpx;
|
|
214
|
+
background: var(--prism-bg-color-card, #FFFFFF);
|
|
215
|
+
border-bottom: 1rpx solid var(--prism-border-color-light, #F2F3F5);
|
|
216
|
+
font-size: 28rpx;
|
|
217
|
+
color: var(--prism-text-primary, #1D2129);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.dark-mode & :deep(.group-item) {
|
|
221
|
+
background: var(--prism-bg-color-card, #242424);
|
|
222
|
+
border-bottom-color: var(--prism-border-color-light, #2D2D2D);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// 每个分组的最后一个 item(后面紧跟 group-index 或者是最后一个)
|
|
226
|
+
:deep(.group-item:has(+ .group-index)),
|
|
227
|
+
:deep(.group-item:last-child) {
|
|
228
|
+
border-radius: 0 0 16rpx 16rpx;
|
|
229
|
+
border-bottom: none;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
:deep(.group-item:active) {
|
|
233
|
+
background: var(--prism-bg-color, #F2F2F2);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.dark-mode & :deep(.group-item:active) {
|
|
237
|
+
background: var(--prism-bg-color, #1A1A1A);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// 第一个 group-item(紧跟在 group-index 后面)- 顶部圆角
|
|
241
|
+
:deep(.group-index + .group-item) {
|
|
242
|
+
border-radius: 16rpx 16rpx 0 0;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 分组只有一个 item 时 - 全圆角
|
|
246
|
+
:deep(.group-index + .group-item:has(+ .group-index)),
|
|
247
|
+
:deep(.group-index + .group-item:last-child) {
|
|
248
|
+
border-radius: 16rpx;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 头像(可选)
|
|
252
|
+
.group-avatar {
|
|
253
|
+
width: 80rpx;
|
|
254
|
+
height: 80rpx;
|
|
255
|
+
border-radius: 50%;
|
|
256
|
+
margin-right: 24rpx;
|
|
257
|
+
background: var(--prism-primary-light, #EBF2FF);
|
|
258
|
+
display: flex;
|
|
259
|
+
align-items: center;
|
|
260
|
+
justify-content: center;
|
|
261
|
+
font-size: 28rpx;
|
|
262
|
+
font-weight: 600;
|
|
263
|
+
color: var(--prism-primary-color, #3478F6);
|
|
264
|
+
flex-shrink: 0;
|
|
265
|
+
|
|
266
|
+
.dark-mode & {
|
|
267
|
+
background: rgba(52, 120, 246, 0.15);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// 信息区(可选)
|
|
272
|
+
.group-info {
|
|
273
|
+
flex: 1;
|
|
274
|
+
min-width: 0;
|
|
275
|
+
|
|
276
|
+
.group-title {
|
|
277
|
+
font-size: 30rpx;
|
|
278
|
+
font-weight: 500;
|
|
279
|
+
color: var(--prism-text-primary, #1D2129);
|
|
280
|
+
margin-bottom: 4rpx;
|
|
281
|
+
|
|
282
|
+
.dark-mode & {
|
|
283
|
+
color: var(--prism-text-primary, #E5E6EB);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.group-desc {
|
|
288
|
+
font-size: 24rpx;
|
|
289
|
+
color: var(--prism-text-secondary, #86909C);
|
|
290
|
+
overflow: hidden;
|
|
291
|
+
text-overflow: ellipsis;
|
|
292
|
+
white-space: nowrap;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// 右侧索引条
|
|
298
|
+
.prism-index-bar {
|
|
299
|
+
position: absolute;
|
|
300
|
+
right: 0;
|
|
301
|
+
top: 50%;
|
|
302
|
+
transform: translateY(-50%);
|
|
303
|
+
z-index: 100;
|
|
304
|
+
display: flex;
|
|
305
|
+
flex-direction: column;
|
|
306
|
+
align-items: center;
|
|
307
|
+
padding: 12rpx 16rpx 12rpx 24rpx;
|
|
308
|
+
background: rgba(255, 255, 255, 0.02);
|
|
309
|
+
border-radius: 20rpx 0 0 20rpx;
|
|
310
|
+
-webkit-backdrop-filter: blur(8px);
|
|
311
|
+
backdrop-filter: blur(8px);
|
|
312
|
+
|
|
313
|
+
.index-item {
|
|
314
|
+
width: 36rpx;
|
|
315
|
+
height: 36rpx;
|
|
316
|
+
display: flex;
|
|
317
|
+
align-items: center;
|
|
318
|
+
justify-content: center;
|
|
319
|
+
font-size: 22rpx;
|
|
320
|
+
color: var(--prism-text-primary, #1D2129);
|
|
321
|
+
font-weight: 500;
|
|
322
|
+
background: transparent;
|
|
323
|
+
|
|
324
|
+
&:active,
|
|
325
|
+
&.active {
|
|
326
|
+
color: var(--prism-primary-color, #3478F6);
|
|
327
|
+
font-weight: 600;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// 气泡提示
|
|
333
|
+
.index-indicator {
|
|
334
|
+
position: fixed;
|
|
335
|
+
right: 120rpx;
|
|
336
|
+
width: 100rpx;
|
|
337
|
+
height: 100rpx;
|
|
338
|
+
margin-top: -50rpx;
|
|
339
|
+
border-radius: 50%;
|
|
340
|
+
background: rgba(52, 120, 246, 0.8);
|
|
341
|
+
-webkit-backdrop-filter: blur(10px);
|
|
342
|
+
backdrop-filter: blur(10px);
|
|
343
|
+
color: #FFFFFF;
|
|
344
|
+
font-size: 48rpx;
|
|
345
|
+
font-weight: 600;
|
|
346
|
+
display: flex;
|
|
347
|
+
align-items: center;
|
|
348
|
+
justify-content: center;
|
|
349
|
+
box-shadow: 0 8rpx 32rpx rgba(52, 120, 246, 0.3);
|
|
350
|
+
z-index: 1000;
|
|
351
|
+
}
|
|
352
|
+
</style>
|