@didaoktv/didaoui-uniapp 2.1.0 → 2.3.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-button/dd-button.vue +9 -9
- package/components/dd-capsule-button/dd-capsule-button.vue +2 -2
- package/components/dd-empty-state/dd-empty-state.vue +1 -1
- package/components/dd-field/dd-field.vue +4 -2
- package/components/dd-input/dd-input.vue +2 -2
- package/components/dd-package-sku/dd-package-sku.vue +277 -0
- package/components/dd-package-sku/package-sku.ts +124 -0
- package/components/dd-picker/dd-picker.vue +4 -4
- package/components/dd-search-bar/dd-search-bar.vue +2 -2
- package/components/dd-stepper/dd-stepper.vue +4 -4
- package/index.ts +11 -3
- package/package.json +2 -1
- package/scss/_variables.scss +6 -8
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
- **帝王级配色** — 帝王金 `#F5A623` + 皇家蓝 `#2D4BA0` 双主色,暗色主题默认
|
|
8
8
|
- **玻璃拟态设计** — 多层级玻璃拟态效果,打造高端夜店沉浸感
|
|
9
|
-
- **
|
|
9
|
+
- **97 个精心打磨的组件** — 覆盖表单、导航、布局卡片、数据展示、浮层反馈、交互、画布七大类,含 KTV 业务组件(房态卡、账单明细、工单卡、日历、二维码)
|
|
10
10
|
- **Vue3 + TypeScript** — 完整类型定义,Composition API
|
|
11
11
|
- **多端兼容** — H5 / 微信小程序 / 抖音小程序 / Android / iOS
|
|
12
12
|
|
|
@@ -50,7 +50,7 @@ import { DdButton, DdInput } from '@didaoktv/didaoui-uniapp'
|
|
|
50
50
|
|
|
51
51
|
| 分类 | 数量 | 组件 |
|
|
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
|
| 布局/卡片 | 10 | Card, RoomCard, GoodsCard, FeatureGrid, Sticky, BillDetail, WorkorderCard, Calendar, Qrcode, SubmitBar |
|
|
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 |
|
|
@@ -80,7 +80,7 @@ function onClick(e: Event) {
|
|
|
80
80
|
font-family: $dd-font-body;
|
|
81
81
|
white-space: nowrap;
|
|
82
82
|
user-select: none;
|
|
83
|
-
height: $dd-size-
|
|
83
|
+
height: $dd-size-control-md;
|
|
84
84
|
padding: 0 $dd-space-4;
|
|
85
85
|
font-size: $dd-font-size-body;
|
|
86
86
|
font-weight: 600;
|
|
@@ -97,7 +97,7 @@ function onClick(e: Event) {
|
|
|
97
97
|
|
|
98
98
|
&__loading {
|
|
99
99
|
width: 28rpx;
|
|
100
|
-
height: 28rpx;
|
|
100
|
+
height: 28rpx; // size-exempt: loading 圈内部件,非控件高度
|
|
101
101
|
border: 3rpx solid currentColor;
|
|
102
102
|
border-top-color: transparent;
|
|
103
103
|
border-radius: 50%;
|
|
@@ -106,7 +106,7 @@ function onClick(e: Event) {
|
|
|
106
106
|
|
|
107
107
|
.dd-btn--icon-only {
|
|
108
108
|
padding: 0;
|
|
109
|
-
width: $dd-size-
|
|
109
|
+
width: $dd-size-control-md;
|
|
110
110
|
gap: 0;
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -127,28 +127,28 @@ function onClick(e: Event) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
.dd-btn--sm {
|
|
130
|
-
height: $dd-size-
|
|
130
|
+
height: $dd-size-control-sm;
|
|
131
131
|
padding: 0 $dd-space-3;
|
|
132
132
|
font-size: $dd-font-size-caption;
|
|
133
133
|
&.dd-btn--icon-only {
|
|
134
|
-
width: $dd-size-
|
|
134
|
+
width: $dd-size-control-sm;
|
|
135
135
|
}
|
|
136
136
|
.dd-btn__loading {
|
|
137
137
|
width: 22rpx;
|
|
138
|
-
height: 22rpx;
|
|
138
|
+
height: 22rpx; // size-exempt: loading 圈内部件,非控件高度
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
.dd-btn--lg {
|
|
143
|
-
height: $dd-size-
|
|
143
|
+
height: $dd-size-control-lg;
|
|
144
144
|
padding: 0 $dd-space-5;
|
|
145
145
|
font-size: $dd-font-size-h4;
|
|
146
146
|
&.dd-btn--icon-only {
|
|
147
|
-
width: $dd-size-
|
|
147
|
+
width: $dd-size-control-lg;
|
|
148
148
|
}
|
|
149
149
|
.dd-btn__loading {
|
|
150
150
|
width: 34rpx;
|
|
151
|
-
height: 34rpx;
|
|
151
|
+
height: 34rpx; // size-exempt: loading 圈内部件,非控件高度
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -56,7 +56,7 @@ function onMenu() {
|
|
|
56
56
|
// 微信小程序标准 87×32px → 174×64rpx (ponytail: 固定尺寸,H5 降级同样尺寸)
|
|
57
57
|
.dd-capsule-button {
|
|
58
58
|
width: 174rpx;
|
|
59
|
-
height: $dd-size-
|
|
59
|
+
height: $dd-size-control-sm;
|
|
60
60
|
border-radius: $dd-radius-full;
|
|
61
61
|
@include dd-glass;
|
|
62
62
|
display: flex;
|
|
@@ -77,7 +77,7 @@ function onMenu() {
|
|
|
77
77
|
// CSS 绘制返回箭头 "<": border-left+border-bottom + rotate(45deg) (无 SVG,MP 兼容)
|
|
78
78
|
&__arrow {
|
|
79
79
|
width: 20rpx;
|
|
80
|
-
height: 20rpx;
|
|
80
|
+
height: 20rpx; // size-exempt: CSS 绘制箭头内部件
|
|
81
81
|
border-left: $dd-space-1 solid var(--dd-text-secondary, #{$dd-text-secondary});
|
|
82
82
|
border-bottom: $dd-space-1 solid var(--dd-text-secondary, #{$dd-text-secondary});
|
|
83
83
|
transform: rotate(45deg);
|
|
@@ -114,7 +114,7 @@ function onAction() {
|
|
|
114
114
|
&__btn {
|
|
115
115
|
margin-top: $dd-space-5;
|
|
116
116
|
padding: 0 $dd-space-5;
|
|
117
|
-
height: $dd-size-
|
|
117
|
+
height: $dd-size-control-md;
|
|
118
118
|
border-radius: $dd-radius-full;
|
|
119
119
|
background: var(--dd-gradient-primary, #{$dd-gradient-primary});
|
|
120
120
|
@include dd-flex-center;
|
|
@@ -435,6 +435,8 @@ defineExpose({ validate, validateWithTrigger, resetValidation, scrollIntoView, f
|
|
|
435
435
|
flex-wrap: wrap; // extra 插槽独占第二行
|
|
436
436
|
box-sizing: border-box;
|
|
437
437
|
width: 100%;
|
|
438
|
+
// 单行/多行统一以 md 档为下限(border-box 下 padding 已含);textarea 靠内容自然增高,min-height 不限高
|
|
439
|
+
min-height: $dd-size-control-md;
|
|
438
440
|
padding: 20rpx $dd-space-4;
|
|
439
441
|
overflow: hidden;
|
|
440
442
|
font-size: $dd-font-size-body;
|
|
@@ -517,7 +519,7 @@ defineExpose({ validate, validateWithTrigger, resetValidation, scrollIntoView, f
|
|
|
517
519
|
align-items: center;
|
|
518
520
|
flex: 1;
|
|
519
521
|
min-width: 0;
|
|
520
|
-
min-height: 48rpx;
|
|
522
|
+
min-height: 48rpx; // size-exempt: 控件行内部最小高,非档位
|
|
521
523
|
}
|
|
522
524
|
|
|
523
525
|
&__control {
|
|
@@ -545,7 +547,7 @@ defineExpose({ validate, validateWithTrigger, resetValidation, scrollIntoView, f
|
|
|
545
547
|
}
|
|
546
548
|
|
|
547
549
|
&__textarea {
|
|
548
|
-
min-height: 48rpx;
|
|
550
|
+
min-height: 48rpx; // size-exempt: textarea 内部最小高,非档位
|
|
549
551
|
}
|
|
550
552
|
|
|
551
553
|
&__left-icon {
|
|
@@ -114,7 +114,7 @@ function toggleVisible() {
|
|
|
114
114
|
display: flex;
|
|
115
115
|
align-items: center;
|
|
116
116
|
gap: $dd-space-2;
|
|
117
|
-
height:
|
|
117
|
+
height: $dd-size-control-md;
|
|
118
118
|
padding: 0 $dd-space-4;
|
|
119
119
|
background: var(--dd-surface-container-low, #{$dd-surface-container-low});
|
|
120
120
|
border: 1px solid var(--dd-border-default, #{$dd-border-default});
|
|
@@ -141,7 +141,7 @@ function toggleVisible() {
|
|
|
141
141
|
&__clear {
|
|
142
142
|
@include dd-flex-center;
|
|
143
143
|
width: 36rpx;
|
|
144
|
-
height: 36rpx;
|
|
144
|
+
height: 36rpx; // size-exempt: clear 图标内部件
|
|
145
145
|
border-radius: 50%;
|
|
146
146
|
background: var(--dd-surface-container-high, #{$dd-surface-container-high});
|
|
147
147
|
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="dd-package-sku">
|
|
3
|
+
<view @click="open">
|
|
4
|
+
<slot name="trigger"></slot>
|
|
5
|
+
</view>
|
|
6
|
+
<dd-popup
|
|
7
|
+
v-model="show"
|
|
8
|
+
position="bottom"
|
|
9
|
+
round
|
|
10
|
+
:closeable="closeable"
|
|
11
|
+
@close="close"
|
|
12
|
+
>
|
|
13
|
+
<view class="dd-package-sku__container">
|
|
14
|
+
<view class="dd-package-sku__title">{{ title }}</view>
|
|
15
|
+
|
|
16
|
+
<scroll-view class="dd-package-sku__content" scroll-y>
|
|
17
|
+
<view v-for="group in groups" :key="group.id" class="dd-package-sku__group">
|
|
18
|
+
<view class="dd-package-sku__group__header">
|
|
19
|
+
<text class="dd-package-sku__group__header__name">{{ group.name }}</text>
|
|
20
|
+
<text class="dd-package-sku__group__header__hint">{{ hintText(group) }}</text>
|
|
21
|
+
</view>
|
|
22
|
+
<view class="dd-package-sku__group__list">
|
|
23
|
+
<view
|
|
24
|
+
v-for="item in group.items"
|
|
25
|
+
:key="item.id"
|
|
26
|
+
class="dd-package-sku__chip"
|
|
27
|
+
:class="{
|
|
28
|
+
'dd-package-sku__chip--active': isSelected(group, item),
|
|
29
|
+
'dd-package-sku__chip--disabled': itemDisabled(item),
|
|
30
|
+
'dd-package-sku__chip--fixed': isFixedGroup(group),
|
|
31
|
+
}"
|
|
32
|
+
@click="onItemClick(group, item)"
|
|
33
|
+
>
|
|
34
|
+
<text>{{ item.name }}</text>
|
|
35
|
+
<text v-if="surchargeText(item)" class="dd-package-sku__chip__surcharge">{{ surchargeText(item) }}</text>
|
|
36
|
+
<text v-if="itemDisabled(item)" class="dd-package-sku__chip__soldout">已售罄</text>
|
|
37
|
+
</view>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
</scroll-view>
|
|
41
|
+
|
|
42
|
+
<view class="dd-package-sku__footer">
|
|
43
|
+
<text v-if="!canConfirmNow" class="dd-package-sku__footer__tip">{{ unmetTip }}</text>
|
|
44
|
+
<dd-button type="primary" :disabled="!canConfirmNow" @click="onConfirm">
|
|
45
|
+
{{ confirmText }}
|
|
46
|
+
</dd-button>
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
</dd-popup>
|
|
50
|
+
</view>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script setup lang="ts">
|
|
54
|
+
/**
|
|
55
|
+
* 套餐可选组选择弹层(N选M 多选 + 加价 + 售罄置灰)
|
|
56
|
+
* - groups 通用形状,不绑业务 DTO;FIXED 组只读展示,OPTIONAL 组按 minSel/maxSel 校验
|
|
57
|
+
* - confirm emit { options:[{groupId,skuId}], surchargeFen, selectedText };确认后不自动关闭,由调用方 ref.close()
|
|
58
|
+
*/
|
|
59
|
+
import { computed, reactive, ref } from 'vue'
|
|
60
|
+
import DdPopup from '../dd-popup/dd-popup.vue'
|
|
61
|
+
import DdButton from '../dd-button/dd-button.vue'
|
|
62
|
+
import {
|
|
63
|
+
type PackageSkuGroup,
|
|
64
|
+
type PackageSkuItem,
|
|
65
|
+
type PackageSkuOption,
|
|
66
|
+
type PackageSkuSelections,
|
|
67
|
+
isFixed,
|
|
68
|
+
isItemDisabled,
|
|
69
|
+
groupHint,
|
|
70
|
+
groupMax,
|
|
71
|
+
isGroupSatisfied,
|
|
72
|
+
canConfirm as calcCanConfirm,
|
|
73
|
+
unmetText,
|
|
74
|
+
buildOptions,
|
|
75
|
+
computeSurchargeFen,
|
|
76
|
+
buildSelectedText,
|
|
77
|
+
surchargeLabel,
|
|
78
|
+
} from './package-sku'
|
|
79
|
+
|
|
80
|
+
interface Props {
|
|
81
|
+
/** 选择组列表 */
|
|
82
|
+
groups?: PackageSkuGroup[]
|
|
83
|
+
/** 弹层标题 */
|
|
84
|
+
title?: string
|
|
85
|
+
/** 确认按钮文字 */
|
|
86
|
+
confirmText?: string
|
|
87
|
+
/** 是否显示关闭弹窗按钮 */
|
|
88
|
+
closeable?: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
92
|
+
groups: () => [],
|
|
93
|
+
title: '选择套餐内容',
|
|
94
|
+
confirmText: '确定',
|
|
95
|
+
closeable: true,
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const emit = defineEmits<{
|
|
99
|
+
(e: 'open'): void
|
|
100
|
+
(e: 'confirm', val: { options: PackageSkuOption[]; surchargeFen: number; selectedText: string }): void
|
|
101
|
+
(e: 'close'): void
|
|
102
|
+
}>()
|
|
103
|
+
|
|
104
|
+
const show = ref(false)
|
|
105
|
+
/** 已选项:key = String(group.id) */
|
|
106
|
+
const selections = reactive<PackageSkuSelections>({})
|
|
107
|
+
|
|
108
|
+
const canConfirmNow = computed(() => calcCanConfirm(props.groups, selections))
|
|
109
|
+
const unmetTip = computed(() => unmetText(props.groups, selections))
|
|
110
|
+
|
|
111
|
+
// 模板内避免复杂表达式(小程序约束),逐一下沉为方法
|
|
112
|
+
function isFixedGroup(group: PackageSkuGroup): boolean {
|
|
113
|
+
return isFixed(group)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function itemDisabled(item: PackageSkuItem): boolean {
|
|
117
|
+
return isItemDisabled(item)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function hintText(group: PackageSkuGroup): string {
|
|
121
|
+
return groupHint(group)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function surchargeText(item: PackageSkuItem): string {
|
|
125
|
+
return surchargeLabel(item)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function isSelected(group: PackageSkuGroup, item: PackageSkuItem): boolean {
|
|
129
|
+
return (selections[String(group.id)] ?? []).includes(item.id)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function onItemClick(group: PackageSkuGroup, item: PackageSkuItem): void {
|
|
133
|
+
if (isFixed(group) || isItemDisabled(item)) return
|
|
134
|
+
const key = String(group.id)
|
|
135
|
+
const selected = selections[key] ?? []
|
|
136
|
+
const at = selected.indexOf(item.id)
|
|
137
|
+
if (at >= 0) {
|
|
138
|
+
selected.splice(at, 1)
|
|
139
|
+
} else if (selected.length >= groupMax(group)) {
|
|
140
|
+
uni.showToast({ title: `最多选择${groupMax(group)}项`, icon: 'none' })
|
|
141
|
+
return
|
|
142
|
+
} else {
|
|
143
|
+
selected.push(item.id)
|
|
144
|
+
}
|
|
145
|
+
selections[key] = selected
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function reset(): void {
|
|
149
|
+
Object.keys(selections).forEach((key) => delete selections[key])
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function open(): void {
|
|
153
|
+
show.value = true
|
|
154
|
+
emit('open')
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function close(): void {
|
|
158
|
+
show.value = false
|
|
159
|
+
emit('close')
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function onConfirm(): void {
|
|
163
|
+
if (!canConfirmNow.value) return
|
|
164
|
+
emit('confirm', {
|
|
165
|
+
options: buildOptions(props.groups, selections),
|
|
166
|
+
surchargeFen: computeSurchargeFen(props.groups, selections),
|
|
167
|
+
selectedText: buildSelectedText(props.groups, selections),
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
defineExpose({ open, close, reset })
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<style lang="scss" scoped>
|
|
175
|
+
@import '../../scss/variables';
|
|
176
|
+
@import '../../scss/mixins';
|
|
177
|
+
|
|
178
|
+
.dd-package-sku {
|
|
179
|
+
background-color: var(--dd-bg-elevated, #{$dd-bg-elevated});
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
|
|
182
|
+
&__container {
|
|
183
|
+
padding: 4rpx 30rpx;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
&__title {
|
|
187
|
+
padding: 30rpx 0 10rpx;
|
|
188
|
+
font-size: 32rpx;
|
|
189
|
+
font-weight: bold;
|
|
190
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&__content {
|
|
194
|
+
max-height: 640rpx;
|
|
195
|
+
padding-bottom: 10rpx;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&__group {
|
|
199
|
+
margin-bottom: 30rpx;
|
|
200
|
+
|
|
201
|
+
&__header {
|
|
202
|
+
display: flex;
|
|
203
|
+
flex-direction: row;
|
|
204
|
+
align-items: baseline;
|
|
205
|
+
justify-content: space-between;
|
|
206
|
+
margin-bottom: 20rpx;
|
|
207
|
+
|
|
208
|
+
&__name {
|
|
209
|
+
font-size: 28rpx;
|
|
210
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&__hint {
|
|
214
|
+
font-size: 24rpx;
|
|
215
|
+
color: var(--dd-text-tertiary, #{$dd-text-tertiary});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
&__list {
|
|
220
|
+
display: flex;
|
|
221
|
+
flex-direction: row;
|
|
222
|
+
flex-wrap: wrap;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&__chip {
|
|
227
|
+
display: flex;
|
|
228
|
+
flex-direction: row;
|
|
229
|
+
align-items: center;
|
|
230
|
+
padding: 10rpx 20rpx;
|
|
231
|
+
border: 2rpx solid var(--dd-border-default, #{$dd-border-default});
|
|
232
|
+
border-radius: 10rpx;
|
|
233
|
+
margin-right: 20rpx;
|
|
234
|
+
margin-bottom: 20rpx;
|
|
235
|
+
font-size: 26rpx;
|
|
236
|
+
color: var(--dd-text-primary, #{$dd-text-primary});
|
|
237
|
+
background-color: var(--dd-bg-elevated, #{$dd-bg-elevated});
|
|
238
|
+
|
|
239
|
+
&--active {
|
|
240
|
+
border-color: var(--dd-primary, #{$dd-primary});
|
|
241
|
+
color: var(--dd-primary, #{$dd-primary});
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
&--disabled {
|
|
245
|
+
color: var(--dd-muted, #{$dd-muted});
|
|
246
|
+
border-color: var(--dd-border-default, #{$dd-border-default});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
&--fixed {
|
|
250
|
+
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
&__surcharge {
|
|
254
|
+
margin-left: 8rpx;
|
|
255
|
+
font-size: 24rpx;
|
|
256
|
+
color: var(--dd-error-400, #{$dd-error-400});
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
&__soldout {
|
|
260
|
+
margin-left: 8rpx;
|
|
261
|
+
font-size: 22rpx;
|
|
262
|
+
color: var(--dd-error-400, #{$dd-error-400});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
&__footer {
|
|
267
|
+
padding: 20rpx 0 40rpx 0;
|
|
268
|
+
|
|
269
|
+
&__tip {
|
|
270
|
+
display: block;
|
|
271
|
+
margin-bottom: 16rpx;
|
|
272
|
+
font-size: 24rpx;
|
|
273
|
+
color: var(--dd-error-400, #{$dd-error-400});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
</style>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// dd-package-sku 纯逻辑(可选组 N选M 校验/加价合计/文案),供组件与 scripts/package-sku-selfcheck.ts 共用
|
|
2
|
+
// ponytail: 通用形状不绑业务 DTO;qty 缺省视为不限量(enabled 缺省视为可选)
|
|
3
|
+
|
|
4
|
+
export interface PackageSkuItem {
|
|
5
|
+
id: string | number
|
|
6
|
+
name: string
|
|
7
|
+
/** 加价金额(分),0/缺省 = 不加价 */
|
|
8
|
+
priceFen?: number
|
|
9
|
+
/** 库存数量,<=0 置灰;缺省视为有货 */
|
|
10
|
+
qty?: number
|
|
11
|
+
/** false 置灰;缺省视为可用 */
|
|
12
|
+
enabled?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface PackageSkuGroup {
|
|
16
|
+
id: string | number
|
|
17
|
+
name: string
|
|
18
|
+
/** 最少选择数,缺省 0 */
|
|
19
|
+
minSel?: number
|
|
20
|
+
/** 最多选择数,缺省 = items.length */
|
|
21
|
+
maxSel?: number
|
|
22
|
+
/** FIXED = 只读展示不可选;缺省 OPTIONAL */
|
|
23
|
+
groupType?: 'FIXED' | 'OPTIONAL'
|
|
24
|
+
items: PackageSkuItem[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface PackageSkuOption {
|
|
28
|
+
groupId: string | number
|
|
29
|
+
skuId: string | number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 选择状态:key = String(group.id),value = 已选 item.id 数组 */
|
|
33
|
+
export type PackageSkuSelections = Record<string, (string | number)[]>
|
|
34
|
+
|
|
35
|
+
export function isFixed(group: PackageSkuGroup): boolean {
|
|
36
|
+
return group.groupType === 'FIXED'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isItemDisabled(item: PackageSkuItem): boolean {
|
|
40
|
+
return item.enabled === false || (item.qty !== undefined && item.qty <= 0)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function groupMin(group: PackageSkuGroup): number {
|
|
44
|
+
return group.minSel ?? 0
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function groupMax(group: PackageSkuGroup): number {
|
|
48
|
+
return group.maxSel ?? group.items.length
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 组标题右侧文案:N选M / 选x~y项 / 最多选y项;FIXED 无文案 */
|
|
52
|
+
export function groupHint(group: PackageSkuGroup): string {
|
|
53
|
+
if (isFixed(group)) return ''
|
|
54
|
+
const min = groupMin(group)
|
|
55
|
+
const max = groupMax(group)
|
|
56
|
+
if (min === max) return `${group.items.length}选${max}`
|
|
57
|
+
if (min > 0) return `选${min}~${max}项`
|
|
58
|
+
return `最多选${max}项`
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** 组是否已选满最低要求(上限在点击时拦截,不会超) */
|
|
62
|
+
export function isGroupSatisfied(group: PackageSkuGroup, selections: PackageSkuSelections): boolean {
|
|
63
|
+
if (isFixed(group)) return true
|
|
64
|
+
const selected = selections[String(group.id)] ?? []
|
|
65
|
+
return selected.length >= groupMin(group)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function canConfirm(groups: PackageSkuGroup[], selections: PackageSkuSelections): boolean {
|
|
69
|
+
return groups.every((g) => isGroupSatisfied(g, selections))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 首个未满足组的提示文案(全部满足返回空串) */
|
|
73
|
+
export function unmetText(groups: PackageSkuGroup[], selections: PackageSkuSelections): string {
|
|
74
|
+
for (const g of groups) {
|
|
75
|
+
if (isFixed(g)) continue
|
|
76
|
+
const need = groupMin(g) - (selections[String(g.id)] ?? []).length
|
|
77
|
+
if (need > 0) return `「${g.name}」还需选择 ${need} 项`
|
|
78
|
+
}
|
|
79
|
+
return ''
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function buildOptions(groups: PackageSkuGroup[], selections: PackageSkuSelections): PackageSkuOption[] {
|
|
83
|
+
const options: PackageSkuOption[] = []
|
|
84
|
+
for (const g of groups) {
|
|
85
|
+
if (isFixed(g)) continue
|
|
86
|
+
for (const skuId of selections[String(g.id)] ?? []) {
|
|
87
|
+
options.push({ groupId: g.id, skuId })
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return options
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** 已选 OPTIONAL 项加价合计(分) */
|
|
94
|
+
export function computeSurchargeFen(groups: PackageSkuGroup[], selections: PackageSkuSelections): number {
|
|
95
|
+
let sum = 0
|
|
96
|
+
for (const g of groups) {
|
|
97
|
+
if (isFixed(g)) continue
|
|
98
|
+
for (const skuId of selections[String(g.id)] ?? []) {
|
|
99
|
+
const item = g.items.find((it) => it.id === skuId)
|
|
100
|
+
sum += item?.priceFen ?? 0
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return sum
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 已选 OPTIONAL 项名称顿号拼接 */
|
|
107
|
+
export function buildSelectedText(groups: PackageSkuGroup[], selections: PackageSkuSelections): string {
|
|
108
|
+
const names: string[] = []
|
|
109
|
+
for (const g of groups) {
|
|
110
|
+
if (isFixed(g)) continue
|
|
111
|
+
for (const skuId of selections[String(g.id)] ?? []) {
|
|
112
|
+
const item = g.items.find((it) => it.id === skuId)
|
|
113
|
+
if (item) names.push(item.name)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return names.join('、')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** 加价标签:「+¥X」(元,去尾零);无加价返回空串 */
|
|
120
|
+
export function surchargeLabel(item: PackageSkuItem): string {
|
|
121
|
+
const fen = item.priceFen ?? 0
|
|
122
|
+
if (fen <= 0) return ''
|
|
123
|
+
return `+¥${fen / 100}`
|
|
124
|
+
}
|
|
@@ -142,7 +142,7 @@ function onConfirm() {
|
|
|
142
142
|
// ponytail: H5 picker-view 吸附 itemSize 取 indicator 框高度(默认34px),必须与行高一致拖动松手才对齐。
|
|
143
143
|
// 需与下方 .dd-picker__item 的 88rpx 保持一致;改行高时必须同步改这里。小程序为原生组件此规则天然无效,安全。
|
|
144
144
|
:deep(.uni-picker-view-indicator) {
|
|
145
|
-
height: 88rpx;
|
|
145
|
+
height: 88rpx; // size-exempt: 滚轮选项行高(列表项),非控件高度
|
|
146
146
|
}
|
|
147
147
|
.dd-picker {
|
|
148
148
|
&__mask {
|
|
@@ -176,7 +176,7 @@ function onConfirm() {
|
|
|
176
176
|
|
|
177
177
|
&__toolbar {
|
|
178
178
|
@include dd-flex-between;
|
|
179
|
-
height: 96rpx;
|
|
179
|
+
height: 96rpx; // size-exempt: 弹层头部,非控件高度
|
|
180
180
|
padding: 0 32rpx;
|
|
181
181
|
@include dd-hairline-bottom(var(--dd-border-default, #{$dd-border-default}));
|
|
182
182
|
}
|
|
@@ -203,12 +203,12 @@ function onConfirm() {
|
|
|
203
203
|
}
|
|
204
204
|
&__wheels {
|
|
205
205
|
width: 100%;
|
|
206
|
-
height: 440rpx;
|
|
206
|
+
height: 440rpx; // size-exempt: 弹层滚轮区,非控件高度
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
&__item {
|
|
210
210
|
@include dd-flex-center;
|
|
211
|
-
height: 88rpx;
|
|
211
|
+
height: 88rpx; // size-exempt: 滚轮选项行高(列表项),非控件高度
|
|
212
212
|
}
|
|
213
213
|
&__item-text {
|
|
214
214
|
font-size: 28rpx;
|
|
@@ -107,7 +107,7 @@ function onCancel() {
|
|
|
107
107
|
display: flex;
|
|
108
108
|
align-items: center;
|
|
109
109
|
gap: $dd-space-2;
|
|
110
|
-
height:
|
|
110
|
+
height: $dd-size-control-md;
|
|
111
111
|
padding: 0 $dd-space-3;
|
|
112
112
|
background: var(--dd-surface-container-low, #{$dd-surface-container-low});
|
|
113
113
|
border: 1px solid var(--dd-border-default, #{$dd-border-default});
|
|
@@ -149,7 +149,7 @@ function onCancel() {
|
|
|
149
149
|
&__clear {
|
|
150
150
|
@include dd-flex-center;
|
|
151
151
|
width: 36rpx;
|
|
152
|
-
height: 36rpx;
|
|
152
|
+
height: 36rpx; // size-exempt: clear 图标内部件
|
|
153
153
|
border-radius: 50%;
|
|
154
154
|
background: var(--dd-surface-container-high, #{$dd-surface-container-high});
|
|
155
155
|
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
@@ -140,10 +140,10 @@ function onPlus() {
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
.dd-stepper--md {
|
|
143
|
-
height:
|
|
143
|
+
height: $dd-size-control-compact;
|
|
144
144
|
.dd-stepper__btn {
|
|
145
145
|
width: 56rpx;
|
|
146
|
-
height: 56rpx;
|
|
146
|
+
height: 56rpx; // size-exempt: 步进器内部按钮
|
|
147
147
|
}
|
|
148
148
|
.dd-stepper__icon {
|
|
149
149
|
font-size: $dd-font-size-h4;
|
|
@@ -155,10 +155,10 @@ function onPlus() {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
.dd-stepper--sm {
|
|
158
|
-
height: 56rpx;
|
|
158
|
+
height: 56rpx; // size-exempt: sm 档变体,档位体系外(本轮仅 md→compact 入档)
|
|
159
159
|
.dd-stepper__btn {
|
|
160
160
|
width: 44rpx;
|
|
161
|
-
height: 44rpx;
|
|
161
|
+
height: 44rpx; // size-exempt: 步进器内部按钮
|
|
162
162
|
}
|
|
163
163
|
.dd-stepper__icon {
|
|
164
164
|
font-size: 26rpx;
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { App } from 'vue'
|
|
2
2
|
|
|
3
|
-
// === Input (
|
|
3
|
+
// === Input (25) ===
|
|
4
4
|
import DdButton from './components/dd-button/dd-button.vue'
|
|
5
5
|
import DdCodeButton from './components/dd-code-button/dd-code-button.vue'
|
|
6
6
|
import DdInput from './components/dd-input/dd-input.vue'
|
|
@@ -24,6 +24,7 @@ import DdNumberKeyboard from './components/dd-number-keyboard/dd-number-keyboard
|
|
|
24
24
|
import DdCarKeyboard from './components/dd-car-keyboard/dd-car-keyboard.vue'
|
|
25
25
|
import DdCascader from './components/dd-cascader/dd-cascader.vue'
|
|
26
26
|
import DdGoodsSku from './components/dd-goods-sku/dd-goods-sku.vue'
|
|
27
|
+
import DdPackageSku from './components/dd-package-sku/dd-package-sku.vue'
|
|
27
28
|
import DdTreeSelect from './components/dd-tree-select/dd-tree-select.vue'
|
|
28
29
|
|
|
29
30
|
// === Navigation (14) ===
|
|
@@ -116,7 +117,7 @@ const components = {
|
|
|
116
117
|
DdButton, DdCodeButton, DdInput, DdSwitch, DdCheckbox, DdCheckboxGroup, DdRadio, DdRadioGroup, DdForm,
|
|
117
118
|
DdSearchBar, DdSlider, DdStepper, DdDatePicker, DdField,
|
|
118
119
|
DdPicker, DdRate, DdUpload, DdIcon,
|
|
119
|
-
DdKeyboard, DdNumberKeyboard, DdCarKeyboard, DdCascader, DdGoodsSku, DdTreeSelect,
|
|
120
|
+
DdKeyboard, DdNumberKeyboard, DdCarKeyboard, DdCascader, DdGoodsSku, DdPackageSku, DdTreeSelect,
|
|
120
121
|
DdNavigation, DdTopNavbar, DdSegmentedTab, DdSwipeableTab,
|
|
121
122
|
DdDrawer, DdTabbar, DdTabbarItem, DdBacktop,
|
|
122
123
|
DdCollapse, DdCollapseItem, DdDropdownMenu, DdDropdownItem,
|
|
@@ -148,7 +149,7 @@ export {
|
|
|
148
149
|
DdButton, DdCodeButton, DdInput, DdSwitch, DdCheckbox, DdCheckboxGroup, DdRadio, DdRadioGroup, DdForm,
|
|
149
150
|
DdSearchBar, DdSlider, DdStepper, DdDatePicker, DdField,
|
|
150
151
|
DdPicker, DdRate, DdUpload, DdIcon,
|
|
151
|
-
DdKeyboard, DdNumberKeyboard, DdCarKeyboard, DdCascader, DdGoodsSku, DdTreeSelect,
|
|
152
|
+
DdKeyboard, DdNumberKeyboard, DdCarKeyboard, DdCascader, DdGoodsSku, DdPackageSku, DdTreeSelect,
|
|
152
153
|
DdNavigation, DdTopNavbar, DdSegmentedTab, DdSwipeableTab,
|
|
153
154
|
DdDrawer, DdTabbar, DdTabbarItem, DdBacktop,
|
|
154
155
|
DdCollapse, DdCollapseItem, DdDropdownMenu, DdDropdownItem,
|
|
@@ -176,5 +177,12 @@ export type {
|
|
|
176
177
|
DdFormContext,
|
|
177
178
|
} from './components/dd-form/rules'
|
|
178
179
|
|
|
180
|
+
// 套餐可选组类型(dd-package-sku 配套)
|
|
181
|
+
export type {
|
|
182
|
+
PackageSkuItem,
|
|
183
|
+
PackageSkuGroup,
|
|
184
|
+
PackageSkuOption,
|
|
185
|
+
} from './components/dd-package-sku/package-sku'
|
|
186
|
+
|
|
179
187
|
// 图标元数据(供 demo/文档消费,与 dd-icon.vue 内 SCSS &-- 规则保持一致)
|
|
180
188
|
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.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "帝到KTV UniApp 组件库",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"types": "index.ts",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"dev:h5": "cd ../DidaoUI-uniapp-docs/h5-demo && npm run dev:h5",
|
|
25
25
|
"build:docs": "cd ../DidaoUI-uniapp-docs && npm run build",
|
|
26
26
|
"type-check": "vue-tsc --noEmit",
|
|
27
|
+
"size-selfcheck": "npx tsc scripts/size-selfcheck.ts --module commonjs --target es2020 --lib es2020 --outDir .check --skipLibCheck && node .check/size-selfcheck.js",
|
|
27
28
|
"bump:consumers": "node scripts/bump-consumers.mjs",
|
|
28
29
|
"prepublishOnly": "node -e \"const p=require('./package.json');if(p.publishConfig&&p.publishConfig.access==='public'){process.exit(0)}console.error('publishConfig.access must be public');process.exit(1)\""
|
|
29
30
|
},
|
package/scss/_variables.scss
CHANGED
|
@@ -267,19 +267,17 @@ $dd-size-icon-sm: 16px !default;
|
|
|
267
267
|
$dd-size-icon-md: 20px !default;
|
|
268
268
|
$dd-size-icon-lg: 24px !default;
|
|
269
269
|
$dd-size-icon-xl: 32px !default;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
$dd-size-
|
|
273
|
-
$dd-size-
|
|
270
|
+
|
|
271
|
+
// 控件高度档位真源(ADR 0019):输入类与按钮类同档消费同一变量;值 = css.json size × 2(1px=2rpx)
|
|
272
|
+
$dd-size-control-sm: 64rpx !default;
|
|
273
|
+
$dd-size-control-compact: 72rpx !default;
|
|
274
|
+
$dd-size-control-md: 88rpx !default;
|
|
275
|
+
$dd-size-control-lg: 100rpx !default;
|
|
274
276
|
|
|
275
277
|
// 按钮内边距
|
|
276
278
|
$dd-button-padding-x-sm: 12px !default;
|
|
277
279
|
$dd-button-padding-x-md: 16px !default;
|
|
278
280
|
$dd-button-padding-x-lg: 24px !default;
|
|
279
|
-
$dd-button-height-sm: $dd-size-button-sm !default;
|
|
280
|
-
$dd-button-height-md: $dd-size-button-md !default;
|
|
281
|
-
$dd-button-height-lg: $dd-size-button-lg !default;
|
|
282
|
-
$dd-input-height: $dd-size-input-height !default;
|
|
283
281
|
|
|
284
282
|
// === 阴影 (from css.json shadow) ===
|
|
285
283
|
$dd-shadow-1: 0 2px 8px rgba(0, 0, 0, 0.3) !default;
|