@didaoktv/didaoui-uniapp 2.5.0 → 2.7.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 +2 -2
- package/components/dd-cart-bar/cart-bar.ts +15 -0
- package/components/dd-cart-bar/dd-cart-bar.vue +447 -0
- package/components/dd-goods-card/dd-goods-card.vue +69 -9
- package/components/dd-goods-sku/dd-goods-sku.vue +27 -8
- package/components/dd-package-sku/dd-package-sku.vue +16 -1
- package/components/dd-package-sku/package-sku.ts +10 -6
- package/components/dd-price/dd-price.vue +32 -1
- package/index.ts +7 -1
- package/libs/config/zIndex.js +2 -0
- package/package.json +1 -1
- package/scss/theme.scss +81 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- **帝王级配色** — 帝王金 `#F5A623` + 皇家蓝 `#2D4BA0` 双主色,暗色主题默认
|
|
8
8
|
- **玻璃拟态设计** — 多层级玻璃拟态效果,打造高端夜店沉浸感
|
|
9
|
-
- **
|
|
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
|
-
| 布局/卡片 |
|
|
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,447 @@
|
|
|
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
|
+
@closed="onPanelClosed"
|
|
53
|
+
>
|
|
54
|
+
<view class="dd-cart-bar__panel">
|
|
55
|
+
<view class="dd-cart-bar__header">
|
|
56
|
+
<text class="dd-cart-bar__title">{{ title }}</text>
|
|
57
|
+
<view class="dd-cart-bar__clear" @click="onClear">
|
|
58
|
+
<dd-icon name="delete-o" class="dd-cart-bar__clear-icon" />
|
|
59
|
+
<text class="dd-cart-bar__clear-text">{{ clearText }}</text>
|
|
60
|
+
</view>
|
|
61
|
+
</view>
|
|
62
|
+
<view v-if="tips" class="dd-cart-bar__tips">
|
|
63
|
+
<text class="dd-cart-bar__tips-text">{{ tips }}</text>
|
|
64
|
+
</view>
|
|
65
|
+
<scroll-view
|
|
66
|
+
v-if="items.length"
|
|
67
|
+
class="dd-cart-bar__list"
|
|
68
|
+
scroll-y
|
|
69
|
+
:style="{ maxHeight: maxListHeight }"
|
|
70
|
+
>
|
|
71
|
+
<!-- 商品行复用 dd-goods-card 小号横卡(96rpx 紧凑图、不渲染描述、价格小一号);规格随卡 desc 传入(sm 档不显示),数量步进器走 price-right 插槽 -->
|
|
72
|
+
<dd-goods-card
|
|
73
|
+
v-for="item in items"
|
|
74
|
+
:key="item.id"
|
|
75
|
+
class="dd-cart-bar__item-card"
|
|
76
|
+
size="sm"
|
|
77
|
+
:thumb="item.image"
|
|
78
|
+
:title="item.name"
|
|
79
|
+
:desc="item.specs"
|
|
80
|
+
:price="item.price / 100"
|
|
81
|
+
:currency="currency"
|
|
82
|
+
@click="emit('item-click', item)"
|
|
83
|
+
>
|
|
84
|
+
<template #price-right>
|
|
85
|
+
<dd-stepper
|
|
86
|
+
:model-value="item.count"
|
|
87
|
+
:min="1"
|
|
88
|
+
size="sm"
|
|
89
|
+
@click.stop
|
|
90
|
+
@change="onCountChange(item, $event)"
|
|
91
|
+
@minus="onMinus(item)"
|
|
92
|
+
/>
|
|
93
|
+
</template>
|
|
94
|
+
</dd-goods-card>
|
|
95
|
+
</scroll-view>
|
|
96
|
+
<view v-else class="dd-cart-bar__empty">
|
|
97
|
+
<dd-icon name="shopping-cart-o" class="dd-cart-bar__empty-icon" />
|
|
98
|
+
<text class="dd-cart-bar__empty-text">购物车还是空的,快去挑选商品吧</text>
|
|
99
|
+
</view>
|
|
100
|
+
</view>
|
|
101
|
+
</dd-popup>
|
|
102
|
+
|
|
103
|
+
<!-- 清空二次确认:库内 dd-dialog(dialog 档 2011,恒高于本组件 popup 面板 2002),不用 uni.showModal(H5 端 z-index 999 会被自家面板盖住) -->
|
|
104
|
+
<dd-dialog
|
|
105
|
+
v-model="clearDialogVisible"
|
|
106
|
+
title="提示"
|
|
107
|
+
message="确定清空购物车吗?"
|
|
108
|
+
confirm-text="确定"
|
|
109
|
+
:show-cancel-button="true"
|
|
110
|
+
@confirm="doClear"
|
|
111
|
+
/>
|
|
112
|
+
</template>
|
|
113
|
+
|
|
114
|
+
<script setup lang="ts">
|
|
115
|
+
import { computed, ref, watch } from 'vue'
|
|
116
|
+
import type { CSSProperties } from 'vue'
|
|
117
|
+
import DdBadge from '../dd-badge/dd-badge.vue'
|
|
118
|
+
import DdButton from '../dd-button/dd-button.vue'
|
|
119
|
+
import DdDialog from '../dd-dialog/dd-dialog.vue'
|
|
120
|
+
import DdGoodsCard from '../dd-goods-card/dd-goods-card.vue'
|
|
121
|
+
import DdIcon from '../dd-icon/dd-icon.vue'
|
|
122
|
+
import DdPopup from '../dd-popup/dd-popup.vue'
|
|
123
|
+
import DdPrice from '../dd-price/dd-price.vue'
|
|
124
|
+
import DdStepper from '../dd-stepper/dd-stepper.vue'
|
|
125
|
+
import type { DdCartItem } from './cart-bar'
|
|
126
|
+
// z-index 统一取 libs/config/zIndex.js(底栏 sticky 档;弹层打开时 popup 档内 +1 派生抬升)
|
|
127
|
+
import zIndexConfig from '../../libs/config/zIndex.js'
|
|
128
|
+
|
|
129
|
+
interface Props {
|
|
130
|
+
/** 购物车条目(受控);增减/清空经 change 回传新数组 */
|
|
131
|
+
items: DdCartItem[]
|
|
132
|
+
/** 购物车弹层显隐(v-model) */
|
|
133
|
+
modelValue?: boolean
|
|
134
|
+
/** 合计左侧文案 */
|
|
135
|
+
label?: string
|
|
136
|
+
/** 合计右侧附加文案(如「共减¥19」) */
|
|
137
|
+
suffixLabel?: string
|
|
138
|
+
/** 弹层顶部提示条(如凑单/温馨提示) */
|
|
139
|
+
tips?: string
|
|
140
|
+
/** 弹层标题 */
|
|
141
|
+
title?: string
|
|
142
|
+
/** 清空按钮文案 */
|
|
143
|
+
clearText?: string
|
|
144
|
+
/** 清空前是否二次确认(库内 dd-dialog) */
|
|
145
|
+
clearConfirm?: boolean
|
|
146
|
+
/** 货币符号 */
|
|
147
|
+
currency?: string
|
|
148
|
+
/** 结算按钮文案 */
|
|
149
|
+
buttonText?: string
|
|
150
|
+
/** 结算按钮类型(dd-button type) */
|
|
151
|
+
buttonType?: 'default' | 'primary' | 'secondary' | 'ghost' | 'text' | 'success' | 'warning' | 'danger'
|
|
152
|
+
/** 结算按钮自定义背景色 */
|
|
153
|
+
buttonColor?: string
|
|
154
|
+
/** 结算按钮加载态 */
|
|
155
|
+
loading?: boolean
|
|
156
|
+
/** 禁用结算(不影响数量增减;空车时自动禁用) */
|
|
157
|
+
disabled?: boolean
|
|
158
|
+
/** 列表最大高(默认 50vh) */
|
|
159
|
+
maxListHeight?: string
|
|
160
|
+
/** 固定在底部时是否生成占位视图 */
|
|
161
|
+
placeholder?: boolean
|
|
162
|
+
/** 是否预留底部安全区 */
|
|
163
|
+
safeAreaInsetBottom?: boolean
|
|
164
|
+
customStyle?: CSSProperties | string
|
|
165
|
+
customClass?: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
169
|
+
modelValue: false,
|
|
170
|
+
label: '',
|
|
171
|
+
suffixLabel: '',
|
|
172
|
+
tips: '',
|
|
173
|
+
title: '已选商品',
|
|
174
|
+
clearText: '清空购物车',
|
|
175
|
+
clearConfirm: true,
|
|
176
|
+
currency: '¥',
|
|
177
|
+
buttonText: '结算',
|
|
178
|
+
buttonType: 'primary',
|
|
179
|
+
buttonColor: '',
|
|
180
|
+
loading: false,
|
|
181
|
+
disabled: false,
|
|
182
|
+
maxListHeight: '50vh',
|
|
183
|
+
placeholder: false,
|
|
184
|
+
safeAreaInsetBottom: true,
|
|
185
|
+
customStyle: undefined,
|
|
186
|
+
customClass: '',
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
const emit = defineEmits<{
|
|
190
|
+
(e: 'update:modelValue', val: boolean): void
|
|
191
|
+
(e: 'open'): void
|
|
192
|
+
(e: 'close'): void
|
|
193
|
+
/** 数量增减/清空后的最新条目(减到 0 的项已剔除) */
|
|
194
|
+
(e: 'change', items: DdCartItem[]): void
|
|
195
|
+
(e: 'clear'): void
|
|
196
|
+
(e: 'submit'): void
|
|
197
|
+
(e: 'item-click', item: DdCartItem): void
|
|
198
|
+
}>()
|
|
199
|
+
|
|
200
|
+
const totalCount = computed(() => props.items.reduce((sum, it) => sum + (it.count || 0), 0))
|
|
201
|
+
|
|
202
|
+
// 合计(分→元),dd-price 直接展示
|
|
203
|
+
const totalYuan = computed(() => props.items.reduce((sum, it) => sum + (it.price || 0) * (it.count || 0), 0) / 100)
|
|
204
|
+
|
|
205
|
+
const buttonDisabled = computed(() => props.disabled || totalCount.value === 0)
|
|
206
|
+
|
|
207
|
+
// 弹层打开时栏抬升到 popup 档 +1,且保持到关闭动画结束(popup 的 closed 事件)才降回 sticky 档:
|
|
208
|
+
// 否则关闭瞬间栏先掉档,下滑中的面板(2001)会盖在栏(100)上面收起
|
|
209
|
+
const barElevated = ref(props.modelValue)
|
|
210
|
+
|
|
211
|
+
watch(
|
|
212
|
+
() => props.modelValue,
|
|
213
|
+
(val) => {
|
|
214
|
+
if (val) barElevated.value = true
|
|
215
|
+
},
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
function onPanelClosed() {
|
|
219
|
+
barElevated.value = false
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const barStyle = computed<CSSProperties>(() => ({
|
|
223
|
+
zIndex: barElevated.value ? zIndexConfig.popup + 1 : zIndexConfig.sticky,
|
|
224
|
+
}))
|
|
225
|
+
|
|
226
|
+
const buttonStyle = computed(() => (props.buttonColor ? { background: props.buttonColor } : undefined))
|
|
227
|
+
|
|
228
|
+
function onPopupUpdate(val: boolean) {
|
|
229
|
+
emit('update:modelValue', val)
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
function togglePopup() {
|
|
233
|
+
// 空车不允许撑开弹层(业界惯例:角标为 0 时入口不可点)
|
|
234
|
+
if (!props.modelValue && totalCount.value === 0) return
|
|
235
|
+
emit('update:modelValue', !props.modelValue)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function onCountChange(item: DdCartItem, val: number) {
|
|
239
|
+
if (val === item.count) return
|
|
240
|
+
emitChange(props.items.map((it) => (it.id === item.id ? { ...it, count: val } : it)))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// min=1 拦下减号:数量为 1 再减 = 移除该商品(stepper 此时不再发 change,只发 minus)
|
|
244
|
+
function onMinus(item: DdCartItem) {
|
|
245
|
+
if (item.count > 1) return
|
|
246
|
+
emitChange(props.items.filter((it) => it.id !== item.id))
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function emitChange(items: DdCartItem[]) {
|
|
250
|
+
emit('change', items)
|
|
251
|
+
// 减空/清空后自动收起弹层
|
|
252
|
+
if (items.length === 0 && props.modelValue) emit('update:modelValue', false)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** 清空二次确认弹窗显隐(dd-dialog 在模板尾部独立渲染,经 portal 提到页面根节点) */
|
|
256
|
+
const clearDialogVisible = ref(false)
|
|
257
|
+
|
|
258
|
+
function onClear() {
|
|
259
|
+
if (!props.items.length) return
|
|
260
|
+
if (!props.clearConfirm) return doClear()
|
|
261
|
+
clearDialogVisible.value = true
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function doClear() {
|
|
265
|
+
emitChange([])
|
|
266
|
+
emit('clear')
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function onSubmit() {
|
|
270
|
+
if (buttonDisabled.value || props.loading) return
|
|
271
|
+
emit('submit')
|
|
272
|
+
}
|
|
273
|
+
</script>
|
|
274
|
+
|
|
275
|
+
<style lang="scss" scoped>
|
|
276
|
+
@import '../../scss/variables';
|
|
277
|
+
@import '../../scss/mixins';
|
|
278
|
+
|
|
279
|
+
.dd-cart-bar {
|
|
280
|
+
position: fixed;
|
|
281
|
+
left: 0;
|
|
282
|
+
right: 0;
|
|
283
|
+
bottom: 0;
|
|
284
|
+
background: var(--dd-bg-card, #{$dd-bg-card});
|
|
285
|
+
|
|
286
|
+
&--safe {
|
|
287
|
+
@include dd-safe-area-bottom;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.dd-cart-bar__placeholder {
|
|
292
|
+
width: 100%;
|
|
293
|
+
height: 100rpx;
|
|
294
|
+
box-sizing: content-box;
|
|
295
|
+
|
|
296
|
+
&--safe {
|
|
297
|
+
@include dd-safe-area-bottom;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.dd-cart-bar__bar {
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
min-height: 100rpx;
|
|
305
|
+
padding: $dd-space-2 $dd-space-3;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// 入口圆钮:微凸出栏顶(外卖购物车标志视觉)
|
|
309
|
+
.dd-cart-bar__entry {
|
|
310
|
+
position: relative;
|
|
311
|
+
flex-shrink: 0;
|
|
312
|
+
margin-right: $dd-space-3;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.dd-cart-bar__cart {
|
|
316
|
+
display: flex;
|
|
317
|
+
align-items: center;
|
|
318
|
+
justify-content: center;
|
|
319
|
+
width: 88rpx;
|
|
320
|
+
height: 88rpx;
|
|
321
|
+
border-radius: $dd-radius-full;
|
|
322
|
+
background: var(--dd-primary, #{$dd-primary});
|
|
323
|
+
color: var(--dd-primary-contrast, #{$dd-primary-contrast});
|
|
324
|
+
box-shadow: var(--dd-shadow-1, #{$dd-shadow-1});
|
|
325
|
+
|
|
326
|
+
&--empty {
|
|
327
|
+
background: var(--dd-surface-container-low, #{$dd-surface-container-low});
|
|
328
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
329
|
+
box-shadow: none;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.dd-cart-bar__cart-icon {
|
|
334
|
+
font-size: 44rpx;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.dd-cart-bar__count {
|
|
338
|
+
position: absolute;
|
|
339
|
+
top: -6rpx;
|
|
340
|
+
right: -10rpx;
|
|
341
|
+
animation: dd-cart-bar-bounce 0.3s;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
@keyframes dd-cart-bar-bounce {
|
|
345
|
+
0% { transform: scale(0.5); }
|
|
346
|
+
60% { transform: scale(1.25); }
|
|
347
|
+
100% { transform: scale(1); }
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
.dd-cart-bar__text {
|
|
351
|
+
flex: 1;
|
|
352
|
+
padding-right: $dd-space-3;
|
|
353
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
354
|
+
font-size: $dd-font-size-body;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
.dd-cart-bar__price {
|
|
358
|
+
margin-left: $dd-space-1;
|
|
359
|
+
color: var(--dd-error, #{$dd-error});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.dd-cart-bar__suffix-label {
|
|
363
|
+
margin-left: $dd-space-1;
|
|
364
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
365
|
+
font-size: $dd-font-size-caption;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.dd-cart-bar__button {
|
|
369
|
+
flex-shrink: 0;
|
|
370
|
+
min-width: 200rpx;
|
|
371
|
+
margin-left: $dd-space-2;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.dd-cart-bar__panel {
|
|
375
|
+
// 底部留出栏高 + 安全区:弹层面板(popup 档)压在栏下方,内容不被栏遮挡
|
|
376
|
+
padding: $dd-space-3 $dd-space-3 calc(100rpx + $dd-space-2*2 + constant(safe-area-inset-bottom));
|
|
377
|
+
padding: $dd-space-3 $dd-space-3 calc(100rpx + $dd-space-2*2 + env(safe-area-inset-bottom));
|
|
378
|
+
box-sizing: border-box;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.dd-cart-bar__header {
|
|
382
|
+
display: flex;
|
|
383
|
+
align-items: center;
|
|
384
|
+
justify-content: space-between;
|
|
385
|
+
padding-bottom: $dd-space-2;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.dd-cart-bar__title {
|
|
389
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
390
|
+
font-size: $dd-font-size-h4;
|
|
391
|
+
font-weight: $dd-font-weight-h4;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.dd-cart-bar__clear {
|
|
395
|
+
display: flex;
|
|
396
|
+
align-items: center;
|
|
397
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
398
|
+
font-size: $dd-font-size-caption;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.dd-cart-bar__clear-icon {
|
|
402
|
+
margin-right: $dd-space-1;
|
|
403
|
+
font-size: 28rpx;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.dd-cart-bar__tips {
|
|
407
|
+
margin-bottom: $dd-space-2;
|
|
408
|
+
padding: $dd-space-2 $dd-space-3;
|
|
409
|
+
border-radius: $dd-radius-md;
|
|
410
|
+
background: var(--dd-surface-container-low, #{$dd-surface-container-low});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.dd-cart-bar__tips-text {
|
|
414
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
415
|
+
font-size: $dd-font-size-caption;
|
|
416
|
+
line-height: $dd-line-height-caption;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.dd-cart-bar__list {
|
|
420
|
+
box-sizing: border-box;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
// 列表行卡片间距(行本体是 dd-goods-card 小号横卡)
|
|
424
|
+
.dd-cart-bar__item-card {
|
|
425
|
+
& + & {
|
|
426
|
+
margin-top: $dd-space-2;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.dd-cart-bar__empty {
|
|
431
|
+
display: flex;
|
|
432
|
+
flex-direction: column;
|
|
433
|
+
align-items: center;
|
|
434
|
+
padding: $dd-space-8 0;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.dd-cart-bar__empty-icon {
|
|
438
|
+
margin-bottom: $dd-space-2;
|
|
439
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
440
|
+
font-size: 80rpx;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.dd-cart-bar__empty-text {
|
|
444
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
445
|
+
font-size: $dd-font-size-caption;
|
|
446
|
+
}
|
|
447
|
+
</style>
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
class="dd-goods-card"
|
|
4
4
|
:class="[
|
|
5
5
|
`dd-goods-card--${layout}`,
|
|
6
|
+
`dd-goods-card--${size}`,
|
|
6
7
|
{ 'dd-goods-card--disabled': disabled },
|
|
7
8
|
]"
|
|
8
9
|
:style="customStyle"
|
|
@@ -37,15 +38,18 @@
|
|
|
37
38
|
:rate="price"
|
|
38
39
|
:currency="currency"
|
|
39
40
|
:decimal-length="decimalLength"
|
|
41
|
+
:size="size"
|
|
40
42
|
></dd-price>
|
|
41
43
|
<text v-if="originPrice" class="dd-goods-card__price-origin">
|
|
42
44
|
{{ currency }}{{ originPrice }}
|
|
43
45
|
</text>
|
|
44
46
|
</view>
|
|
45
47
|
<!-- 价格行右侧扩展位(步进器/加购等与价格同排贴底);未用时回退已选数量 -->
|
|
46
|
-
<
|
|
47
|
-
<
|
|
48
|
-
|
|
48
|
+
<view class="dd-goods-card__price-right">
|
|
49
|
+
<slot name="price-right">
|
|
50
|
+
<text v-if="num" class="dd-goods-card__num">×{{ num }}</text>
|
|
51
|
+
</slot>
|
|
52
|
+
</view>
|
|
49
53
|
</view>
|
|
50
54
|
|
|
51
55
|
<view v-if="$slots.bottom" class="dd-goods-card__bottom">
|
|
@@ -82,6 +86,8 @@ interface Props {
|
|
|
82
86
|
tag?: string
|
|
83
87
|
/** 布局:horizontal 横向(左图右文)/ vertical 竖向(上图下文) */
|
|
84
88
|
layout?: 'horizontal' | 'vertical'
|
|
89
|
+
/** 尺寸:md 常规 / sm 小号(横向用于购物车列表行且不渲染描述,竖向用于一行三列宫格) */
|
|
90
|
+
size?: 'sm' | 'md'
|
|
85
91
|
/** 已选数量(右下角,不传不渲染) */
|
|
86
92
|
num?: string | number
|
|
87
93
|
/** 置灰(售罄等不可点场景) */
|
|
@@ -104,6 +110,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
104
110
|
decimalLength: 2,
|
|
105
111
|
tag: '',
|
|
106
112
|
layout: 'horizontal',
|
|
113
|
+
size: 'md',
|
|
107
114
|
num: '',
|
|
108
115
|
disabled: false,
|
|
109
116
|
thumbMode: 'aspectFill',
|
|
@@ -206,11 +213,8 @@ function onClick(e: Event) {
|
|
|
206
213
|
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
207
214
|
font-size: 24rpx;
|
|
208
215
|
line-height: 1.4;
|
|
209
|
-
//
|
|
210
|
-
|
|
211
|
-
-webkit-box-orient: vertical;
|
|
212
|
-
-webkit-line-clamp: 2;
|
|
213
|
-
overflow: hidden;
|
|
216
|
+
// 单行省略:给价格行(现价+划线价)留足横向空间,避免挤出右侧操作位
|
|
217
|
+
@include dd-ellipsis;
|
|
214
218
|
}
|
|
215
219
|
|
|
216
220
|
&__price-row {
|
|
@@ -221,6 +225,9 @@ function onClick(e: Event) {
|
|
|
221
225
|
}
|
|
222
226
|
|
|
223
227
|
&__price {
|
|
228
|
+
// 占满剩余宽度且可收缩,划线价过长时自身省略,不把右侧操作位挤出
|
|
229
|
+
flex: 1;
|
|
230
|
+
min-width: 0;
|
|
224
231
|
display: inline-flex;
|
|
225
232
|
align-items: baseline;
|
|
226
233
|
color: var(--dd-error-400, #{$dd-error-400});
|
|
@@ -233,10 +240,18 @@ function onClick(e: Event) {
|
|
|
233
240
|
font-size: 22rpx;
|
|
234
241
|
font-weight: 400;
|
|
235
242
|
text-decoration: line-through;
|
|
243
|
+
// 空间不足时划线价自身省略
|
|
244
|
+
overflow: hidden;
|
|
245
|
+
white-space: nowrap;
|
|
246
|
+
text-overflow: ellipsis;
|
|
236
247
|
}
|
|
237
248
|
|
|
238
|
-
&
|
|
249
|
+
&__price-right {
|
|
250
|
+
flex-shrink: 0;
|
|
239
251
|
margin-left: $dd-space-2;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
&__num {
|
|
240
255
|
color: var(--dd-text-tertiary, #{$dd-text-tertiary});
|
|
241
256
|
font-size: 24rpx;
|
|
242
257
|
}
|
|
@@ -280,4 +295,49 @@ function onClick(e: Event) {
|
|
|
280
295
|
padding: $dd-space-3;
|
|
281
296
|
}
|
|
282
297
|
}
|
|
298
|
+
|
|
299
|
+
// 小号卡:划线价随小号档缩小(价格字号由 dd-price size 联动)
|
|
300
|
+
.dd-goods-card--sm {
|
|
301
|
+
.dd-goods-card__price-origin {
|
|
302
|
+
font-size: 20rpx;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 小号横向(购物车列表行):96rpx 紧凑图 + 小字号,不渲染描述
|
|
307
|
+
.dd-goods-card--horizontal.dd-goods-card--sm {
|
|
308
|
+
padding: $dd-space-2;
|
|
309
|
+
|
|
310
|
+
.dd-goods-card__thumb {
|
|
311
|
+
width: 96rpx;
|
|
312
|
+
height: 96rpx;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.dd-goods-card__body {
|
|
316
|
+
padding-left: $dd-space-2;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.dd-goods-card__title {
|
|
320
|
+
font-size: 26rpx;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.dd-goods-card__num {
|
|
324
|
+
font-size: 22rpx;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// 小号竖向(一行三列宫格):方图 + 标题最多两行(对齐点选套餐页三列规格卡)
|
|
329
|
+
.dd-goods-card--vertical.dd-goods-card--sm {
|
|
330
|
+
.dd-goods-card__body {
|
|
331
|
+
padding: $dd-space-2;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.dd-goods-card__title {
|
|
335
|
+
font-size: 24rpx;
|
|
336
|
+
@include dd-ellipsis(2);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.dd-goods-card__desc {
|
|
340
|
+
font-size: 20rpx;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
283
343
|
</style>
|
|
@@ -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
|
|
151
|
-
return props.goodsInfo.stock
|
|
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
|
-
|
|
210
|
+
const comb = getSkuComb(tempSelected)
|
|
211
|
+
return !comb || stockOf(comb) <= 0
|
|
202
212
|
}
|
|
203
213
|
|
|
204
|
-
//
|
|
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 }} 件
|
|
@@ -64,6 +65,8 @@
|
|
|
64
65
|
</view>
|
|
65
66
|
</view>
|
|
66
67
|
</dd-popup>
|
|
68
|
+
<!-- 库内 toast(toast 档 2040,恒高于自身 popup 面板);单例状态,页面另有 dd-toast 时自动共用 -->
|
|
69
|
+
<dd-toast />
|
|
67
70
|
</view>
|
|
68
71
|
</template>
|
|
69
72
|
|
|
@@ -77,6 +80,7 @@
|
|
|
77
80
|
import { computed, reactive, ref } from 'vue'
|
|
78
81
|
import DdPopup from '../dd-popup/dd-popup.vue'
|
|
79
82
|
import DdButton from '../dd-button/dd-button.vue'
|
|
83
|
+
import DdToast, { showToast } from '../dd-toast/dd-toast.vue'
|
|
80
84
|
import { pickAvatarHue, avatarText as calcAvatarText } from '../../libs/utils'
|
|
81
85
|
import {
|
|
82
86
|
type PackageSkuGroup,
|
|
@@ -146,6 +150,8 @@ const price = computed(
|
|
|
146
150
|
surchargeFen.value) /
|
|
147
151
|
100,
|
|
148
152
|
)
|
|
153
|
+
/** 划线原价(元):套餐级营销价,不随加价联动;originPrice|origin_price,缺省不显示 */
|
|
154
|
+
const originPrice = computed(() => props.goodsInfo.originPrice || props.goodsInfo.origin_price || '')
|
|
149
155
|
/** 库存:缺省不显示库存行(套餐可能无台账库存,如房时套餐) */
|
|
150
156
|
const stock = computed(() => props.goodsInfo.stock ?? props.goodsInfo.quantity)
|
|
151
157
|
/** 已选项实时摘要(确认前即联动展示) */
|
|
@@ -177,7 +183,7 @@ function onItemClick(group: PackageSkuGroup, item: PackageSkuItem): void {
|
|
|
177
183
|
const key = String(group.id)
|
|
178
184
|
const next = nextSelection(group, selections[key] ?? [], item.id)
|
|
179
185
|
if (next === null) {
|
|
180
|
-
|
|
186
|
+
showToast({ message: `最多选择${groupMax(group)}项`, type: 'text' })
|
|
181
187
|
return
|
|
182
188
|
}
|
|
183
189
|
selections[key] = next
|
|
@@ -278,6 +284,15 @@ defineExpose({ open, close, reset })
|
|
|
278
284
|
color: var(--dd-error-400, #{$dd-error-400});
|
|
279
285
|
font-weight: bold;
|
|
280
286
|
}
|
|
287
|
+
|
|
288
|
+
// 划线原价(样式对齐 dd-goods-card / dd-goods-sku)
|
|
289
|
+
&__origin {
|
|
290
|
+
margin-left: $dd-space-2;
|
|
291
|
+
color: var(--dd-text-tertiary, #{$dd-text-tertiary});
|
|
292
|
+
font-size: 22rpx;
|
|
293
|
+
font-weight: 400;
|
|
294
|
+
text-decoration: line-through;
|
|
295
|
+
}
|
|
281
296
|
}
|
|
282
297
|
|
|
283
298
|
&__stock {
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
export interface PackageSkuItem {
|
|
5
5
|
id: string | number
|
|
6
6
|
name: string
|
|
7
|
-
/**
|
|
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)
|
|
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 ''
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view v-if="pricePair" class="dd-price">
|
|
2
|
+
<view v-if="pricePair" class="dd-price" :class="'dd-price--' + size">
|
|
3
3
|
<text v-if="prefix" class="dd-price__prefix">{{ prefix }}</text>
|
|
4
4
|
<text class="dd-price__currency">{{ currency }}</text>
|
|
5
5
|
<text class="dd-price__integer">{{ pricePair[0] }}</text>
|
|
@@ -24,6 +24,8 @@ interface Props {
|
|
|
24
24
|
prefix?: string
|
|
25
25
|
/** 额外后缀文案(如「起」) */
|
|
26
26
|
suffix?: string
|
|
27
|
+
/** 尺寸:sm 小号(购物车行/小卡)/ md 常规 / lg 大号(结算条/合计) */
|
|
28
|
+
size?: 'sm' | 'md' | 'lg'
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -33,6 +35,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
33
35
|
mark: '.',
|
|
34
36
|
prefix: '',
|
|
35
37
|
suffix: '',
|
|
38
|
+
size: 'md',
|
|
36
39
|
})
|
|
37
40
|
|
|
38
41
|
const pricePair = computed<string[] | null>(() => {
|
|
@@ -80,5 +83,33 @@ const pricePair = computed<string[] | null>(() => {
|
|
|
80
83
|
&__integer {
|
|
81
84
|
font-size: 36rpx;
|
|
82
85
|
}
|
|
86
|
+
|
|
87
|
+
// sm:购物车列表行 / 小号商品卡
|
|
88
|
+
&--sm {
|
|
89
|
+
.dd-price__prefix,
|
|
90
|
+
.dd-price__suffix,
|
|
91
|
+
.dd-price__currency,
|
|
92
|
+
.dd-price__decimal {
|
|
93
|
+
font-size: 20rpx;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.dd-price__integer {
|
|
97
|
+
font-size: 30rpx;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// lg:结算条 / 合计
|
|
102
|
+
&--lg {
|
|
103
|
+
.dd-price__prefix,
|
|
104
|
+
.dd-price__suffix,
|
|
105
|
+
.dd-price__currency,
|
|
106
|
+
.dd-price__decimal {
|
|
107
|
+
font-size: 28rpx;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.dd-price__integer {
|
|
111
|
+
font-size: 44rpx;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
83
114
|
}
|
|
84
115
|
</style>
|
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 (
|
|
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/libs/config/zIndex.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// z-index 唯一真源档位表(ADR 0013):组件只准选档或档内 +1 派生,禁止魔数。
|
|
2
2
|
// uniapp 在 H5 中各 API 的 z-index 平台事实(页面层必须低于它们):
|
|
3
3
|
// actionsheet: 999 / modal: 999 / toast: 999 / navigate: 998 / tabbar: 998
|
|
4
|
+
// → 提示类(modal/toast/actionsheet)经 scss/theme.scss 的 H5 补丁统一抬到 2050
|
|
5
|
+
// (高于本表全部档位),否则会压在库内弹层 overlay 2000+ 之下(如购物车面板开启时 confirm 被盖)。
|
|
4
6
|
|
|
5
7
|
export default {
|
|
6
8
|
base: 1, // 普通层内叠放
|
package/package.json
CHANGED
package/scss/theme.scss
CHANGED
|
@@ -12,12 +12,93 @@
|
|
|
12
12
|
// ============================================================
|
|
13
13
|
@import './variables';
|
|
14
14
|
@import './theme-tokens';
|
|
15
|
+
@import './mixins';
|
|
15
16
|
|
|
16
17
|
/* #ifdef H5 */
|
|
17
18
|
:root {
|
|
18
19
|
@include dd-theme($dd-vars-base);
|
|
19
20
|
@include dd-theme($dd-theme-dark);
|
|
20
21
|
}
|
|
22
|
+
|
|
23
|
+
// 平台提示类弹层补丁:uni 的 showModal/showToast/showActionSheet 在 H5 固定 z-index 999,
|
|
24
|
+
// 会被库内弹层(overlay 2000+,如购物车面板)压住;统一抬到 2050(高于本库最高档 toast 2040),
|
|
25
|
+
// 确保所有提示类弹框恒在最顶层。档位表见 libs/config/zIndex.js。
|
|
26
|
+
uni-modal,
|
|
27
|
+
uni-toast,
|
|
28
|
+
uni-actionsheet {
|
|
29
|
+
z-index: 2050 !important;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 平台弹层主题对齐:uni H5 的 showModal/showToast/showActionSheet 写死白底蓝按钮,
|
|
33
|
+
// 按选择器(取自 @dcloudio/uni-h5/style/api/*.css)覆写为库内 token,明暗主题跟随换肤。
|
|
34
|
+
// 选择器带元素前缀提高特异性,免 !important(z-index 除外,见上)。
|
|
35
|
+
uni-modal {
|
|
36
|
+
.uni-modal {
|
|
37
|
+
background-color: var(--dd-bg-elevated, #{$dd-bg-elevated});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.uni-modal__title {
|
|
41
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.uni-modal__bd {
|
|
45
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.uni-modal__ft:after,
|
|
49
|
+
.uni-modal__btn:after {
|
|
50
|
+
border-color: var(--dd-border-default, #{$dd-border-default});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ponytail: uni-h5 给按钮写内联 color(confirmColor 机制),只能 !important 压掉;
|
|
54
|
+
// 代价是 uni.showModal({ confirmColor }) 自定义色会被忽略(需要自定义色时用库内 dd-dialog)
|
|
55
|
+
.uni-modal__btn,
|
|
56
|
+
.uni-modal__btn_default {
|
|
57
|
+
color: var(--dd-text-primary, #{$dd-text-primary}) !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.uni-modal__btn_primary {
|
|
61
|
+
color: var(--dd-primary, #{$dd-primary}) !important;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.uni-modal__btn:active {
|
|
65
|
+
background-color: var(--dd-border-strong, #{$dd-border-strong});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 平台 toast 对齐库内 dd-toast 的玻璃胶囊风格
|
|
70
|
+
uni-toast {
|
|
71
|
+
.uni-toast,
|
|
72
|
+
.uni-simple-toast__text {
|
|
73
|
+
@include dd-glass;
|
|
74
|
+
border-radius: $dd-radius-full;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
uni-actionsheet {
|
|
79
|
+
.uni-actionsheet__menu,
|
|
80
|
+
.uni-actionsheet__action {
|
|
81
|
+
background-color: var(--dd-bg-elevated, #{$dd-bg-elevated});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.uni-actionsheet__title {
|
|
85
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
86
|
+
background-color: var(--dd-bg-elevated, #{$dd-bg-elevated});
|
|
87
|
+
border-bottom: 1px solid var(--dd-border-default, #{$dd-border-default});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.uni-actionsheet__cell {
|
|
91
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.uni-actionsheet__cell:before {
|
|
95
|
+
border-top-color: var(--dd-border-subtle, #{$dd-border-subtle});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.uni-actionsheet__cell:active {
|
|
99
|
+
background-color: var(--dd-border-strong, #{$dd-border-strong});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
21
102
|
/* #endif */
|
|
22
103
|
|
|
23
104
|
/* #ifndef H5 */
|