hw-cus-ui 1.1.0 → 1.1.1

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.
Files changed (56) hide show
  1. package/HwTabs/HwTabs.vue +332 -0
  2. package/HwTabs/index.ts +10 -0
  3. package/HwTabs/props.js +100 -0
  4. package/HwTabs/readme.md +276 -0
  5. package/HwTabs/utils.js +110 -0
  6. package/index.d.ts +3 -1
  7. package/index.ts +14 -2
  8. package/package.json +1 -1
  9. package/z-paging/changelog.md +51 -0
  10. package/z-paging/components/z-paging/components/z-paging-load-more.vue +182 -0
  11. package/z-paging/components/z-paging/components/z-paging-refresh.vue +214 -0
  12. package/z-paging/components/z-paging/config/index.js +3 -0
  13. package/z-paging/components/z-paging/css/z-paging-main.css +241 -0
  14. package/z-paging/components/z-paging/css/z-paging-static.css +50 -0
  15. package/z-paging/components/z-paging/i18n/en.json +23 -0
  16. package/z-paging/components/z-paging/i18n/index.js +8 -0
  17. package/z-paging/components/z-paging/i18n/zh-Hans.json +23 -0
  18. package/z-paging/components/z-paging/i18n/zh-Hant.json +23 -0
  19. package/z-paging/components/z-paging/js/hooks/useZPaging.js +25 -0
  20. package/z-paging/components/z-paging/js/hooks/useZPagingComp.js +25 -0
  21. package/z-paging/components/z-paging/js/modules/back-to-top.js +125 -0
  22. package/z-paging/components/z-paging/js/modules/chat-record-mode.js +153 -0
  23. package/z-paging/components/z-paging/js/modules/common-layout.js +152 -0
  24. package/z-paging/components/z-paging/js/modules/data-handle.js +744 -0
  25. package/z-paging/components/z-paging/js/modules/empty.js +144 -0
  26. package/z-paging/components/z-paging/js/modules/i18n.js +113 -0
  27. package/z-paging/components/z-paging/js/modules/load-more.js +374 -0
  28. package/z-paging/components/z-paging/js/modules/loading.js +95 -0
  29. package/z-paging/components/z-paging/js/modules/nvue.js +299 -0
  30. package/z-paging/components/z-paging/js/modules/refresher.js +890 -0
  31. package/z-paging/components/z-paging/js/modules/scroller.js +605 -0
  32. package/z-paging/components/z-paging/js/modules/virtual-list.js +539 -0
  33. package/z-paging/components/z-paging/js/z-paging-constant.js +19 -0
  34. package/z-paging/components/z-paging/js/z-paging-enum.js +45 -0
  35. package/z-paging/components/z-paging/js/z-paging-interceptor.js +97 -0
  36. package/z-paging/components/z-paging/js/z-paging-main.js +537 -0
  37. package/z-paging/components/z-paging/js/z-paging-mixin.js +22 -0
  38. package/z-paging/components/z-paging/js/z-paging-static.js +13 -0
  39. package/z-paging/components/z-paging/js/z-paging-utils.js +322 -0
  40. package/z-paging/components/z-paging/wxs/z-paging-renderjs.js +67 -0
  41. package/z-paging/components/z-paging/wxs/z-paging-wxs.wxs +382 -0
  42. package/z-paging/components/z-paging/z-paging.vue +655 -0
  43. package/z-paging/components/z-paging-cell/z-paging-cell.vue +47 -0
  44. package/z-paging/components/z-paging-empty-view/z-paging-empty-view.vue +209 -0
  45. package/z-paging/components/z-paging-swiper/z-paging-swiper.vue +176 -0
  46. package/z-paging/components/z-paging-swiper-item/z-paging-swiper-item.vue +160 -0
  47. package/z-paging/package.json +89 -0
  48. package/z-paging/readme.md +57 -0
  49. package/z-paging/types/comps/_common.d.ts +9 -0
  50. package/z-paging/types/comps/z-paging-cell.d.ts +29 -0
  51. package/z-paging/types/comps/z-paging-empty-view.d.ts +95 -0
  52. package/z-paging/types/comps/z-paging-swiper-item.d.ts +95 -0
  53. package/z-paging/types/comps/z-paging-swiper.d.ts +89 -0
  54. package/z-paging/types/comps/z-paging.d.ts +2131 -0
  55. package/z-paging/types/comps.d.ts +11 -0
  56. package/z-paging/types/index.d.ts +24 -0
