@didaoktv/didaoui-uniapp 2.5.0 → 2.6.0

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 CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  - **帝王级配色** — 帝王金 `#F5A623` + 皇家蓝 `#2D4BA0` 双主色,暗色主题默认
8
8
  - **玻璃拟态设计** — 多层级玻璃拟态效果,打造高端夜店沉浸感
9
- - **97 个精心打磨的组件** — 覆盖表单、导航、布局卡片、数据展示、浮层反馈、交互、画布七大类,含 KTV 业务组件(房态卡、账单明细、工单卡、日历、二维码)
9
+ - **98 个精心打磨的组件** — 覆盖表单、导航、布局卡片、数据展示、浮层反馈、交互、画布七大类,含 KTV 业务组件(房态卡、账单明细、工单卡、日历、二维码)
10
10
  - **Vue3 + TypeScript** — 完整类型定义,Composition API
11
11
  - **多端兼容** — H5 / 微信小程序 / 抖音小程序 / Android / iOS
12
12
 
@@ -52,7 +52,7 @@ import { DdButton, DdInput } from '@didaoktv/didaoui-uniapp'
52
52
  | ----- | -- | --------------------------------------------------------------------------------------------------------------------------------------------- |
53
53
  | 表单输入 | 25 | Button, CodeButton, Input, Form, Field, Switch, Checkbox, CheckboxGroup, Radio, RadioGroup, Stepper, SearchBar, Slider, DatePicker, Picker, Rate, Upload, Icon, Keyboard, NumberKeyboard, CarKeyboard, Cascader, GoodsSku, PackageSku, TreeSelect |
54
54
  | 导航 | 14 | Navigation, TopNavbar, SegmentedTab, SwipeableTab, Drawer, Tabbar, TabbarItem, Backtop, Collapse, CollapseItem, DropdownMenu, DropdownItem, Sidebar, SidebarItem | |
55
- | 布局/卡片 | 10 | Card, RoomCard, GoodsCard, FeatureGrid, Sticky, BillDetail, WorkorderCard, Calendar, Qrcode, SubmitBar |
55
+ | 布局/卡片 | 11 | Card, RoomCard, GoodsCard, FeatureGrid, Sticky, BillDetail, WorkorderCard, Calendar, Qrcode, SubmitBar, CartBar |
56
56
  | 数据展示 | 25 | Tag, StatCard, ChampionCard, Avatar, AvatarGroup, Badge, ListCell, Cell, CellGroup, CountDown, Divider, Image, Progress, Skeleton, EmptyState, Step, Steps, Text, Link, Copy, Album, Coupon, Parse, Markdown, Price |
57
57
  | 浮层反馈 | 11 | Modal, ActionSheet, Toast, Alert, Loading, Dialog, Overlay, Popup, Popover, PopoverItem, Portal |
58
58
  | 交互 | 5 | SwipeAction, Swipe, SwipeItem, PullRefresh, Loadmore |
