@tplc/business 0.5.11 → 0.5.12
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 +9 -0
- package/components/lcb-swiper/lcb-swiper.vue +239 -16
- package/components/lcb-swiper/types.ts +5 -0
- package/package.json +2 -3
- package/types/components/lcb-swiper/lcb-swiper.vue.d.ts +30 -5
- package/types/components/lcb-swiper/types.d.ts +5 -0
- package/types/components/lcb-waterfall/lcb-waterfall.vue.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.5.12](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.11...v0.5.12) (2025-10-11)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### ✨ Features | 新功能
|
|
9
|
+
|
|
10
|
+
* t同步constant ([9f4c637](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/9f4c6374935e04bc6de4c3f26c149b42c98237eb))
|
|
11
|
+
* 删除多余依赖 ([84abd86](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/84abd860f693cbacb74c6bc0ef27fe552784df1d))
|
|
12
|
+
* 图片圆角 ([a68898e](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/commit/a68898ec76b518fa16e4038936c0bea4a815ae7a))
|
|
13
|
+
|
|
5
14
|
### [0.5.11](https://gitlab888.30jia.com.cn/tourism-front/zero-code-pro/compare/v0.5.7...v0.5.11) (2025-10-11)
|
|
6
15
|
|
|
7
16
|
|
|
@@ -1,23 +1,41 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<lcb-block v-bind="$props"
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
<lcb-block v-bind="$props">
|
|
3
|
+
<view class="lcb-carousel" @touchstart="starts" @touchend="ends">
|
|
4
|
+
<view
|
|
5
|
+
v-for="(item, i) in imagelist"
|
|
6
|
+
:key="i"
|
|
7
|
+
class="carousel-block"
|
|
8
|
+
@click="changeBlock(item)"
|
|
9
|
+
:style="{
|
|
10
|
+
left: item.left,
|
|
11
|
+
top: item.top,
|
|
12
|
+
zIndex: item.zIndex,
|
|
13
|
+
width: itemWidth + 'rpx',
|
|
14
|
+
height: itemHeight + 'rpx',
|
|
15
|
+
transition: item.transition + 's all',
|
|
16
|
+
transform: 'translate3d(-50%, -50%, 0) scale(' + item.scale + ')',
|
|
17
|
+
}"
|
|
18
|
+
>
|
|
19
|
+
<view class="image-block">
|
|
20
|
+
<lcb-action-view v-bind="item.item.link" customClass="w-full h-full">
|
|
21
|
+
<wd-img
|
|
22
|
+
:src="item.item.url"
|
|
23
|
+
mode="aspectFill"
|
|
24
|
+
width="100%"
|
|
25
|
+
height="100%"
|
|
26
|
+
:radius="imageRadius"
|
|
27
|
+
/>
|
|
28
|
+
</lcb-action-view>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
16
32
|
</lcb-block>
|
|
17
33
|
</template>
|
|
18
34
|
|
|
19
35
|
<script setup lang="ts">
|
|
36
|
+
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
20
37
|
import { LcbSwiperProps } from './types'
|
|
38
|
+
import { ActionView } from 'action'
|
|
21
39
|
defineOptions({
|
|
22
40
|
name: 'LcbSwiper',
|
|
23
41
|
options: {
|
|
@@ -27,6 +45,211 @@ defineOptions({
|
|
|
27
45
|
},
|
|
28
46
|
})
|
|
29
47
|
|
|
30
|
-
withDefaults(defineProps<LcbSwiperProps>(), {
|
|
48
|
+
const props = withDefaults(defineProps<LcbSwiperProps>(), {
|
|
49
|
+
mode: 'multiple',
|
|
50
|
+
itemWidth: 450,
|
|
51
|
+
itemHeight: 300,
|
|
52
|
+
})
|
|
53
|
+
type DataRecord = Record<string, any>
|
|
54
|
+
|
|
55
|
+
interface SlotStyle {
|
|
56
|
+
left: string
|
|
57
|
+
top: string
|
|
58
|
+
zIndex: number
|
|
59
|
+
scale: number
|
|
60
|
+
transition: number
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ImageItem extends SlotStyle {
|
|
64
|
+
isIndex: number
|
|
65
|
+
slotIndex: number
|
|
66
|
+
item: Partial<
|
|
67
|
+
ActionView & {
|
|
68
|
+
maskBgColor?: string
|
|
69
|
+
}
|
|
70
|
+
>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const emit = defineEmits<{
|
|
74
|
+
(e: 'selection', item: DataRecord): void
|
|
75
|
+
}>()
|
|
76
|
+
|
|
77
|
+
const datalist = ref<DataRecord[]>([])
|
|
78
|
+
const imagelist = ref<ImageItem[]>([])
|
|
79
|
+
const ismove = ref(0)
|
|
80
|
+
const count = reactive({ sta: 0, end: 0 })
|
|
81
|
+
const slotStyles = ref<SlotStyle[]>([])
|
|
82
|
+
|
|
83
|
+
const visible = computed<number>(() => {
|
|
84
|
+
if (props.visibleCount && props.visibleCount > 0) return props.visibleCount
|
|
85
|
+
if (props.mode === 'single') return 3
|
|
86
|
+
if (props.mode === 'multiple') return 5
|
|
87
|
+
return 5
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
function buildSlots(n: number): SlotStyle[] {
|
|
91
|
+
const center = Math.floor(n / 2)
|
|
92
|
+
const spacing = 14 // percent per slot
|
|
93
|
+
const scaleStep = 0.15
|
|
94
|
+
return Array.from({ length: n }, (_, i) => {
|
|
95
|
+
const d = Math.abs(i - center)
|
|
96
|
+
return {
|
|
97
|
+
left: `calc(50% + ${(i - center) * spacing}% )`,
|
|
98
|
+
top: '50%',
|
|
99
|
+
zIndex: 100 - d,
|
|
100
|
+
scale: Math.max(1 - d * scaleStep, 0.6),
|
|
101
|
+
transition: 0.3,
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function initData() {
|
|
107
|
+
datalist.value = Array.isArray(props.items) ? props.items.slice() : []
|
|
108
|
+
const desired = visible.value
|
|
109
|
+
const n = Math.min(desired, datalist.value.length)
|
|
110
|
+
slotStyles.value = buildSlots(n)
|
|
111
|
+
imagelist.value = slotStyles.value.map((s, i) => ({
|
|
112
|
+
...s,
|
|
113
|
+
isIndex: i,
|
|
114
|
+
slotIndex: i,
|
|
115
|
+
item: datalist.value[i],
|
|
116
|
+
}))
|
|
117
|
+
count.sta = 0
|
|
118
|
+
count.end = Math.max(0, n - 1)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function refreshVisibleFields() {
|
|
122
|
+
imagelist.value.forEach((item) => {
|
|
123
|
+
item.item = datalist.value[item.isIndex]
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function applySlotStyle(item: ImageItem, slot: SlotStyle) {
|
|
128
|
+
item.left = slot.left
|
|
129
|
+
item.top = slot.top
|
|
130
|
+
item.zIndex = slot.zIndex
|
|
131
|
+
item.scale = slot.scale
|
|
132
|
+
item.transition = slot.transition
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function LeftSliding() {
|
|
136
|
+
const n = imagelist.value.length
|
|
137
|
+
if (n === 0) return
|
|
138
|
+
const slots = slotStyles.value
|
|
139
|
+
imagelist.value.forEach((item) => {
|
|
140
|
+
const to = item.slotIndex - 1 < 0 ? n - 1 : item.slotIndex - 1
|
|
141
|
+
item.slotIndex = to
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
applySlotStyle(item, slots[to])
|
|
144
|
+
if (to === n - 1) {
|
|
145
|
+
count.end = count.end + 1 > datalist.value.length - 1 ? 0 : count.end + 1
|
|
146
|
+
item.isIndex = count.end
|
|
147
|
+
item.item = datalist.value[count.end]
|
|
148
|
+
}
|
|
149
|
+
if (to === 0) {
|
|
150
|
+
count.sta = item.isIndex
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function RightSliding() {
|
|
156
|
+
const n = imagelist.value.length
|
|
157
|
+
if (n === 0) return
|
|
158
|
+
const slots = slotStyles.value
|
|
159
|
+
imagelist.value.forEach((item) => {
|
|
160
|
+
const to = item.slotIndex + 1 > n - 1 ? 0 : item.slotIndex + 1
|
|
161
|
+
item.slotIndex = to
|
|
162
|
+
applySlotStyle(item, slots[to])
|
|
163
|
+
if (to === 0) {
|
|
164
|
+
count.sta = count.sta - 1 < 0 ? datalist.value.length - 1 : count.sta - 1
|
|
165
|
+
item.isIndex = count.sta
|
|
166
|
+
item.item = datalist.value[count.sta]
|
|
167
|
+
}
|
|
168
|
+
if (to === n - 1) {
|
|
169
|
+
count.end = item.isIndex
|
|
170
|
+
}
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function changeBlock(item: ImageItem) {
|
|
175
|
+
const n = imagelist.value.length
|
|
176
|
+
const center = Math.floor(n / 2)
|
|
177
|
+
const toor = item.slotIndex
|
|
178
|
+
if (toor < center) {
|
|
179
|
+
RightSliding()
|
|
180
|
+
if (toor < center - 1) {
|
|
181
|
+
setTimeout(() => RightSliding(), 100)
|
|
182
|
+
}
|
|
183
|
+
} else if (toor > center) {
|
|
184
|
+
LeftSliding()
|
|
185
|
+
if (toor > center + 1) {
|
|
186
|
+
setTimeout(() => LeftSliding(), 100)
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
const selected = datalist.value[item.isIndex]
|
|
190
|
+
if (selected) emit('selection', selected)
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function starts(e: any) {
|
|
195
|
+
if (e && e.touches && e.touches[0]) {
|
|
196
|
+
ismove.value = e.touches[0].pageX
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function ends(e: any) {
|
|
201
|
+
if (!e || !e.changedTouches || !e.changedTouches[0]) return
|
|
202
|
+
const pageX = e.changedTouches[0].pageX
|
|
203
|
+
const nums = ismove.value - pageX
|
|
204
|
+
if (nums > 50) {
|
|
205
|
+
LeftSliding()
|
|
206
|
+
} else if (nums < -50) {
|
|
207
|
+
RightSliding()
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
onMounted(() => {
|
|
212
|
+
initData()
|
|
213
|
+
})
|
|
214
|
+
|
|
215
|
+
// Re-init when count-related inputs change or array length changes
|
|
216
|
+
watch(
|
|
217
|
+
() => [props.visibleCount, props.mode, props.items?.length],
|
|
218
|
+
() => initData(),
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
// Update only fields when array identity changes without length change
|
|
222
|
+
watch(
|
|
223
|
+
() => props.items,
|
|
224
|
+
() => {
|
|
225
|
+
datalist.value = Array.isArray(props.items) ? props.items.slice() : []
|
|
226
|
+
refreshVisibleFields()
|
|
227
|
+
},
|
|
228
|
+
)
|
|
31
229
|
</script>
|
|
32
|
-
<style lang="scss" scoped
|
|
230
|
+
<style lang="scss" scoped>
|
|
231
|
+
.lcb-carousel {
|
|
232
|
+
width: 100%;
|
|
233
|
+
height: 100%;
|
|
234
|
+
min-height: 200px;
|
|
235
|
+
position: relative;
|
|
236
|
+
overflow: hidden;
|
|
237
|
+
.carousel-block {
|
|
238
|
+
position: absolute;
|
|
239
|
+
overflow: hidden;
|
|
240
|
+
border-radius: 10upx;
|
|
241
|
+
overflow: hidden;
|
|
242
|
+
box-shadow: 0 0 5px #0000001a;
|
|
243
|
+
will-change: transform;
|
|
244
|
+
.image-block {
|
|
245
|
+
position: absolute;
|
|
246
|
+
left: 0;
|
|
247
|
+
top: 0;
|
|
248
|
+
width: 100%;
|
|
249
|
+
height: 100%;
|
|
250
|
+
background-size: 100% 100%;
|
|
251
|
+
z-index: 5;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tplc/business",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.12",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"业务组件"
|
|
6
6
|
],
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"mp-html": "^2.5.0",
|
|
22
22
|
"qs": "6.5.3",
|
|
23
|
-
"uview-plus": "^3.3.9"
|
|
24
|
-
"@zebra-ui/swiper": "^3.0.2"
|
|
23
|
+
"uview-plus": "^3.3.9"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
27
26
|
"standard-version": "^9.5.0"
|
|
@@ -1,19 +1,44 @@
|
|
|
1
1
|
import { LcbSwiperProps } from './types'
|
|
2
|
+
type DataRecord = Record<string, any>
|
|
2
3
|
declare const _default: import('vue').DefineComponent<
|
|
3
|
-
__VLS_WithDefaults<
|
|
4
|
+
__VLS_WithDefaults<
|
|
5
|
+
__VLS_TypePropsToOption<LcbSwiperProps>,
|
|
6
|
+
{
|
|
7
|
+
mode: string
|
|
8
|
+
itemWidth: number
|
|
9
|
+
itemHeight: number
|
|
10
|
+
}
|
|
11
|
+
>,
|
|
4
12
|
{},
|
|
5
13
|
unknown,
|
|
6
14
|
{},
|
|
7
15
|
{},
|
|
8
16
|
import('vue').ComponentOptionsMixin,
|
|
9
17
|
import('vue').ComponentOptionsMixin,
|
|
10
|
-
{
|
|
18
|
+
{
|
|
19
|
+
selection: (item: DataRecord) => void
|
|
20
|
+
},
|
|
11
21
|
string,
|
|
12
22
|
import('vue').PublicProps,
|
|
13
23
|
Readonly<
|
|
14
|
-
import('vue').ExtractPropTypes<
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
import('vue').ExtractPropTypes<
|
|
25
|
+
__VLS_WithDefaults<
|
|
26
|
+
__VLS_TypePropsToOption<LcbSwiperProps>,
|
|
27
|
+
{
|
|
28
|
+
mode: string
|
|
29
|
+
itemWidth: number
|
|
30
|
+
itemHeight: number
|
|
31
|
+
}
|
|
32
|
+
>
|
|
33
|
+
>
|
|
34
|
+
> & {
|
|
35
|
+
onSelection?: ((item: DataRecord) => any) | undefined
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
mode: string
|
|
39
|
+
itemWidth: number
|
|
40
|
+
itemHeight: number
|
|
41
|
+
},
|
|
17
42
|
{}
|
|
18
43
|
>
|
|
19
44
|
export default _default
|
|
@@ -180,10 +180,10 @@ declare const _default: import('vue').DefineComponent<
|
|
|
180
180
|
width: string | number
|
|
181
181
|
height: string | number
|
|
182
182
|
showScrollbar: boolean
|
|
183
|
-
idKey: string
|
|
184
|
-
addTime: number
|
|
185
183
|
columnCount: string | number
|
|
186
184
|
columnGap: string | number
|
|
185
|
+
idKey: string
|
|
186
|
+
addTime: number
|
|
187
187
|
leftGap: string | number
|
|
188
188
|
rightGap: string | number
|
|
189
189
|
},
|