@didaoktv/didaoui-uniapp 2.8.0 → 2.9.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.
@@ -33,7 +33,7 @@ import DdIcon from '../dd-icon/dd-icon.vue'
33
33
 
34
34
  interface Props {
35
35
  type?: 'default' | 'primary' | 'secondary' | 'ghost' | 'text' | 'success' | 'warning' | 'danger'
36
- size?: 'sm' | 'md' | 'lg'
36
+ size?: 'xs' | 'sm' | 'md' | 'lg'
37
37
  block?: boolean
38
38
  round?: boolean
39
39
  plain?: boolean
@@ -126,6 +126,20 @@ function onClick(e: Event) {
126
126
  }
127
127
  }
128
128
 
129
+ .dd-btn--xs {
130
+ height: $dd-size-control-xs;
131
+ padding: 0 $dd-space-2;
132
+ font-size: $dd-font-size-caption;
133
+ &.dd-btn--icon-only {
134
+ width: $dd-size-control-xs;
135
+ }
136
+ .dd-btn__loading {
137
+ width: 18rpx;
138
+ height: 18rpx; // size-exempt: loading 圈内部件,非控件高度
139
+ border-width: 2rpx;
140
+ }
141
+ }
142
+
129
143
  .dd-btn--sm {
130
144
  height: $dd-size-control-sm;
131
145
  padding: 0 $dd-space-3;
@@ -3,6 +3,7 @@
3
3
  class="dd-card"
4
4
  :class="[
5
5
  `dd-card--${variant}`,
6
+ padClass,
6
7
  {
7
8
  'dd-card--border': border,
8
9
  'dd-card--active': active,
@@ -13,20 +14,30 @@
13
14
  :hover-stay-time="120"
14
15
  @click="onClick"
15
16
  >
16
- <view v-if="$slots.header || $slots.extra" class="dd-card__header">
17
+ <view
18
+ v-if="$slots.header || $slots.extra"
19
+ class="dd-card__header"
20
+ :style="padStyle"
21
+ >
17
22
  <view class="dd-card__header-inner"><slot name="header"></slot></view>
18
23
  <view v-if="$slots.extra" class="dd-card__extra"><slot name="extra"></slot></view>
19
24
  </view>
20
- <view class="dd-card__body"><slot></slot></view>
21
- <view v-if="$slots.footer" class="dd-card__footer"><slot name="footer"></slot></view>
25
+ <view class="dd-card__body" :style="padStyle"><slot></slot></view>
26
+ <view v-if="$slots.footer" class="dd-card__footer" :style="padStyle"><slot name="footer"></slot></view>
22
27
  </view>
23
28
  </template>
24
29
 
25
30
  <script setup lang="ts">
26
- import { useSlots } from 'vue'
31
+ import { computed, useSlots } from 'vue'
27
32
 
28
33
  interface Props {
29
34
  variant?: 'vertical' | 'horizontal' | 'compact'
35
+ /**
36
+ * 内边距(与 variant 正交,统一作用于 header/body/footer):
37
+ * 档位 none 贴边 / sm 12px / md 16px / lg 24px;也可直接给数字(按 px,如 `padding="24"` 或 `:padding="24"`)
38
+ * 不传=沿用 variant 默认档
39
+ */
40
+ padding?: '' | 'none' | 'sm' | 'md' | 'lg' | number | `${number}`
30
41
  border?: boolean
31
42
  active?: boolean
32
43
  hover?: boolean
@@ -35,12 +46,33 @@ interface Props {
35
46
 
36
47
  const props = withDefaults(defineProps<Props>(), {
37
48
  variant: 'vertical',
49
+ padding: '',
38
50
  border: true,
39
51
  active: false,
40
52
  hover: false,
41
53
  hoverable: false,
42
54
  })
43
55
 
56
+ /** 数字入参(或数字字符串)解析为 px;档位键/空值返回 null */
57
+ const customPadPx = computed<number | null>(() => {
58
+ const v = props.padding
59
+ if (typeof v === 'number') return v
60
+ if (typeof v === 'string' && /^\d+(\.\d+)?$/.test(v)) return Number(v)
61
+ return null
62
+ })
63
+
64
+ /** 档位键拼对应类名;数字入参走行内 style(见 padStyle);空值不覆盖 variant 默认档 */
65
+ const padClass = computed(() => {
66
+ const v = props.padding
67
+ if (!v || customPadPx.value !== null) return ''
68
+ return `dd-card--padding-${v}`
69
+ })
70
+
71
+ /** 自定义 px 用行内 style 直接落到三区(不依赖 CSS 变量,兼容各端) */
72
+ const padStyle = computed(() =>
73
+ customPadPx.value === null ? '' : { padding: `${customPadPx.value}px` },
74
+ )
75
+
44
76
  const emit = defineEmits<{ (e: 'click', val: Event): void }>()
45
77
 
46
78
  const slots = useSlots()
@@ -149,6 +181,17 @@ function onClick(e: Event) {
149
181
  }
150
182
  }
151
183
 
184
+ // 内边距档:与 variant 正交,显式覆盖头/体/尾三区(不传=沿用 variant 默认档;同权重靠后声明覆盖上面的 variant 规则)
185
+ @each $size, $pad in ('none': 0, 'sm': $dd-space-3, 'md': $dd-space-4, 'lg': $dd-space-5) {
186
+ .dd-card--padding-#{$size} {
187
+ .dd-card__header,
188
+ .dd-card__body,
189
+ .dd-card__footer {
190
+ padding: $pad;
191
+ }
192
+ }
193
+ }
194
+
152
195
  .dd-card--horizontal.dd-card--active {
153
196
  border: 2px solid var(--dd-primary, #{$dd-primary});
154
197
  }
@@ -68,7 +68,7 @@
68
68
  scroll-y
69
69
  :style="{ maxHeight: maxListHeight }"
70
70
  >
71
- <!-- 商品行复用 dd-goods-card 小号横卡(96rpx 紧凑图、不渲染描述、价格小一号);规格随卡 desc 传入(sm 档不显示),数量步进器走 price-right 插槽 -->
71
+ <!-- 商品行复用 dd-goods-card 小号横卡(96rpx 紧凑图、不渲染描述、价格小一号);规格随卡 desc 传入(sm 档不显示);数量步进器走 price-right 插槽 -->
72
72
  <dd-goods-card
73
73
  v-for="item in items"
74
74
  :key="item.id"
@@ -288,9 +288,12 @@ function onSubmit() {
288
288
  }
289
289
  }
290
290
 
291
+ // 占位块高度必须与固定栏实际高度一致:栏高由「操作钮 88rpx + 上下内边距」决定(min-height 不生效),
292
+ // 原占位块固定 100rpx 比真实栏矮约 16px,页面底部内容会被栏遮住
291
293
  .dd-cart-bar__placeholder {
292
294
  width: 100%;
293
- height: 100rpx;
295
+ height: $dd-size-control-md;
296
+ padding: $dd-space-2 0;
294
297
  box-sizing: content-box;
295
298
 
296
299
  &--safe {
@@ -301,6 +304,9 @@ function onSubmit() {
301
304
  .dd-cart-bar__bar {
302
305
  display: flex;
303
306
  align-items: center;
307
+ // 显式 border-box:栏高 = 88rpx + 上下内边距,与占位块的 content-box 镜像计算一致,
308
+ // 不受消费端是否引入 _reset.scss(全局 border-box)影响
309
+ box-sizing: border-box;
304
310
  min-height: 100rpx;
305
311
  padding: $dd-space-2 $dd-space-3;
306
312
  }
@@ -373,8 +379,8 @@ function onSubmit() {
373
379
 
374
380
  .dd-cart-bar__panel {
375
381
  // 底部留出栏高 + 安全区:弹层面板(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));
382
+ padding: $dd-space-3 $dd-space-3 calc(100rpx + $dd-space-2*3 + constant(safe-area-inset-bottom));
383
+ padding: $dd-space-3 $dd-space-3 calc(100rpx + $dd-space-2*3 + env(safe-area-inset-bottom));
378
384
  box-sizing: border-box;
379
385
  }
380
386
 
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <dd-portal>
3
3
  <view class="dd-dp" :class="{ 'dd-dp--open': show }">
4
- <view class="dd-dp__mask" :style="{ zIndex: zIndexConfig.overlay }" @click="onMaskClick"></view>
5
- <view class="dd-dp__sheet" :style="{ zIndex: zIndexConfig.popup }">
4
+ <view class="dd-dp__mask" :style="{ zIndex: maskZIndex }" @click="onMaskClick"></view>
5
+ <view class="dd-dp__sheet" :style="{ zIndex: sheetZIndex }">
6
6
  <view class="dd-dp__toolbar">
7
7
  <text class="dd-dp__cancel" @click="onCancel">取消</text>
8
8
  <text class="dd-dp__title">{{ title }}</text>
@@ -61,6 +61,10 @@ const indicatorStyle =
61
61
  'height:80rpx;background:rgba(255,193,7,0.08);border-top:1px solid rgba(255,193,7,0.3);border-bottom:1px solid rgba(255,193,7,0.3);box-shadow:0 0 20rpx rgba(255,193,7,0.15);'
62
62
 
63
63
  const indexes = ref<number[]>([])
64
+ // 与 dd-picker 同理:常从 dd-popup 面板内打开,遮罩需压过父面板(popup 档 2001)才能点击关闭
65
+ // ponytail: 上限低于 dialog 档(2010),若要在 dd-dialog 内打开需再抬一档
66
+ const maskZIndex = zIndexConfig.popup + 1
67
+ const sheetZIndex = zIndexConfig.popup + 1
64
68
 
65
69
  const yearList = computed(() => {
66
70
  const arr: string[] = []
@@ -139,7 +143,8 @@ watch(() => props.show, (v) => {
139
143
 
140
144
  function onPickerChange(e: any) {
141
145
  const val = (e?.detail?.value ?? []).slice()
142
- const dayIdx = props.type === 'date' || props.type === 'range' ? 2 : props.type === 'datetime' ? 3 : -1
146
+ // 列序:date/range = [年,月,日] → 日=2;datetime = [年,月,日,时,分] → 日=2;time 无日列
147
+ const dayIdx = props.type === 'date' || props.type === 'range' || props.type === 'datetime' ? 2 : -1
143
148
  if (dayIdx >= 0) {
144
149
  const y = startYear + (val[0] ?? 0)
145
150
  const m = (val[1] ?? 0) + 1
@@ -28,21 +28,29 @@
28
28
  <!-- 信息区 -->
29
29
  <view class="dd-goods-card__body">
30
30
  <slot name="default">
31
- <text v-if="title" class="dd-goods-card__title">{{ title }}</text>
31
+ <!-- 名称行:有 title-suffix 插槽时与名称同排(名称占满并省略,后缀贴右),否则等同原单行名称 -->
32
+ <view v-if="title || $slots['title-suffix']" class="dd-goods-card__title-row">
33
+ <text v-if="title" class="dd-goods-card__title">{{ title }}</text>
34
+ <slot name="title-suffix"></slot>
35
+ </view>
32
36
  <text v-if="desc" class="dd-goods-card__desc">{{ desc }}</text>
33
37
 
34
38
  <view class="dd-goods-card__price-row">
35
39
  <view class="dd-goods-card__price">
36
- <dd-price
37
- v-if="price !== undefined && price !== null && price !== ''"
38
- :rate="price"
39
- :currency="currency"
40
- :decimal-length="decimalLength"
41
- :size="size"
42
- ></dd-price>
43
- <text v-if="originPrice" class="dd-goods-card__price-origin">
44
- {{ currency }}{{ originPrice }}
45
- </text>
40
+ <!-- 价格位插槽:默认渲染 dd-price(+划线原价);使用方自定义(如赠品改「赠送」标签)时整块替换,
41
+ 此时 price / originPrice / currency 均不生效(插槽内容自负责展示) -->
42
+ <slot name="price">
43
+ <dd-price
44
+ v-if="price !== undefined && price !== null && price !== ''"
45
+ :rate="price"
46
+ :currency="currency"
47
+ :decimal-length="decimalLength"
48
+ :size="size"
49
+ ></dd-price>
50
+ <text v-if="originPrice" class="dd-goods-card__price-origin">
51
+ {{ currency }}{{ originPrice }}
52
+ </text>
53
+ </slot>
46
54
  </view>
47
55
  <!-- 价格行右侧扩展位(步进器/加购等与价格同排贴底);未用时回退已选数量 -->
48
56
  <view class="dd-goods-card__price-right flex_m">
@@ -200,7 +208,16 @@ function onClick(e: Event) {
200
208
  flex-direction: column;
201
209
  }
202
210
 
211
+ // 名称行:名称占满剩余宽度(自身省略),title-suffix 贴右不被压缩
212
+ &__title-row {
213
+ display: flex;
214
+ align-items: center;
215
+ min-width: 0;
216
+ }
217
+
203
218
  &__title {
219
+ flex: 1;
220
+ min-width: 0;
204
221
  color: var(--dd-text-primary, #{$dd-text-primary});
205
222
  font-size: 28rpx;
206
223
  font-weight: 600;
@@ -25,7 +25,7 @@
25
25
 
26
26
  <!-- 第二行:商品卡片横向滚动(竖向超小号)+ 右侧总价与件数(渐变蒙版压在最右侧) -->
27
27
  <view class="dd-order-list__goods">
28
- <scroll-view scroll-x class="dd-order-list__goods-scroll">
28
+ <scroll-view scroll-x :show-scrollbar="false" class="dd-order-list__goods-scroll">
29
29
  <view class="dd-order-list__goods-track">
30
30
  <view v-for="line in item.lines" :key="line.id" class="dd-order-list__goods-cell">
31
31
  <dd-goods-card
@@ -193,6 +193,14 @@ function onCardTap(item: DdOrderItem): void {
193
193
  .dd-order-list__goods-scroll {
194
194
  width: 100%;
195
195
  white-space: nowrap;
196
+ // 隐藏滚动条、保留横向滚动:H5/App-vue 走 CSS,小程序默认不显,App-nvue 由 show-scrollbar=false 兜底
197
+ scrollbar-width: none;
198
+
199
+ &::-webkit-scrollbar {
200
+ display: none;
201
+ width: 0;
202
+ height: 0;
203
+ }
196
204
  }
197
205
 
198
206
  .dd-order-list__goods-track {
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <dd-portal>
3
3
  <view class="dd-picker" :class="{ 'dd-picker--open': show }">
4
- <view class="dd-picker__mask" :style="{ zIndex: zIndexConfig.overlay }" @click="onMaskClick"></view>
5
- <view class="dd-picker__sheet" :style="{ zIndex: zIndexConfig.popup }">
4
+ <view class="dd-picker__mask" :style="{ zIndex: maskZIndex }" @click="onMaskClick"></view>
5
+ <view class="dd-picker__sheet" :style="{ zIndex: sheetZIndex }">
6
6
  <view class="dd-picker__toolbar">
7
7
  <text class="dd-picker__cancel" @click="onCancel">取消</text>
8
8
  <text class="dd-picker__title">{{ title }}</text>
@@ -76,6 +76,12 @@ const normalizedColumns = computed<PickerItem[][]>(() => {
76
76
 
77
77
  const indexes = ref<number[]>([])
78
78
 
79
+ // picker 常从 dd-popup 内打开(父面板同属 popup 档 2001):遮罩必须高于父面板,否则被面板盖住、
80
+ // 点到面板无法关闭;取 popup+1 派生,sheet 与 mask 同档但 DOM 在后,仍压在遮罩之上。
81
+ // ponytail: 上限低于 dialog 档(2010),若将来 picker 要从 dd-dialog 内打开需再抬一档。
82
+ const maskZIndex = zIndexConfig.popup + 1
83
+ const sheetZIndex = zIndexConfig.popup + 1
84
+
79
85
  watch(
80
86
  () => normalizedColumns.value,
81
87
  (cols) => {
@@ -1,5 +1,10 @@
1
1
  <template>
2
- <view v-if="pricePair" class="dd-price" :class="'dd-price--' + size">
2
+ <view
3
+ v-if="pricePair"
4
+ class="dd-price"
5
+ :class="['dd-price--' + size, { 'dd-price--custom-color': color }]"
6
+ :style="color ? { color } : undefined"
7
+ >
3
8
  <text v-if="prefix" class="dd-price__prefix">{{ prefix }}</text>
4
9
  <text class="dd-price__currency">{{ currency }}</text>
5
10
  <text class="dd-price__integer">{{ pricePair[0] }}</text>
@@ -24,8 +29,10 @@ interface Props {
24
29
  prefix?: string
25
30
  /** 额外后缀文案(如「起」) */
26
31
  suffix?: string
27
- /** 尺寸:xs 最小号(一行四列小卡)/ sm 小号(购物车行/小卡)/ md 常规 / lg 大号(结算条/合计) */
28
- size?: 'xs' | 'sm' | 'md' | 'lg'
32
+ /** 尺寸:xxs 紧凑行最小号(房态卡片等 22rpx 正文旁)/ xs 最小号(一行四列小卡)/ sm 小号(购物车行/小卡)/ md 常规 / lg 大号(结算条/合计) */
33
+ size?: 'xxs' | 'xs' | 'sm' | 'md' | 'lg'
34
+ /** 主色(CSS 颜色/变量):整数、货币符、小数一起变色;不传则 inherit 跟随上下文(货币符/小数保持次级灰) */
35
+ color?: string
29
36
  }
30
37
 
31
38
  const props = withDefaults(defineProps<Props>(), {
@@ -36,6 +43,7 @@ const props = withDefaults(defineProps<Props>(), {
36
43
  prefix: '',
37
44
  suffix: '',
38
45
  size: 'md',
46
+ color: '',
39
47
  })
40
48
 
41
49
  const pricePair = computed<string[] | null>(() => {
@@ -80,6 +88,14 @@ const pricePair = computed<string[] | null>(() => {
80
88
  font-size: 24rpx;
81
89
  }
82
90
 
91
+ // 自定义主色:货币符/小数默认是次级灰,传 color 时统一跟随主色
92
+ &--custom-color {
93
+ .dd-price__currency,
94
+ .dd-price__decimal {
95
+ color: inherit;
96
+ }
97
+ }
98
+
83
99
  &__integer {
84
100
  font-size: 36rpx;
85
101
  }
@@ -112,6 +128,20 @@ const pricePair = computed<string[] | null>(() => {
112
128
  }
113
129
  }
114
130
 
131
+ // xxs:紧凑行最小号(房态卡片等 22rpx 正文旁,整数对齐正文、符号再压一档)
132
+ &--xxs {
133
+ .dd-price__prefix,
134
+ .dd-price__suffix,
135
+ .dd-price__currency,
136
+ .dd-price__decimal {
137
+ font-size: 16rpx;
138
+ }
139
+
140
+ .dd-price__integer {
141
+ font-size: 22rpx;
142
+ }
143
+ }
144
+
115
145
  // lg:结算条 / 合计
116
146
  &--lg {
117
147
  .dd-price__prefix,
@@ -137,9 +137,12 @@ function onSubmit() {
137
137
  }
138
138
  }
139
139
 
140
+ // 占位块高度必须与固定条实际高度一致:条高由「按钮高度 + 上下内边距」决定(min-height 反而不生效),
141
+ // 原占位块固定 100rpx,在真机上是 100rpx + 安全区,比真实条矮约 16px,底部内容被遮住
140
142
  .dd-submit-bar__placeholder {
141
143
  width: 100%;
142
- height: 100rpx;
144
+ height: $dd-size-control-md;
145
+ padding: $dd-space-2 0;
143
146
  box-sizing: content-box;
144
147
 
145
148
  &--safe {
@@ -165,6 +168,9 @@ function onSubmit() {
165
168
  .dd-submit-bar__bar {
166
169
  display: flex;
167
170
  align-items: center;
171
+ // 显式 border-box:条高 = 按钮 88rpx + 上下内边距,与占位块的 content-box 镜像计算一致,
172
+ // 不受消费端是否引入 _reset.scss(全局 border-box)影响
173
+ box-sizing: border-box;
168
174
  min-height: 100rpx;
169
175
  padding: $dd-space-2 $dd-space-3;
170
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@didaoktv/didaoui-uniapp",
3
- "version": "2.8.0",
3
+ "version": "2.9.0",
4
4
  "description": "帝到KTV UniApp 组件库",
5
5
  "main": "index.ts",
6
6
  "types": "index.ts",
@@ -269,6 +269,7 @@ $dd-size-icon-lg: 24px !default;
269
269
  $dd-size-icon-xl: 32px !default;
270
270
 
271
271
  // 控件高度档位真源(ADR 0019):输入类与按钮类同档消费同一变量;值 = css.json size × 2(1px=2rpx)
272
+ $dd-size-control-xs: 52rpx !default;
272
273
  $dd-size-control-sm: 64rpx !default;
273
274
  $dd-size-control-compact: 72rpx !default;
274
275
  $dd-size-control-md: 88rpx !default;