@@ -0,0 +1,15 @@
1
+ /** 购物车条目(dd-cart-bar 配套;price 单位与全库一致为「分」) */
2
+ export interface DdCartItem {
3
+ /** 唯一标识 */
4
+ id: string | number
5
+ /** 商品名 */
6
+ name: string
7
+ /** 商品图(不传渲染占位图标) */
8
+ image?: string
9
+ /** 单价,单位:分 */
10
+ price: number
11
+ /** 数量(减到 1 再减 = 移除该项,由 change 回传剔除后的数组) */
12
+ count: number
13
+ /** 已选规格/备注文案(如「大杯 / 少冰」) */
14
+ specs?: string
15
+ }
@@ -0,0 +1,494 @@
1
+ <template>
2
+ <view
3
+ v-if="placeholder"
4
+ class="dd-cart-bar__placeholder"
5
+ :class="{ 'dd-cart-bar__placeholder--safe': safeAreaInsetBottom }"
6
+ ></view>
7
+
8
+ <!-- 弹层打开时栏抬升到 popup 档 +1:遮罩(overlay 档)盖不住栏,弹层面板(popup 档)从栏下方弹出,栏始终可点 -->
9
+ <view
10
+ class="dd-cart-bar"
11
+ :class="[{ 'dd-cart-bar--safe': safeAreaInsetBottom }, customClass]"
12
+ :style="[barStyle, customStyle]"
13
+ >
14
+ <view class="dd-cart-bar__bar">
15
+ <slot></slot>
16
+ <!-- 购物车入口:圆钮 + 数量角标(数量变化时 :key 重建触发弹跳动画重放) -->
17
+ <view class="dd-cart-bar__entry" @click="togglePopup">
18
+ <view class="dd-cart-bar__cart" :class="{ 'dd-cart-bar__cart--empty': totalCount === 0 }">
19
+ <dd-icon :name="totalCount > 0 ? 'cart' : 'cart-o'" class="dd-cart-bar__cart-icon" />
20
+ </view>
21
+ <view :key="totalCount" class="dd-cart-bar__count">
22
+ <dd-badge :content="totalCount" :max="99" />
23
+ </view>
24
+ </view>
25
+ <view class="dd-cart-bar__text">
26
+ <text class="dd-cart-bar__label">{{ label }}</text>
27
+ <dd-price class="dd-cart-bar__price" :rate="totalYuan" :currency="currency" />
28
+ <text v-if="suffixLabel" class="dd-cart-bar__suffix-label">{{ suffixLabel }}</text>
29
+ </view>
30
+ <slot name="button">
31
+ <dd-button
32
+ class="dd-cart-bar__button"
33
+ round
34
+ :type="buttonType"
35
+ :style="buttonStyle"
36
+ :loading="loading"
37
+ :disabled="buttonDisabled"
38
+ @click="onSubmit"
39
+ >{{ buttonText }}</dd-button>
40
+ </slot>
41
+ </view>
42
+ </view>
43
+
44
+ <dd-popup
45
+ :model-value="modelValue"
46
+ position="bottom"
47
+ round
48
+ :safe-area-inset-bottom="false"
49
+ @update:model-value="onPopupUpdate"
50
+ @open="emit('open')"
51
+ @close="emit('close')"
52
+ >
53
+ <view class="dd-cart-bar__panel">
54
+ <view class="dd-cart-bar__header">
55
+ <text class="dd-cart-bar__title">{{ title }}</text>
56
+ <view class="dd-cart-bar__clear" @click="onClear">
57
+ <dd-icon name="delete-o" class="dd-cart-bar__clear-icon" />
58
+ <text class="dd-cart-bar__clear-text">{{ clearText }}</text>
59
+ </view>
60
+ </view>
61
+ <view v-if="tips" class="dd-cart-bar__tips">
62
+ <text class="dd-cart-bar__tips-text">{{ tips }}</text>
63
+ </view>
64
+ <scroll-view
65
+ v-if="items.length"
66
+ class="dd-cart-bar__list"
67
+ scroll-y
68
+ :style="{ maxHeight: maxListHeight }"
69
+ >
70
+ <view
71
+ v-for="item in items"
72
+ :key="item.id"
73
+ class="dd-cart-bar__item"
74
+ @click="emit('item-click', item)"
75
+ >
76
+ <dd-image
77
+ v-if="item.image"
78
+ class="dd-cart-bar__item-image"
79
+ :src="item.image"
80
+ width="120rpx"
81
+ height="120rpx"
82
+ radius="16rpx"
83
+ fit="cover"
84
+ />
85
+ <view v-else class="dd-cart-bar__item-image dd-cart-bar__item-image--empty">
86
+ <dd-icon name="shopping-cart-o" class="dd-cart-bar__item-image-icon" />
87
+ </view>
88
+ <view class="dd-cart-bar__item-info">
89
+ <text class="dd-cart-bar__item-name">{{ item.name }}</text>
90
+ <text v-if="item.specs" class="dd-cart-bar__item-specs">{{ item.specs }}</text>
91
+ <view class="dd-cart-bar__item-footer">
92
+ <dd-price
93
+ class="dd-cart-bar__item-price"
94
+ :rate="item.price / 100"
95
+ :currency="currency"
96
+ />
97
+ <!-- 减到 1 再减由 onMinus 移除该项(min=1 时 stepper 只发 minus 不发 change) -->
98
+ <dd-stepper
99
+ :model-value="item.count"
100
+ :min="1"
101
+ size="sm"
102
+ @click.stop
103
+ @change="onCountChange(item, $event)"
104
+ @minus="onMinus(item)"
105
+ />
106
+ </view>
107
+ </view>
108
+ </view>
109
+ </scroll-view>
110
+ <view v-else class="dd-cart-bar__empty">
111
+ <dd-icon name="shopping-cart-o" class="dd-cart-bar__empty-icon" />
112
+ <text class="dd-cart-bar__empty-text">购物车还是空的,快去挑选商品吧</text>
113
+ </view>
114
+ </view>
115
+ </dd-popup>
116
+ </template>
117
+
118
+ <script setup lang="ts">
119
+ import { computed } from 'vue'
120
+ import type { CSSProperties } from 'vue'
121
+ import DdBadge from '../dd-badge/dd-badge.vue'
122
+ import DdButton from '../dd-button/dd-button.vue'
123
+ import DdIcon from '../dd-icon/dd-icon.vue'
124
+ import DdImage from '../dd-image/dd-image.vue'
125
+ import DdPopup from '../dd-popup/dd-popup.vue'
126
+ import DdPrice from '../dd-price/dd-price.vue'
127
+ import DdStepper from '../dd-stepper/dd-stepper.vue'
128
+ import type { DdCartItem } from './cart-bar'
129
+ // z-index 统一取 libs/config/zIndex.js(底栏 sticky 档;弹层打开时 popup 档内 +1 派生抬升)
130
+ import zIndexConfig from '../../libs/config/zIndex.js'
131
+
132
+ interface Props {
133
+ /** 购物车条目(受控);增减/清空经 change 回传新数组 */
134
+ items: DdCartItem[]
135
+ /** 购物车弹层显隐(v-model) */
136
+ modelValue?: boolean
137
+ /** 合计左侧文案 */
138
+ label?: string
139
+ /** 合计右侧附加文案(如「共减¥19」) */
140
+ suffixLabel?: string
141
+ /** 弹层顶部提示条(如凑单/温馨提示) */
142
+ tips?: string
143
+ /** 弹层标题 */
144
+ title?: string
145
+ /** 清空按钮文案 */
146
+ clearText?: string
147
+ /** 清空前是否二次确认(uni.showModal) */
148
+ clearConfirm?: boolean
149
+ /** 货币符号 */
150
+ currency?: string
151
+ /** 结算按钮文案 */
152
+ buttonText?: string
153
+ /** 结算按钮类型(dd-button type) */
154
+ buttonType?: 'default' | 'primary' | 'secondary' | 'ghost' | 'text' | 'success' | 'warning' | 'danger'
155
+ /** 结算按钮自定义背景色 */
156
+ buttonColor?: string
157
+ /** 结算按钮加载态 */
158
+ loading?: boolean
159
+ /** 禁用结算(不影响数量增减;空车时自动禁用) */
160
+ disabled?: boolean
161
+ /** 列表最大高(默认 50vh) */
162
+ maxListHeight?: string
163
+ /** 固定在底部时是否生成占位视图 */
164
+ placeholder?: boolean
165
+ /** 是否预留底部安全区 */
166
+ safeAreaInsetBottom?: boolean
167
+ customStyle?: CSSProperties | string
168
+ customClass?: string
169
+ }
170
+
171
+ const props = withDefaults(defineProps<Props>(), {
172
+ modelValue: false,
173
+ label: '合计:',
174
+ suffixLabel: '',
175
+ tips: '',
176
+ title: '已选商品',
177
+ clearText: '清空购物车',
178
+ clearConfirm: true,
179
+ currency: '¥',
180
+ buttonText: '结算',
181
+ buttonType: 'primary',
182
+ buttonColor: '',
183
+ loading: false,
184
+ disabled: false,
185
+ maxListHeight: '50vh',
186
+ placeholder: false,
187
+ safeAreaInsetBottom: true,
188
+ customStyle: undefined,
189
+ customClass: '',
190
+ })
191
+
192
+ const emit = defineEmits<{
193
+ (e: 'update:modelValue', val: boolean): void
194
+ (e: 'open'): void
195
+ (e: 'close'): void
196
+ /** 数量增减/清空后的最新条目(减到 0 的项已剔除) */
197
+ (e: 'change', items: DdCartItem[]): void
198
+ (e: 'clear'): void
199
+ (e: 'submit'): void
200
+ (e: 'item-click', item: DdCartItem): void
201
+ }>()
202
+
203
+ const totalCount = computed(() => props.items.reduce((sum, it) => sum + (it.count || 0), 0))
204
+
205
+ // 合计(分→元),dd-price 直接展示
206
+ const totalYuan = computed(() => props.items.reduce((sum, it) => sum + (it.price || 0) * (it.count || 0), 0) / 100)
207
+
208
+ const buttonDisabled = computed(() => props.disabled || totalCount.value === 0)
209
+
210
+ const barStyle = computed<CSSProperties>(() => ({
211
+ zIndex: props.modelValue ? zIndexConfig.popup + 1 : zIndexConfig.sticky,
212
+ }))
213
+
214
+ const buttonStyle = computed(() => (props.buttonColor ? { background: props.buttonColor } : undefined))
215
+
216
+ function onPopupUpdate(val: boolean) {
217
+ emit('update:modelValue', val)
218
+ }
219
+
220
+ function togglePopup() {
221
+ // 空车不允许撑开弹层(业界惯例:角标为 0 时入口不可点)
222
+ if (!props.modelValue && totalCount.value === 0) return
223
+ emit('update:modelValue', !props.modelValue)
224
+ }
225
+
226
+ function onCountChange(item: DdCartItem, val: number) {
227
+ if (val === item.count) return
228
+ emitChange(props.items.map((it) => (it.id === item.id ? { ...it, count: val } : it)))
229
+ }
230
+
231
+ // min=1 拦下减号:数量为 1 再减 = 移除该商品(stepper 此时不再发 change,只发 minus)
232
+ function onMinus(item: DdCartItem) {
233
+ if (item.count > 1) return
234
+ emitChange(props.items.filter((it) => it.id !== item.id))
235
+ }
236
+
237
+ function emitChange(items: DdCartItem[]) {
238
+ emit('change', items)
239
+ // 减空/清空后自动收起弹层
240
+ if (items.length === 0 && props.modelValue) emit('update:modelValue', false)
241
+ }
242
+
243
+ function onClear() {
244
+ if (!props.items.length) return
245
+ if (!props.clearConfirm) return doClear()
246
+ uni.showModal({
247
+ title: '提示',
248
+ content: '确定清空购物车吗?',
249
+ success: (res) => {
250
+ if (res.confirm) doClear()
251
+ },
252
+ })
253
+ }
254
+
255
+ function doClear() {
256
+ emitChange([])
257
+ emit('clear')
258
+ }
259
+
260
+ function onSubmit() {
261
+ if (buttonDisabled.value || props.loading) return
262
+ emit('submit')
263
+ }
264
+ </script>
265
+
266
+ <style lang="scss" scoped>
267
+ @import '../../scss/variables';
268
+ @import '../../scss/mixins';
269
+
270
+ .dd-cart-bar {
271
+ position: fixed;
272
+ left: 0;
273
+ right: 0;
274
+ bottom: 0;
275
+ background: var(--dd-bg-card, #{$dd-bg-card});
276
+
277
+ &--safe {
278
+ @include dd-safe-area-bottom;
279
+ }
280
+ }
281
+
282
+ .dd-cart-bar__placeholder {
283
+ width: 100%;
284
+ height: 100rpx;
285
+ box-sizing: content-box;
286
+
287
+ &--safe {
288
+ @include dd-safe-area-bottom;
289
+ }
290
+ }
291
+
292
+ .dd-cart-bar__bar {
293
+ display: flex;
294
+ align-items: center;
295
+ min-height: 100rpx;
296
+ padding: $dd-space-2 $dd-space-3;
297
+ }
298
+
299
+ // 入口圆钮:微凸出栏顶(外卖购物车标志视觉)
300
+ .dd-cart-bar__entry {
301
+ position: relative;
302
+ flex-shrink: 0;
303
+ margin-right: $dd-space-3;
304
+ }
305
+
306
+ .dd-cart-bar__cart {
307
+ display: flex;
308
+ align-items: center;
309
+ justify-content: center;
310
+ width: 88rpx;
311
+ height: 88rpx;
312
+ transform: translateY(-14rpx);
313
+ border-radius: $dd-radius-full;
314
+ background: var(--dd-primary, #{$dd-primary});
315
+ color: var(--dd-primary-contrast, #{$dd-primary-contrast});
316
+ box-shadow: var(--dd-shadow-1, #{$dd-shadow-1});
317
+
318
+ &--empty {
319
+ background: var(--dd-surface-container-low, #{$dd-surface-container-low});
320
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
321
+ box-shadow: none;
322
+ }
323
+ }
324
+
325
+ .dd-cart-bar__cart-icon {
326
+ font-size: 44rpx;
327
+ }
328
+
329
+ .dd-cart-bar__count {
330
+ position: absolute;
331
+ top: -6rpx;
332
+ right: -10rpx;
333
+ animation: dd-cart-bar-bounce 0.3s;
334
+ }
335
+
336
+ @keyframes dd-cart-bar-bounce {
337
+ 0% { transform: scale(0.5); }
338
+ 60% { transform: scale(1.25); }
339
+ 100% { transform: scale(1); }
340
+ }
341
+
342
+ .dd-cart-bar__text {
343
+ flex: 1;
344
+ padding-right: $dd-space-3;
345
+ color: var(--dd-text-primary, #{$dd-text-primary});
346
+ font-size: $dd-font-size-body;
347
+ }
348
+
349
+ .dd-cart-bar__price {
350
+ margin-left: $dd-space-1;
351
+ color: var(--dd-error, #{$dd-error});
352
+ }
353
+
354
+ .dd-cart-bar__suffix-label {
355
+ margin-left: $dd-space-1;
356
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
357
+ font-size: $dd-font-size-caption;
358
+ }
359
+
360
+ .dd-cart-bar__button {
361
+ flex-shrink: 0;
362
+ min-width: 200rpx;
363
+ margin-left: $dd-space-2;
364
+ }
365
+
366
+ .dd-cart-bar__panel {
367
+ // 底部留出栏高 + 安全区:弹层面板(popup 档)压在栏下方,内容不被栏遮挡
368
+ padding: $dd-space-3 $dd-space-3 calc(100rpx + constant(safe-area-inset-bottom));
369
+ padding: $dd-space-3 $dd-space-3 calc(100rpx + env(safe-area-inset-bottom));
370
+ box-sizing: border-box;
371
+ }
372
+
373
+ .dd-cart-bar__header {
374
+ display: flex;
375
+ align-items: center;
376
+ justify-content: space-between;
377
+ padding-bottom: $dd-space-2;
378
+ }
379
+
380
+ .dd-cart-bar__title {
381
+ color: var(--dd-text-primary, #{$dd-text-primary});
382
+ font-size: $dd-font-size-h4;
383
+ font-weight: $dd-font-weight-h4;
384
+ }
385
+
386
+ .dd-cart-bar__clear {
387
+ display: flex;
388
+ align-items: center;
389
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
390
+ font-size: $dd-font-size-caption;
391
+ }
392
+
393
+ .dd-cart-bar__clear-icon {
394
+ margin-right: $dd-space-1;
395
+ font-size: 28rpx;
396
+ }
397
+
398
+ .dd-cart-bar__tips {
399
+ margin-bottom: $dd-space-2;
400
+ padding: $dd-space-2 $dd-space-3;
401
+ border-radius: $dd-radius-md;
402
+ background: var(--dd-surface-container-low, #{$dd-surface-container-low});
403
+ }
404
+
405
+ .dd-cart-bar__tips-text {
406
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
407
+ font-size: $dd-font-size-caption;
408
+ line-height: $dd-line-height-caption;
409
+ }
410
+
411
+ .dd-cart-bar__list {
412
+ box-sizing: border-box;
413
+ }
414
+
415
+ .dd-cart-bar__item {
416
+ display: flex;
417
+ align-items: center;
418
+ padding: $dd-space-3 0;
419
+ }
420
+
421
+ .dd-cart-bar__item-image {
422
+ flex-shrink: 0;
423
+ margin-right: $dd-space-3;
424
+ overflow: hidden;
425
+
426
+ &--empty {
427
+ display: flex;
428
+ align-items: center;
429
+ justify-content: center;
430
+ width: 120rpx;
431
+ height: 120rpx;
432
+ border-radius: 16rpx;
433
+ background: var(--dd-surface-container-low, #{$dd-surface-container-low});
434
+ }
435
+ }
436
+
437
+ .dd-cart-bar__item-image-icon {
438
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
439
+ font-size: 48rpx;
440
+ }
441
+
442
+ .dd-cart-bar__item-info {
443
+ flex: 1;
444
+ min-width: 0;
445
+ }
446
+
447
+ .dd-cart-bar__item-name {
448
+ display: block;
449
+ overflow: hidden;
450
+ color: var(--dd-text-primary, #{$dd-text-primary});
451
+ font-size: $dd-font-size-body;
452
+ white-space: nowrap;
453
+ text-overflow: ellipsis;
454
+ }
455
+
456
+ .dd-cart-bar__item-specs {
457
+ display: block;
458
+ margin-top: $dd-space-1;
459
+ overflow: hidden;
460
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
461
+ font-size: $dd-font-size-caption;
462
+ white-space: nowrap;
463
+ text-overflow: ellipsis;
464
+ }
465
+
466
+ .dd-cart-bar__item-footer {
467
+ display: flex;
468
+ align-items: center;
469
+ justify-content: space-between;
470
+ margin-top: $dd-space-2;
471
+ }
472
+
473
+ .dd-cart-bar__item-price {
474
+ color: var(--dd-error, #{$dd-error});
475
+ }
476
+
477
+ .dd-cart-bar__empty {
478
+ display: flex;
479
+ flex-direction: column;
480
+ align-items: center;
481
+ padding: $dd-space-8 0;
482
+ }
483
+
484
+ .dd-cart-bar__empty-icon {
485
+ margin-bottom: $dd-space-2;
486
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
487
+ font-size: 80rpx;
488
+ }
489
+
490
+ .dd-cart-bar__empty-text {
491
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
492
+ font-size: $dd-font-size-caption;
493
+ }
494
+ </style>
@@ -43,9 +43,11 @@
43
43
  </text>
44
44
  </view>
45
45
  <!-- 价格行右侧扩展位(步进器/加购等与价格同排贴底);未用时回退已选数量 -->
46
- <slot name="price-right">
47
- <text v-if="num" class="dd-goods-card__num">×{{ num }}</text>
48
- </slot>
46
+ <view class="dd-goods-card__price-right">
47
+ <slot name="price-right">
48
+ <text v-if="num" class="dd-goods-card__num">×{{ num }}</text>
49
+ </slot>
50
+ </view>
49
51
  </view>
50
52
 
51
53
  <view v-if="$slots.bottom" class="dd-goods-card__bottom">
@@ -206,11 +208,8 @@ function onClick(e: Event) {
206
208
  color: var(--dd-text-secondary, #{$dd-text-secondary});
207
209
  font-size: 24rpx;
208
210
  line-height: 1.4;
209
- // 两行省略
210
- display: -webkit-box;
211
- -webkit-box-orient: vertical;
212
- -webkit-line-clamp: 2;
213
- overflow: hidden;
211
+ // 单行省略:给价格行(现价+划线价)留足横向空间,避免挤出右侧操作位
212
+ @include dd-ellipsis;
214
213
  }
215
214
 
216
215
  &__price-row {
@@ -221,6 +220,9 @@ function onClick(e: Event) {
221
220
  }
222
221
 
223
222
  &__price {
223
+ // 占满剩余宽度且可收缩,划线价过长时自身省略,不把右侧操作位挤出
224
+ flex: 1;
225
+ min-width: 0;
224
226
  display: inline-flex;
225
227
  align-items: baseline;
226
228
  color: var(--dd-error-400, #{$dd-error-400});
@@ -233,10 +235,18 @@ function onClick(e: Event) {
233
235
  font-size: 22rpx;
234
236
  font-weight: 400;
235
237
  text-decoration: line-through;
238
+ // 空间不足时划线价自身省略
239
+ overflow: hidden;
240
+ white-space: nowrap;
241
+ text-overflow: ellipsis;
236
242
  }
237
243
 
238
- &__num {
244
+ &__price-right {
245
+ flex-shrink: 0;
239
246
  margin-left: $dd-space-2;
247
+ }
248
+
249
+ &__num {
240
250
  color: var(--dd-text-tertiary, #{$dd-text-tertiary});
241
251
  font-size: 24rpx;
242
252
  }
@@ -22,6 +22,7 @@
22
22
  <view class="dd-goods-sku__header__info__price">
23
23
  <text class="dd-goods-sku__header__info__price__symbol">¥</text>
24
24
  <text class="dd-goods-sku__header__info__price__value">{{ price }}</text>
25
+ <text v-if="originPrice" class="dd-goods-sku__header__info__price__origin">¥{{ originPrice }}</text>
25
26
  </view>
26
27
  <view class="dd-goods-sku__header__info__stock">库存 {{ stock }} 件</view>
27
28
  <view class="dd-goods-sku__header__info__selected">已选: {{ selectedSkuText }}</view>
@@ -139,16 +140,23 @@ const price = computed(() => {
139
140
  return props.goodsInfo.price || props.goodsInfo.price_fee || 0
140
141
  })
141
142
 
143
+ // 划线原价:随选中组合(originPrice|origin_price),缺省回退商品级;不传不显示
144
+ const originPrice = computed(() => {
145
+ const comb = getSelectedSkuComb()
146
+ if (comb) return comb.originPrice || comb.origin_price || ''
147
+ return props.goodsInfo.originPrice || props.goodsInfo.origin_price || ''
148
+ })
149
+
142
150
  // 头图:缺图时文字占位(与 dd-package-sku / dd-goods-card 同规则)——随机主题底色 + 名称前 2 字
143
151
  const headerImage = computed(() => props.goodsInfo.image || props.goodsInfo.picture || '')
144
152
  const avatarHue = ref<string>(pickAvatarHue())
145
153
  const avatarText = computed(() => calcAvatarText(props.goodsInfo.name))
146
154
 
147
- // 当前库存
155
+ // 当前库存:库存 0 是合法值(售罄规格),必须用 ?? 兜底——|| 会把 0 误判缺省落到 undefined,模板渲染成「库存 件」
148
156
  const stock = computed(() => {
149
157
  const comb = getSelectedSkuComb()
150
- if (comb) return comb.stock || comb.quantity
151
- return props.goodsInfo.stock || props.goodsInfo.quantity || 0
158
+ if (comb) return comb.stock ?? comb.quantity ?? 0
159
+ return props.goodsInfo.stock ?? props.goodsInfo.quantity ?? 0
152
160
  })
153
161
 
154
162
  // 最大购买数量
@@ -187,21 +195,23 @@ function isSelected(skuKey: string, skuValueId: string | number) {
187
195
  return selectedSku[skuKey] === skuValueId
188
196
  }
189
197
 
190
- // 判断SKU是否禁用
198
+ // 判断SKU是否禁用:组合不存在或库存为 0(售罄)均不可选;库存 0 是合法值,取值须用 ?? 防穿透
191
199
  function isDisabled(skuKey: string, skuValueId: string | number) {
192
200
  // 构造一个临时的已选中SKU对象
193
201
  const tempSelected: Record<string, any> = { ...selectedSku, [skuKey]: skuValueId }
202
+ const stockOf = (s: Record<string, any>) => s.stock ?? s.quantity ?? 0
194
203
 
195
204
  // 检查是否还有未选择的SKU维度
196
205
  const selectedCount = Object.keys(tempSelected).filter((key) => tempSelected[key]).length
197
206
  const totalSkuCount = props.skuTree.length
198
207
 
199
- // 如果所有SKU都已选择,则检查组合是否存在
208
+ // 如果所有SKU都已选择,则检查组合是否存在且有货
200
209
  if (selectedCount === totalSkuCount) {
201
- return !getSkuComb(tempSelected)
210
+ const comb = getSkuComb(tempSelected)
211
+ return !comb || stockOf(comb) <= 0
202
212
  }
203
213
 
204
- // 检查当前选择的SKU是否会导致无法组成有效组合
214
+ // 部分选择预检:存在任一有货的匹配行即可选;匹配行全售罄等同组合不存在,一并禁用
205
215
  for (let i = 0; i < props.skuList.length; i++) {
206
216
  const sku = props.skuList[i]
207
217
  let match = true
@@ -213,7 +223,7 @@ function isDisabled(skuKey: string, skuValueId: string | number) {
213
223
  }
214
224
  }
215
225
 
216
- if (match) {
226
+ if (match && stockOf(sku) > 0) {
217
227
  return false
218
228
  }
219
229
  }
@@ -374,6 +384,15 @@ defineExpose({ open, close, reset })
374
384
  color: var(--dd-error-400, #{$dd-error-400});
375
385
  font-weight: bold;
376
386
  }
387
+
388
+ // 划线原价(样式对齐 dd-goods-card)
389
+ &__origin {
390
+ margin-left: $dd-space-2;
391
+ color: var(--dd-text-tertiary, #{$dd-text-tertiary});
392
+ font-size: 22rpx;
393
+ font-weight: 400;
394
+ text-decoration: line-through;
395
+ }
377
396
  }
378
397
 
379
398
  &__stock {
@@ -22,6 +22,7 @@
22
22
  <view class="dd-package-sku__header__info__price">
23
23
  <text class="dd-package-sku__header__info__price__symbol">¥</text>
24
24
  <text class="dd-package-sku__header__info__price__value">{{ price }}</text>
25
+ <text v-if="originPrice" class="dd-package-sku__header__info__price__origin">¥{{ originPrice }}</text>
25
26
  </view>
26
27
  <view v-if="stock !== undefined && stock !== null" class="dd-package-sku__header__info__stock">
27
28
  库存 {{ stock }} 件
@@ -146,6 +147,8 @@ const price = computed(
146
147
  surchargeFen.value) /
147
148
  100,
148
149
  )
150
+ /** 划线原价(元):套餐级营销价,不随加价联动;originPrice|origin_price,缺省不显示 */
151
+ const originPrice = computed(() => props.goodsInfo.originPrice || props.goodsInfo.origin_price || '')
149
152
  /** 库存:缺省不显示库存行(套餐可能无台账库存,如房时套餐) */
150
153
  const stock = computed(() => props.goodsInfo.stock ?? props.goodsInfo.quantity)
151
154
  /** 已选项实时摘要(确认前即联动展示) */
@@ -278,6 +281,15 @@ defineExpose({ open, close, reset })
278
281
  color: var(--dd-error-400, #{$dd-error-400});
279
282
  font-weight: bold;
280
283
  }
284
+
285
+ // 划线原价(样式对齐 dd-goods-card / dd-goods-sku)
286
+ &__origin {
287
+ margin-left: $dd-space-2;
288
+ color: var(--dd-text-tertiary, #{$dd-text-tertiary});
289
+ font-size: 22rpx;
290
+ font-weight: 400;
291
+ text-decoration: line-through;
292
+ }
281
293
  }
282
294
 
283
295
  &__stock {
@@ -4,10 +4,12 @@
4
4
  export interface PackageSkuItem {
5
5
  id: string | number
6
6
  name: string
7
- /** 加价金额(分),0/缺省 = 不加价 */
7
+ /** 加价金额(分/每份,ADR-0026),0/缺省 = 不加价 */
8
8
  priceFen?: number
9
9
  /** 库存数量,<=0 置灰;缺省视为有货 */
10
10
  qty?: number
11
+ /** 单次选中份数(选中一次即 N 份,仅影响摘要文案与加价合计),缺省 1;与 qty(库存)正交 */
12
+ perQty?: number
11
13
  /** false 置灰;缺省视为可用 */
12
14
  enabled?: boolean
13
15
  }
@@ -115,33 +117,35 @@ export function buildOptions(groups: PackageSkuGroup[], selections: PackageSkuSe
115
117
  return options
116
118
  }
117
119
 
118
- /** 已选 OPTIONAL 项加价合计(分) */
120
+ /** 已选 OPTIONAL 项加价合计(分):每份加价 × 单次选中份数(与服务端口径同源,ADR-0026) */
119
121
  export function computeSurchargeFen(groups: PackageSkuGroup[], selections: PackageSkuSelections): number {
120
122
  let sum = 0
121
123
  for (const g of groups) {
122
124
  if (isFixed(g)) continue
123
125
  for (const skuId of selections[String(g.id)] ?? []) {
124
126
  const item = g.items.find((it) => it.id === skuId)
125
- sum += item?.priceFen ?? 0
127
+ sum += (item?.priceFen ?? 0) * (item?.perQty ?? 1)
126
128
  }
127
129
  }
128
130
  return sum
129
131
  }
130
132
 
131
- /** 已选 OPTIONAL 项名称顿号拼接 */
133
+ /** 已选 OPTIONAL 项名称顿号拼接;单次选中份数 >1 时带 ×N */
132
134
  export function buildSelectedText(groups: PackageSkuGroup[], selections: PackageSkuSelections): string {
133
135
  const names: string[] = []
134
136
  for (const g of groups) {
135
137
  if (isFixed(g)) continue
136
138
  for (const skuId of selections[String(g.id)] ?? []) {
137
139
  const item = g.items.find((it) => it.id === skuId)
138
- if (item) names.push(item.name)
140
+ if (!item) continue
141
+ const n = item.perQty ?? 1
142
+ names.push(n > 1 ? `${item.name}×${n}` : item.name)
139
143
  }
140
144
  }
141
145
  return names.join('、')
142
146
  }
143
147
 
144
- /** 加价标签:「+¥X」(元,去尾零);无加价返回空串 */
148
+ /** 加价标签:「+¥X」(元,去尾零)——每份口径(perQty>1 时实收为 X×N,合计预览兜底),无加价返回空串 */
145
149
  export function surchargeLabel(item: PackageSkuItem): string {
146
150
  const fen = item.priceFen ?? 0
147
151
  if (fen <= 0) return ''
package/index.ts CHANGED
@@ -43,7 +43,7 @@ import DdDropdownItem from './components/dd-dropdown-item/dd-dropdown-item.vue'
43
43
  import DdSidebar from './components/dd-sidebar/dd-sidebar.vue'
44
44
  import DdSidebarItem from './components/dd-sidebar-item/dd-sidebar-item.vue'
45
45
 
46
- // === Layout (10) ===
46
+ // === Layout (11) ===
47
47
  import DdCard from './components/dd-card/dd-card.vue'
48
48
  import DdRoomCard from './components/dd-room-card/dd-room-card.vue'
49
49
  import DdGoodsCard from './components/dd-goods-card/dd-goods-card.vue'
@@ -54,6 +54,7 @@ import DdWorkorderCard from './components/dd-workorder-card/dd-workorder-card.vu
54
54
  import DdCalendar from './components/dd-calendar/dd-calendar.vue'
55
55
  import DdQrcode from './components/dd-qrcode/dd-qrcode.vue'
56
56
  import DdSubmitBar from './components/dd-submit-bar/dd-submit-bar.vue'
57
+ import DdCartBar from './components/dd-cart-bar/dd-cart-bar.vue'
57
58
 
58
59
  // === Display (25) ===
59
60
  import DdTag from './components/dd-tag/dd-tag.vue'
@@ -124,6 +125,7 @@ const components = {
124
125
  DdSidebar, DdSidebarItem,
125
126
  DdCard, DdRoomCard, DdGoodsCard, DdFeatureGrid, DdSticky, DdBillDetail, DdWorkorderCard, DdCalendar, DdQrcode,
126
127
  DdSubmitBar,
128
+ DdCartBar,
127
129
  DdTag, DdStatCard, DdChampionCard, DdAvatar, DdAvatarGroup, DdBadge,
128
130
  DdListCell, DdCell, DdCellGroup, DdCountDown, DdDivider,
129
131
  DdImage, DdProgress, DdSkeleton, DdEmptyState, DdStep, DdSteps,
@@ -156,6 +158,7 @@ export {
156
158
  DdSidebar, DdSidebarItem,
157
159
  DdCard, DdRoomCard, DdGoodsCard, DdFeatureGrid, DdSticky, DdBillDetail, DdWorkorderCard, DdCalendar, DdQrcode,
158
160
  DdSubmitBar,
161
+ DdCartBar,
159
162
  DdTag, DdStatCard, DdChampionCard, DdAvatar, DdAvatarGroup, DdBadge,
160
163
  DdListCell, DdCell, DdCellGroup, DdCountDown, DdDivider,
161
164
  DdImage, DdProgress, DdSkeleton, DdEmptyState, DdStep, DdSteps,
@@ -184,5 +187,8 @@ export type {
184
187
  PackageSkuOption,
185
188
  } from './components/dd-package-sku/package-sku'
186
189
 
190
+ // 购物车条目类型(dd-cart-bar 配套)
191
+ export type { DdCartItem } from './components/dd-cart-bar/cart-bar'
192
+
187
193
  // 图标元数据(供 demo/文档消费,与 dd-icon.vue 内 SCSS &-- 规则保持一致)
188
194
  export { iconNames, iconGroups, iconLabels } from './components/dd-icon/dd-icon.vue'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@didaoktv/didaoui-uniapp",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "帝到KTV UniApp 组件库",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",