uview-plus 3.4.67 → 3.4.69

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/changelog.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 3.4.69(2025-08-04)
2
+ feat: pull-refresh下拉刷新新增上拉加载特性
3
+
4
+ ## 3.4.68(2025-08-03)
5
+ feat: 新增pull-refresh下拉刷新组件
6
+
1
7
  ## 3.4.67(2025-08-02)
2
8
  feat: number-box支持disabledBgColor参数
3
9
 
@@ -0,0 +1,350 @@
1
+ <template>
2
+ <view
3
+ class="u-pull-refresh"
4
+ @touchstart="onTouchStart"
5
+ @touchmove="onTouchMove"
6
+ @touchend="onTouchEnd"
7
+ @touchcancel="onTouchEnd"
8
+ >
9
+ <!-- 下拉刷新区域 -->
10
+ <view
11
+ class="refresh-area"
12
+ :style="{ height: refreshDistance + 'px' }"
13
+ :class="{ refreshing: isRefreshing }"
14
+ >
15
+ <!-- 不同状态的插槽 -->
16
+ <slot
17
+ v-if="refreshStatus === 'pull'"
18
+ name="pull"
19
+ :distance="refreshDistance"
20
+ :threshold="threshold"
21
+ >
22
+ <!-- 默认下拉状态 -->
23
+ <view class="refresh-content">
24
+ <view class="refresh-indicator">
25
+ <view class="arrow"></view>
26
+ </view>
27
+ <text class="refresh-text">下拉刷新</text>
28
+ </view>
29
+ </slot>
30
+
31
+ <slot
32
+ v-else-if="refreshStatus === 'release'"
33
+ name="release"
34
+ :distance="refreshDistance"
35
+ :threshold="threshold"
36
+ >
37
+ <!-- 默认释放状态 -->
38
+ <view class="refresh-content">
39
+ <view class="refresh-indicator">
40
+ <view class="arrow rotate"></view>
41
+ </view>
42
+ <text class="refresh-text">释放刷新</text>
43
+ </view>
44
+ </slot>
45
+
46
+ <slot
47
+ v-else-if="refreshStatus === 'refreshing'"
48
+ name="refreshing"
49
+ >
50
+ <!-- 默认刷新中状态 -->
51
+ <view class="refresh-content">
52
+ <view class="refresh-indicator">
53
+ <view class="spinner"></view>
54
+ </view>
55
+ <text class="refresh-text">正在刷新...</text>
56
+ </view>
57
+ </slot>
58
+ </view>
59
+
60
+ <!-- 内容区域 -->
61
+ <view
62
+ class="refresh-content-wrapper"
63
+ :style="{ transform: `translateY(${contentTranslateY}px)` }"
64
+ >
65
+ <scroll-view
66
+ v-if="useScrollView"
67
+ class="scroll-wrapper"
68
+ :scroll-y="true"
69
+ :enable-back-to-top="enableBackToTop"
70
+ :scroll-top="scrollTop"
71
+ :lower-threshold="lowerThreshold"
72
+ @scroll="handleScroll"
73
+ @scrolltolower="handleScrollToLower"
74
+ >
75
+ <slot></slot>
76
+
77
+ <!-- 使用 u-loadmore 组件实现上拉加载更多 -->
78
+ <u-loadmore
79
+ v-if="showLoadmore"
80
+ v-bind="loadmoreProps"
81
+ />
82
+ </scroll-view>
83
+
84
+ <view v-else>
85
+ <slot></slot>
86
+
87
+ <!-- 使用 u-loadmore 组件实现上拉加载更多 -->
88
+ <u-loadmore
89
+ v-if="showLoadmore"
90
+ v-bind="loadmoreProps"
91
+ />
92
+ </view>
93
+ </view>
94
+ </view>
95
+ </template>
96
+
97
+ <script>
98
+ export default {
99
+ name: 'u-pull-refresh',
100
+ props: {
101
+ // 是否正在刷新
102
+ refreshing: {
103
+ type: Boolean,
104
+ default: false
105
+ },
106
+ // 下拉刷新阈值
107
+ threshold: {
108
+ type: Number,
109
+ default: 50
110
+ },
111
+ // 阻尼系数
112
+ damping: {
113
+ type: Number,
114
+ default: 0.4
115
+ },
116
+ // 最大下拉距离
117
+ maxDistance: {
118
+ type: Number,
119
+ default: 100
120
+ },
121
+ // 是否显示加载更多
122
+ showLoadmore: {
123
+ type: Boolean,
124
+ default: false
125
+ },
126
+ // u-loadmore 组件的 props 配置
127
+ loadmoreProps: {
128
+ type: Object,
129
+ default: () => ({
130
+ status: 'loadmore',
131
+ loadmoreText: '加载更多',
132
+ loadingText: '正在加载...',
133
+ nomoreText: '没有更多了'
134
+ })
135
+ },
136
+ // 是否使用 scroll-view 包装内容
137
+ useScrollView: {
138
+ type: Boolean,
139
+ default: true
140
+ },
141
+ // scroll-view 相关属性
142
+ enableBackToTop: {
143
+ type: Boolean,
144
+ default: false
145
+ },
146
+ lowerThreshold: {
147
+ type: [Number, String],
148
+ default: 50
149
+ },
150
+ scrollTop: {
151
+ type: [Number, String],
152
+ default: 0
153
+ }
154
+ },
155
+ data() {
156
+ return {
157
+ // 下拉刷新相关
158
+ isRefreshing: false,
159
+ refreshStatus: 'pull', // pull, release, refreshing
160
+ refreshDistance: 0,
161
+ startY: 0,
162
+ currentY: 0,
163
+ touching: false,
164
+
165
+ // 动画相关
166
+ contentTranslateY: 0
167
+ }
168
+ },
169
+ emits: ['refresh', 'loadmore', 'scroll'],
170
+ watch: {
171
+ refreshing: {
172
+ handler(newVal) {
173
+ if (!newVal) {
174
+ this.finishRefresh()
175
+ } else {
176
+ this.startRefresh()
177
+ }
178
+ }
179
+ }
180
+ },
181
+ methods: {
182
+ // 触摸开始
183
+ onTouchStart(e) {
184
+ if (this.isRefreshing) return
185
+
186
+ this.touching = true
187
+ this.startY = e.touches[0].pageY
188
+ this.currentY = this.startY
189
+ this.refreshStatus = 'pull'
190
+ },
191
+
192
+ // 触摸移动
193
+ onTouchMove(e) {
194
+ if (!this.touching || this.isRefreshing) return
195
+
196
+ this.currentY = e.touches[0].pageY
197
+ const diff = this.currentY - this.startY
198
+
199
+ // 只有在顶部且下拉时才触发下拉刷新
200
+ if (diff > 0 && this.isScrollViewAtTop()) {
201
+ this.refreshDistance = Math.min(diff * this.damping, this.maxDistance)
202
+ this.contentTranslateY = this.refreshDistance
203
+
204
+ // 更新状态
205
+ if (this.refreshDistance >= this.threshold) {
206
+ this.refreshStatus = 'release'
207
+ } else {
208
+ this.refreshStatus = 'pull'
209
+ }
210
+ }
211
+ },
212
+
213
+ // 触摸结束
214
+ onTouchEnd() {
215
+ if (!this.touching) return
216
+
217
+ this.touching = false
218
+
219
+ if (this.refreshDistance >= this.threshold && !this.isRefreshing) {
220
+ // 触发刷新
221
+ this.startRefresh()
222
+ this.$emit('refresh')
223
+ } else {
224
+ // 回弹
225
+ this.resetRefresh()
226
+ }
227
+ },
228
+
229
+ // 开始刷新
230
+ startRefresh() {
231
+ this.isRefreshing = true
232
+ this.refreshStatus = 'refreshing'
233
+ this.refreshDistance = this.threshold
234
+ this.contentTranslateY = this.threshold
235
+ },
236
+
237
+ // 完成刷新
238
+ finishRefresh() {
239
+ this.isRefreshing = false
240
+ this.refreshStatus = 'pull'
241
+ this.resetRefresh()
242
+ },
243
+
244
+ // 重置刷新状态
245
+ resetRefresh() {
246
+ this.refreshDistance = 0
247
+ this.contentTranslateY = 0
248
+ },
249
+
250
+ // 检查 scroll-view 是否在顶部
251
+ isScrollViewAtTop() {
252
+ // 这里可以更精确地判断,但简单起见直接返回 true
253
+ // 实际项目中可能需要通过 scroll 事件获取 scrollTop 判断
254
+ return true
255
+ },
256
+
257
+ // 处理滚动事件
258
+ handleScroll(e) {
259
+ this.$emit('scroll', e)
260
+ },
261
+
262
+ // 处理滚动到底部事件
263
+ handleScrollToLower(e) {
264
+ // 只有当 loadmore 状态为 loadmore 时才触发
265
+ if (this.showLoadmore && this.loadmoreProps.status === 'loadmore') {
266
+ this.$emit('loadmore')
267
+ }
268
+ }
269
+ }
270
+ }
271
+ </script>
272
+
273
+ <style scoped lang="scss">
274
+ .u-pull-refresh {
275
+ position: relative;
276
+ height: 100%;
277
+ overflow: hidden;
278
+ }
279
+
280
+ .refresh-area {
281
+ position: absolute;
282
+ left: 0;
283
+ right: 0;
284
+ top: 0;
285
+ display: flex;
286
+ align-items: flex-end;
287
+ justify-content: center;
288
+ overflow: hidden;
289
+ transition: height 0.2s ease-out;
290
+ }
291
+
292
+ .refresh-content-wrapper {
293
+ height: 100%;
294
+ transition: transform 0.2s ease-out;
295
+ }
296
+
297
+ .scroll-wrapper {
298
+ height: 100%;
299
+ }
300
+
301
+ .refresh-content {
302
+ display: flex;
303
+ flex-direction: column;
304
+ align-items: center;
305
+ justify-content: center;
306
+ width: 100%;
307
+ padding-bottom: 10px;
308
+ }
309
+
310
+ .refresh-indicator {
311
+ width: 24px;
312
+ height: 24px;
313
+ display: flex;
314
+ align-items: center;
315
+ justify-content: center;
316
+ margin-bottom: 8px;
317
+ }
318
+
319
+ .arrow {
320
+ width: 12px;
321
+ height: 12px;
322
+ border-left: 2px solid #666;
323
+ border-bottom: 2px solid #666;
324
+ transform: rotate(-45deg);
325
+ transition: transform 0.2s;
326
+ }
327
+
328
+ .arrow.rotate {
329
+ transform: rotate(135deg);
330
+ }
331
+
332
+ .spinner {
333
+ width: 16px;
334
+ height: 16px;
335
+ border: 2px solid #f3f3f3;
336
+ border-top: 2px solid #666;
337
+ border-radius: 50%;
338
+ animation: spin 1s linear infinite;
339
+ }
340
+
341
+ @keyframes spin {
342
+ 0% { transform: rotate(0deg); }
343
+ 100% { transform: rotate(360deg); }
344
+ }
345
+
346
+ .refresh-text {
347
+ font-size: 14px;
348
+ color: #666;
349
+ }
350
+ </style>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙移动组件库。",
5
- "version": "3.4.67",
5
+ "version": "3.4.69",
6
6
  "description": "零云®uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水。",
7
7
  "keywords": [
8
8
  "uview",