@@ -0,0 +1,332 @@
1
+ <template>
2
+ <view class="v-tabs">
3
+ <scroll-view
4
+ :id="getDomId"
5
+ :scroll-x="scroll"
6
+ :scroll-left="scroll ? scrollLeft : 0"
7
+ :scroll-with-animation="scroll"
8
+ :style="{
9
+ position: fixed ? 'fixed' : 'relative',
10
+ zIndex,
11
+ width: '100%'
12
+ }"
13
+ >
14
+ <view
15
+ class="v-tabs__container"
16
+ :style="{
17
+ display: scroll ? 'inline-flex' : 'flex',
18
+ whiteSpace: scroll ? 'nowrap' : 'normal',
19
+ background: bgColor,
20
+ height,
21
+ padding
22
+ }"
23
+ >
24
+ <view
25
+ :class="[
26
+ 'v-tabs__container-item',
27
+ { disabled: !!v.disabled },
28
+ { active: current == i }
29
+ ]"
30
+ v-for="(v, i) in tabs"
31
+ :key="i"
32
+ :style="{
33
+ color: current == i ? activeColor : color,
34
+ fontSize: current == i ? fontSize : fontSize,
35
+ fontWeight: bold && current == i ? 'bold' : '',
36
+ justifyContent: !scroll ? 'center' : '',
37
+ flex: scroll ? '' : 1,
38
+ padding: paddingItem
39
+ }"
40
+ @click="change(i)"
41
+ >
42
+ <slot :row="v" :index="i">{{ field ? v[field] : v }}</slot>
43
+ <view class="num" v-if="v.num && v.num > 0">{{ v.num }}</view>
44
+ </view>
45
+ <template v-if="!!tabs.length">
46
+ <view
47
+ v-if="!pills"
48
+ :class="[
49
+ 'v-tabs__container-line',
50
+ { animation: lineAnimation }
51
+ ]"
52
+ :style="{
53
+ background: lineColor,
54
+ width: lineWidth + 'px',
55
+ height: lineHeight,
56
+ borderRadius: lineRadius,
57
+ transform: `translate3d(${lineLeft}px, 0, 0)`
58
+ }"
59
+ />
60
+ <view
61
+ v-else
62
+ :class="[
63
+ 'v-tabs__container-pills',
64
+ { animation: lineAnimation }
65
+ ]"
66
+ :style="{
67
+ background: pillsColor,
68
+ borderRadius: pillsBorderRadius,
69
+ width: currentWidth + 'px',
70
+ transform: `translate3d(${pillsLeft}px, 0, 0)`,
71
+ height
72
+ }"
73
+ />
74
+ </template>
75
+ </view>
76
+ </scroll-view>
77
+ <!-- fixed 的站位高度 -->
78
+ <view
79
+ class="v-tabs__placeholder"
80
+ :style="{ height: fixed ? height : '0', padding }"
81
+ ></view>
82
+ </view>
83
+ </template>
84
+
85
+ <script>
86
+ import { startMicroTask, throttle } from './utils'
87
+ import props from './props'
88
+ /**
89
+ * v-tabs
90
+ * @property {Number} value 选中的下标
91
+ * @property {Array} tabs tabs 列表
92
+ * @property {String} bgColor = '#fff' 背景颜色
93
+ * @property {String} color = '#333' 默认颜色
94
+ * @property {String} activeColor = '#2979ff' 选中文字颜色
95
+ * @property {String} fontSize = '28rpx' 默认文字大小
96
+ * @property {String} activeFontSize = '28rpx' 选中文字大小
97
+ * @property {Boolean} bold = [true | false] 选中文字是否加粗
98
+ * @property {Boolean} scroll = [true | false] 是否滚动
99
+ * @property {String} height = '60rpx' tab 的高度
100
+ * @property {String} lineHeight = '10rpx' 下划线的高度
101
+ * @property {String} lineColor = '#2979ff' 下划线的颜色
102
+ * @property {Number} lineScale = 0.5 下划线的宽度缩放比例
103
+ * @property {String} lineRadius = '10rpx' 下划线圆角
104
+ * @property {Boolean} pills = [true | false] 是否胶囊样式
105
+ * @property {String} pillsColor = '#2979ff' 胶囊背景色
106
+ * @property {String} pillsBorderRadius = '10rpx' 胶囊圆角大小
107
+ * @property {String} field 如果是对象,显示的键名
108
+ * @property {Boolean} fixed = [true | false] 是否固定
109
+ * @property {String} paddingItem = '0 22rpx' 选项的边距
110
+ * @property {Boolean} lineAnimation = [true | false] 下划线是否有动画
111
+ * @property {Number} zIndex = 1993 默认层级
112
+ *
113
+ * @event {Function(current)} change 改变标签触发
114
+ */
115
+ export default {
116
+ name: 'VTabs',
117
+ props,
118
+ // #ifdef VUE3
119
+ emits: ['update:modelValue', 'change'],
120
+ // #endif
121
+ data() {
122
+ return {
123
+ lineWidth: 30,
124
+ currentWidth: 0, // 当前选项的宽度
125
+ lineLeft: 0, // 滑块距离左侧的位置
126
+ pillsLeft: 0, // 胶囊距离左侧的位置
127
+ scrollLeft: 0, // 距离左边的位置
128
+ container: { width: 0, height: 0, left: 0, right: 0 }, // 容器的宽高,左右距离
129
+ current: 0, // 当前选中项
130
+ scrollWidth: 0 // 可以滚动的宽度
131
+ }
132
+ },
133
+ computed: {
134
+ getDomId() {
135
+ const len = 16
136
+ const $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678' /****默认去掉了容易混淆的字符oOLl,9gq,Vv,Uu,I1****/
137
+ const maxPos = $chars.length
138
+ let pwd = ''
139
+ for (let i = 0; i < len; i++) {
140
+ pwd += $chars.charAt(Math.floor(Math.random() * maxPos))
141
+ }
142
+ return `xfjpeter_${pwd}`
143
+ }
144
+ },
145
+ watch: {
146
+ // #ifdef VUE3
147
+ modelValue: {
148
+ // #endif
149
+ // #ifdef VUE2
150
+ value: {
151
+ // #endif
152
+ immediate: true,
153
+ handler(newVal) {
154
+ this.current = newVal > -1 && newVal < this.tabs.length ? newVal : 0
155
+ this.$nextTick(this.update)
156
+ }
157
+ }
158
+ },
159
+ methods: {
160
+ // 切换事件
161
+ change: throttle(function(index) {
162
+ const isDisabled = !!this.tabs[index].disabled
163
+ if (this.current !== index && !isDisabled) {
164
+ this.current = index
165
+ // #ifdef VUE3
166
+ this.$emit('update:modelValue', index)
167
+ // #endif
168
+ // #ifdef VUE2
169
+ this.$emit('input', index)
170
+ // #endif
171
+ this.$emit('change', index)
172
+ }
173
+ }, 300),
174
+ createQueryHandler() {
175
+ let query
176
+ // #ifndef MP-ALIPAY
177
+ query = uni.createSelectorQuery().in(this)
178
+ // #endif
179
+ // #ifdef MP-ALIPAY
180
+ query = uni.createSelectorQuery()
181
+ // #endif
182
+
183
+ return query
184
+ },
185
+ update() {
186
+ const _this = this
187
+ startMicroTask(() => {
188
+ // 没有列表的时候,不执行
189
+ if (!this.tabs.length) return
190
+ _this
191
+ .createQueryHandler()
192
+ .select(`#${this.getDomId}`)
193
+ .boundingClientRect(data => {
194
+ const { width, height, left, right } = data || {}
195
+ // 获取容器的相关属性
196
+ this.container = { width, height, left, right: right - width }
197
+ _this.calcScrollWidth()
198
+ _this.setScrollLeft()
199
+ _this.setLine()
200
+ })
201
+ .exec()
202
+ })
203
+ },
204
+ // 计算可以滚动的宽度
205
+ calcScrollWidth(callback) {
206
+ const view = this.createQueryHandler().select(`#${this.getDomId}`)
207
+ view.fields({ scrollOffset: true })
208
+ view
209
+ .scrollOffset(res => {
210
+ if (typeof callback === 'function') {
211
+ callback(res)
212
+ } else {
213
+ // 获取滚动条的宽度
214
+ this.scrollWidth = res.scrollWidth
215
+ }
216
+ })
217
+ .exec()
218
+ },
219
+ // 设置滚动条滚动的进度
220
+ setScrollLeft() {
221
+ this.calcScrollWidth(res => {
222
+ // 动态读取 scrollLeft
223
+ let scrollLeft = res.scrollLeft
224
+ this.createQueryHandler()
225
+ .select(`#${this.getDomId} .v-tabs__container-item.active`)
226
+ .boundingClientRect(data => {
227
+ if (!data) return
228
+ // 除开当前选项外容器的一半宽度
229
+ let curHalfWidth = (this.container.width - data.width) / 2
230
+ let scrollDiff = this.scrollWidth - this.container.width
231
+ // 在原有滚动条的基础上 + (当前元素距离左侧的距离 - 计算的一半宽度) - 容器的外边距之类的
232
+ scrollLeft += data.left - curHalfWidth - this.container.left
233
+ // 已经滚动在左侧了
234
+ if (scrollLeft < 0) scrollLeft = 0
235
+ // 已经超出右侧了
236
+ else if (scrollLeft > scrollDiff) scrollLeft = scrollDiff
237
+ this.scrollLeft = scrollLeft
238
+ })
239
+ .exec()
240
+ })
241
+ },
242
+ setLine() {
243
+ this.calcScrollWidth(res => {
244
+ const scrollLeft = res.scrollLeft
245
+ this.createQueryHandler()
246
+ .select(`#${this.getDomId} .v-tabs__container-item.active`)
247
+ .boundingClientRect(data => {
248
+ if (!data) return
249
+ if (this.pills) {
250
+ this.currentWidth = data.width
251
+ this.pillsLeft = scrollLeft + data.left - this.container.left
252
+ } else {
253
+ this.lineWidth = data.width * this.lineScale
254
+ this.lineLeft = scrollLeft + data.left + (data.width - data.width * this.lineScale) / 2 - this.container.left
255
+ }
256
+ })
257
+ .exec()
258
+ })
259
+ }
260
+ }
261
+ }
262
+ </script>
263
+
264
+ <style lang="scss" scoped>
265
+ .v-tabs {
266
+ width: 100%;
267
+ box-sizing: border-box;
268
+ overflow: hidden;
269
+
270
+ /* #ifdef H5 */
271
+ ::-webkit-scrollbar {
272
+ display: none;
273
+ }
274
+ /* #endif */
275
+
276
+ &__container {
277
+ min-width: 100%;
278
+ position: relative;
279
+ display: inline-flex;
280
+ align-items: center;
281
+ white-space: nowrap;
282
+ overflow: hidden;
283
+
284
+ &-item {
285
+ flex-shrink: 0;
286
+ display: flex;
287
+ align-items: center;
288
+ height: 100%;
289
+ position: relative;
290
+ z-index: 10;
291
+ transition: all 0.3s;
292
+ white-space: nowrap;
293
+ .num {
294
+ position: absolute;
295
+ right: 0;
296
+ top: 0;
297
+ min-width: 40rpx;
298
+ min-height: 40rpx;
299
+ background: rgba(255, 82, 25, 1);
300
+ font-size: 24rpx;
301
+ color: #ffffff;
302
+ text-align: center;
303
+ line-height: 40rpx;
304
+ border-radius: 50%;
305
+ }
306
+
307
+ &.disabled {
308
+ opacity: 0.5;
309
+ color: #999;
310
+ }
311
+ }
312
+
313
+ &-line {
314
+ position: absolute;
315
+ left: 0;
316
+ bottom: 0;
317
+ }
318
+
319
+ &-pills {
320
+ position: absolute;
321
+ z-index: 9;
322
+ }
323
+
324
+ &-line,
325
+ &-pills {
326
+ &.animation {
327
+ transition: all 0.3s linear;
328
+ }
329
+ }
330
+ }
331
+ }
332
+ </style>
@@ -0,0 +1,10 @@
1
+ // index.ts
2
+ import type { App } from 'vue';
3
+ import HwTabs from './HwTabs.vue';
4
+
5
+ // 使用install方法,在app.use挂载
6
+ HwTabs.install = (app: App) => {
7
+ app.component(HwTabs.__name as string, HwTabs); //注册组件
8
+ };
9
+
10
+ export default HwTabs;
@@ -0,0 +1,100 @@
1
+ export default {
2
+ value: {
3
+ type: Number,
4
+ default: 0
5
+ },
6
+ modelValue: {
7
+ type: Number,
8
+ default: 0
9
+ },
10
+ tabs: {
11
+ type: Array,
12
+ default () {
13
+ return []
14
+ }
15
+ },
16
+ bgColor: {
17
+ type: String,
18
+ default: '#fff'
19
+ },
20
+ padding: {
21
+ type: String,
22
+ default: '0'
23
+ },
24
+ color: {
25
+ type: String,
26
+ default: '#333'
27
+ },
28
+ activeColor: {
29
+ type: String,
30
+ default: '#2979ff'
31
+ },
32
+ fontSize: {
33
+ type: String,
34
+ default: '28rpx'
35
+ },
36
+ activeFontSize: {
37
+ type: String,
38
+ default: '32rpx'
39
+ },
40
+ bold: {
41
+ type: Boolean,
42
+ default: false
43
+ },
44
+ scroll: {
45
+ type: Boolean,
46
+ default: true
47
+ },
48
+ height: {
49
+ type: String,
50
+ default: '70rpx'
51
+ },
52
+ lineColor: {
53
+ type: String,
54
+ default: '#2979ff'
55
+ },
56
+ lineHeight: {
57
+ type: [String, Number],
58
+ default: '10rpx'
59
+ },
60
+ lineScale: {
61
+ type: Number,
62
+ default: 0.3
63
+ },
64
+ lineRadius: {
65
+ type: String,
66
+ default: '10rpx'
67
+ },
68
+ pills: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+ pillsColor: {
73
+ type: String,
74
+ default: '#2979ff'
75
+ },
76
+ pillsBorderRadius: {
77
+ type: String,
78
+ default: '10rpx'
79
+ },
80
+ field: {
81
+ type: String,
82
+ default: ''
83
+ },
84
+ fixed: {
85
+ type: Boolean,
86
+ default: false
87
+ },
88
+ paddingItem: {
89
+ type: String,
90
+ default: '0 22rpx'
91
+ },
92
+ lineAnimation: {
93
+ type: Boolean,
94
+ default: true
95
+ },
96
+ zIndex: {
97
+ type: Number,
98
+ default: 1993
99
+ }
100
+ }