@didaoktv/didaoui-uniapp 1.3.8 → 1.4.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.
@@ -195,7 +195,7 @@ onUnmounted(() => {
195
195
  z-index: 1001;
196
196
  max-width: 720rpx; // 360px 上限
197
197
  max-height: 80vh;
198
- background: var(--dd-bg-elevated, #{$dd-bg-elevated});
198
+ background: var(--dd-bg-popup, #{$dd-bg-popup});
199
199
  border: 1px solid var(--dd-border-default, #{$dd-border-default});
200
200
  border-radius: $dd-radius-xl;
201
201
  box-shadow: var(--dd-shadow-4, #{$dd-shadow-4});
@@ -219,7 +219,7 @@ onUnmounted(() => {
219
219
  transform: translateY(100%);
220
220
  z-index: 1001;
221
221
  max-height: 85vh;
222
- background: var(--dd-bg-elevated, #{$dd-bg-elevated});
222
+ background: var(--dd-bg-popup, #{$dd-bg-popup});
223
223
  border: 1px solid var(--dd-border-default, #{$dd-border-default});
224
224
  border-radius: $dd-radius-xl $dd-radius-xl 0 0;
225
225
  box-shadow: var(--dd-shadow-4, #{$dd-shadow-4});
@@ -150,7 +150,7 @@
150
150
  $dd-number-keyboard-background-color: var(--dd-bg-section, #{$dd-bg-section}) !default;
151
151
  $dd-number-keyboard-padding:8px 10rpx 8px 10rpx !default;
152
152
  $dd-number-keyboard-gap:6rpx !default;
153
- $dd-number-keyboard-button-border-radius:var(--dd-radius-sm, #{$dd-radius-sm}) !default;
153
+ $dd-number-keyboard-button-border-radius:$dd-radius-sm !default;
154
154
  $dd-number-keyboard-button-height: 90rpx!default;
155
155
  $dd-number-keyboard-button-background-color:var(--dd-surface-container-high, #{$dd-surface-container-high}) !default;
156
156
  $dd-number-keyboard-button-box-shadow:0 2px 0px var(--dd-bg, #{$dd-bg}) !default;
@@ -159,7 +159,7 @@ function onConfirm() {
159
159
  right: 0;
160
160
  bottom: 0;
161
161
  z-index: $dd-z-index-popup;
162
- background: var(--dd-bg-elevated, #{$dd-bg-elevated});
162
+ background: var(--dd-bg-popup, #{$dd-bg-popup});
163
163
  border-radius: $dd-radius-lg $dd-radius-lg 0 0;
164
164
  transform: translateY(100%);
165
165
  @include dd-transition(transform 0.3s);
@@ -121,9 +121,9 @@ provide('ddPopover', {
121
121
  z-index: 2000;
122
122
 
123
123
  &--light {
124
- background: var(--dd-bg-elevated, #{$dd-bg-elevated});
124
+ background: var(--dd-bg-popup, #{$dd-bg-popup});
125
125
  color: var(--dd-text-primary, #{$dd-text-primary});
126
- .dd-popover__arrow { background: var(--dd-bg-elevated, #{$dd-bg-elevated}); }
126
+ .dd-popover__arrow { background: var(--dd-bg-popup, #{$dd-bg-popup}); }
127
127
  }
128
128
  &--dark {
129
129
  background: $dd-neutral-700;
@@ -171,7 +171,7 @@ onUnmounted(() => {
171
171
 
172
172
  &__panel {
173
173
  position: fixed;
174
- background: var(--dd-bg-elevated, #{$dd-bg-elevated});
174
+ background: var(--dd-bg-popup, #{$dd-bg-popup});
175
175
  box-shadow: var(--dd-shadow-3, #{$dd-shadow-3});
176
176
  transition: transform var(--dd-popup-duration, 0.3s) ease,
177
177
  opacity var(--dd-popup-duration, 0.3s) ease;
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <view v-if="pricePair" class="dd-price">
3
+ <text v-if="prefix" class="dd-price__prefix">{{ prefix }}</text>
4
+ <text class="dd-price__currency">{{ currency }}</text>
5
+ <text class="dd-price__integer">{{ pricePair[0] }}</text>
6
+ <text v-if="pricePair[1]" class="dd-price__decimal">{{ mark }}{{ pricePair[1] }}</text>
7
+ <text v-if="suffix" class="dd-price__suffix">{{ suffix }}</text>
8
+ </view>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { computed } from 'vue'
13
+
14
+ interface Props {
15
+ /** 金额(元,直接展示不除以 100);不传不渲染 */
16
+ rate?: number | string
17
+ /** 小数位数(rate 为 number 时生效,0 隐藏小数) */
18
+ decimalLength?: string | number
19
+ /** 货币符号 */
20
+ currency?: string
21
+ /** 整数/小数分隔符 */
22
+ mark?: string
23
+ /** 额外前缀文案(货币符之前) */
24
+ prefix?: string
25
+ /** 额外后缀文案(如「起」) */
26
+ suffix?: string
27
+ }
28
+
29
+ const props = withDefaults(defineProps<Props>(), {
30
+ rate: undefined,
31
+ decimalLength: 2,
32
+ currency: '¥',
33
+ mark: '.',
34
+ prefix: '',
35
+ suffix: '',
36
+ })
37
+
38
+ const pricePair = computed<string[] | null>(() => {
39
+ if (props.rate === undefined || props.rate === null || props.rate === '') return null
40
+ if (typeof props.rate === 'number') {
41
+ const len = Math.max(0, Number(props.decimalLength) || 0)
42
+ return props.rate.toFixed(len).split('.')
43
+ }
44
+ return props.rate.split('.')
45
+ })
46
+ </script>
47
+
48
+ <style lang="scss" scoped>
49
+ @import '../../scss/variables';
50
+ @import '../../scss/mixins';
51
+
52
+ .dd-price {
53
+ display: inline-flex;
54
+ align-items: baseline;
55
+ // ponytail: 颜色跟随使用方(inherit),Vant 亦由上下文(如 submit-bar 红价)控制
56
+ color: inherit;
57
+ font-weight: 600;
58
+ line-height: 1;
59
+
60
+ &__prefix,
61
+ &__suffix {
62
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
63
+ font-size: 24rpx;
64
+ font-weight: 400;
65
+ }
66
+
67
+ &__prefix {
68
+ margin-right: $dd-space-1;
69
+ }
70
+
71
+ &__suffix {
72
+ margin-left: $dd-space-1;
73
+ }
74
+
75
+ &__currency,
76
+ &__decimal {
77
+ font-size: 24rpx;
78
+ }
79
+
80
+ &__integer {
81
+ font-size: 36rpx;
82
+ }
83
+ }
84
+ </style>
@@ -0,0 +1,54 @@
1
+ <template>
2
+ <view class="dd-sidebar">
3
+ <slot></slot>
4
+ </view>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed, provide, ref } from 'vue'
9
+
10
+ interface Props {
11
+ /** 当前选中项的索引(v-model) */
12
+ modelValue?: number
13
+ }
14
+
15
+ const props = withDefaults(defineProps<Props>(), {
16
+ modelValue: 0,
17
+ })
18
+
19
+ const emit = defineEmits<{
20
+ (e: 'update:modelValue', val: number): void
21
+ (e: 'change', val: number): void
22
+ }>()
23
+
24
+ const counter = ref(0)
25
+
26
+ function register(): number {
27
+ const idx = counter.value
28
+ counter.value += 1
29
+ return idx
30
+ }
31
+
32
+ function onItemClick(idx: number) {
33
+ if (idx === props.modelValue) return
34
+ emit('update:modelValue', idx)
35
+ emit('change', idx)
36
+ }
37
+
38
+ provide('ddSidebar', {
39
+ active: computed(() => props.modelValue),
40
+ register,
41
+ onItemClick,
42
+ })
43
+ </script>
44
+
45
+ <style lang="scss" scoped>
46
+ @import '../../scss/variables';
47
+ @import '../../scss/mixins';
48
+
49
+ .dd-sidebar {
50
+ display: flex;
51
+ flex-direction: column;
52
+ background: var(--dd-bg-section, #{$dd-bg-section});
53
+ }
54
+ </style>
@@ -0,0 +1,129 @@
1
+ <template>
2
+ <view
3
+ class="dd-sidebar-item"
4
+ :class="[
5
+ customClass,
6
+ {
7
+ 'dd-sidebar-item--active': isActive,
8
+ 'dd-sidebar-item--disabled': disabled,
9
+ },
10
+ ]"
11
+ @click="onClick"
12
+ >
13
+ <view class="dd-sidebar-item__text">
14
+ <slot name="title">{{ title }}</slot>
15
+ </view>
16
+ <view v-if="badge" class="dd-sidebar-item__badge">
17
+ <text class="dd-sidebar-item__badge-text">{{ badge }}</text>
18
+ </view>
19
+ <view v-else-if="dot" class="dd-sidebar-item__dot"></view>
20
+ </view>
21
+ </template>
22
+
23
+ <script setup lang="ts">
24
+ import { computed, inject, ref } from 'vue'
25
+
26
+ interface Props {
27
+ /** 导航项文案 */
28
+ title?: string
29
+ /** 右上角红点 */
30
+ dot?: boolean
31
+ /** 右上角徽标数 */
32
+ badge?: string | number
33
+ /** 禁用(点击不切换、不触发 click) */
34
+ disabled?: boolean
35
+ /** 额外类名 */
36
+ customClass?: string
37
+ }
38
+
39
+ const props = withDefaults(defineProps<Props>(), {
40
+ title: '',
41
+ dot: false,
42
+ badge: '',
43
+ disabled: false,
44
+ customClass: '',
45
+ })
46
+
47
+ const emit = defineEmits<{
48
+ (e: 'click', index: number): void
49
+ }>()
50
+
51
+ const ctx = inject<any>('ddSidebar', null)
52
+ const fallbackIdx = ref(ctx ? ctx.register() : 0)
53
+
54
+ const isActive = computed(() => (ctx ? ctx.active.value === fallbackIdx.value : false))
55
+
56
+ function onClick() {
57
+ if (props.disabled) return
58
+ ctx?.onItemClick(fallbackIdx.value)
59
+ emit('click', fallbackIdx.value)
60
+ }
61
+ </script>
62
+
63
+ <style lang="scss" scoped>
64
+ @import '../../scss/variables';
65
+ @import '../../scss/mixins';
66
+
67
+ .dd-sidebar-item {
68
+ position: relative;
69
+ padding: $dd-space-4 $dd-space-3;
70
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
71
+ font-size: $dd-font-size-body;
72
+ line-height: $dd-line-height-body;
73
+
74
+ &--active {
75
+ background: var(--dd-bg-card, #{$dd-bg-card});
76
+ color: var(--dd-text-primary, #{$dd-text-primary});
77
+ font-weight: 600;
78
+
79
+ // 左侧金色选中条
80
+ &::before {
81
+ content: '';
82
+ position: absolute;
83
+ left: 0;
84
+ top: 50%;
85
+ transform: translateY(-50%);
86
+ width: 6rpx;
87
+ height: 32rpx;
88
+ border-radius: 0 $dd-radius-full $dd-radius-full 0;
89
+ background: var(--dd-primary, #{$dd-primary});
90
+ }
91
+ }
92
+
93
+ &--disabled {
94
+ color: var(--dd-text-tertiary, #{$dd-text-tertiary});
95
+ }
96
+
97
+ &__text {
98
+ @include dd-ellipsis(1);
99
+ }
100
+
101
+ &__badge {
102
+ position: absolute;
103
+ top: $dd-space-2;
104
+ right: $dd-space-2;
105
+ min-width: $dd-space-4;
106
+ height: $dd-space-4;
107
+ padding: 0 $dd-space-1;
108
+ border-radius: $dd-radius-full;
109
+ background: var(--dd-error, #{$dd-error});
110
+ @include dd-flex-center;
111
+ }
112
+
113
+ &__badge-text {
114
+ color: $dd-color-white;
115
+ font-size: 20rpx;
116
+ line-height: 1;
117
+ }
118
+
119
+ &__dot {
120
+ position: absolute;
121
+ top: $dd-space-2;
122
+ right: $dd-space-2;
123
+ width: $dd-space-2;
124
+ height: $dd-space-2;
125
+ border-radius: 50%;
126
+ background: var(--dd-error, #{$dd-error});
127
+ }
128
+ }
129
+ </style>
@@ -0,0 +1,194 @@
1
+ <template>
2
+ <view
3
+ v-if="placeholder"
4
+ class="dd-submit-bar__placeholder"
5
+ :class="{ 'dd-submit-bar__placeholder--safe': safeAreaInsetBottom }"
6
+ ></view>
7
+ <view class="dd-submit-bar" :class="{ 'dd-submit-bar--safe': safeAreaInsetBottom }">
8
+ <slot name="top"></slot>
9
+ <view v-if="hasTip" class="dd-submit-bar__tip">
10
+ <dd-icon v-if="tipIcon" :name="tipIcon" class="dd-submit-bar__tip-icon" />
11
+ <text v-if="tip" class="dd-submit-bar__tip-text">{{ tip }}</text>
12
+ <slot name="tip"></slot>
13
+ </view>
14
+ <view class="dd-submit-bar__bar">
15
+ <slot></slot>
16
+ <view v-if="hasPrice" class="dd-submit-bar__text" :style="textStyle">
17
+ <text class="dd-submit-bar__label">{{ label }}</text>
18
+ <dd-price
19
+ class="dd-submit-bar__price"
20
+ :rate="priceYuan"
21
+ :currency="currency"
22
+ :decimal-length="decimalLength"
23
+ />
24
+ <text v-if="suffixLabel" class="dd-submit-bar__suffix-label">{{ suffixLabel }}</text>
25
+ </view>
26
+ <slot name="button">
27
+ <dd-button
28
+ class="dd-submit-bar__button"
29
+ round
30
+ :type="buttonType"
31
+ :style="buttonStyle"
32
+ :loading="loading"
33
+ :disabled="disabled"
34
+ @click="onSubmit"
35
+ >{{ buttonText }}</dd-button>
36
+ </slot>
37
+ </view>
38
+ </view>
39
+ </template>
40
+
41
+ <script setup lang="ts">
42
+ import { computed, useSlots } from 'vue'
43
+ import type { CSSProperties } from 'vue'
44
+ import DdButton from '../dd-button/dd-button.vue'
45
+ import DdIcon from '../dd-icon/dd-icon.vue'
46
+ import DdPrice from '../dd-price/dd-price.vue'
47
+
48
+ interface Props {
49
+ /** 提示文案(tip 区域,如「小计不含服务费」) */
50
+ tip?: string
51
+ /** 价格左侧文案 */
52
+ label?: string
53
+ /** 价格(单位:分),传 number 才渲染价格区 */
54
+ price?: number
55
+ /** 提示区图标名(dd-icon name) */
56
+ tipIcon?: string
57
+ /** 按钮加载态 */
58
+ loading?: boolean
59
+ /** 货币符号 */
60
+ currency?: string
61
+ /** 按钮禁用态 */
62
+ disabled?: boolean
63
+ /** 价格区对齐方式(left/center/right) */
64
+ textAlign?: string
65
+ /** 按钮文案 */
66
+ buttonText?: string
67
+ /** 按钮类型(dd-button type) */
68
+ buttonType?: 'default' | 'primary' | 'secondary' | 'ghost' | 'text' | 'success' | 'warning' | 'danger'
69
+ /** 按钮自定义背景色(透传覆盖 dd-button 背景) */
70
+ buttonColor?: string
71
+ /** 价格右侧附加文案 */
72
+ suffixLabel?: string
73
+ /** 固定在底部时是否生成占位视图 */
74
+ placeholder?: boolean
75
+ /** 价格小数位数 */
76
+ decimalLength?: string | number
77
+ /** 是否预留底部安全区 */
78
+ safeAreaInsetBottom?: boolean
79
+ }
80
+
81
+ const props = withDefaults(defineProps<Props>(), {
82
+ tip: '',
83
+ label: '合计:',
84
+ tipIcon: '',
85
+ loading: false,
86
+ currency: '¥',
87
+ disabled: false,
88
+ textAlign: '',
89
+ buttonText: '',
90
+ buttonType: 'danger',
91
+ buttonColor: '',
92
+ suffixLabel: '',
93
+ placeholder: false,
94
+ decimalLength: 2,
95
+ safeAreaInsetBottom: true,
96
+ })
97
+
98
+ const emit = defineEmits<{
99
+ (e: 'submit'): void
100
+ }>()
101
+
102
+ const slots = useSlots()
103
+
104
+ const hasTip = computed(() => !!props.tip || !!slots.tip)
105
+
106
+ // Vant 口径:price 单位为分,除以 100 转元交给 dd-price 渲染
107
+ const priceYuan = computed(() => (typeof props.price === 'number' ? props.price / 100 : undefined))
108
+ const hasPrice = computed(() => priceYuan.value !== undefined)
109
+
110
+ const textStyle = computed<CSSProperties | undefined>(() =>
111
+ props.textAlign ? { textAlign: props.textAlign as CSSProperties['textAlign'] } : undefined,
112
+ )
113
+
114
+ const buttonStyle = computed(() => (props.buttonColor ? { background: props.buttonColor } : undefined))
115
+
116
+ function onSubmit() {
117
+ if (props.disabled || props.loading) return
118
+ emit('submit')
119
+ }
120
+ </script>
121
+
122
+ <style lang="scss" scoped>
123
+ @import '../../scss/variables';
124
+ @import '../../scss/mixins';
125
+
126
+ .dd-submit-bar {
127
+ position: fixed;
128
+ left: 0;
129
+ right: 0;
130
+ bottom: 0;
131
+ z-index: $dd-z-index-sticky;
132
+ background: var(--dd-bg-card, #{$dd-bg-card});
133
+
134
+ &--safe {
135
+ @include dd-safe-area-bottom;
136
+ }
137
+ }
138
+
139
+ .dd-submit-bar__placeholder {
140
+ width: 100%;
141
+ height: 100rpx;
142
+ box-sizing: content-box;
143
+
144
+ &--safe {
145
+ @include dd-safe-area-bottom;
146
+ }
147
+ }
148
+
149
+ .dd-submit-bar__tip {
150
+ display: flex;
151
+ align-items: center;
152
+ padding: $dd-space-2 $dd-space-3;
153
+ background: var(--dd-warning, #{$dd-warning});
154
+ color: $dd-color-white;
155
+ font-size: $dd-font-size-caption;
156
+ line-height: $dd-line-height-caption;
157
+ }
158
+
159
+ .dd-submit-bar__tip-icon {
160
+ margin-right: $dd-space-1;
161
+ font-size: 28rpx;
162
+ }
163
+
164
+ .dd-submit-bar__bar {
165
+ display: flex;
166
+ align-items: center;
167
+ min-height: 100rpx;
168
+ padding: $dd-space-2 $dd-space-3;
169
+ }
170
+
171
+ .dd-submit-bar__text {
172
+ flex: 1;
173
+ padding-right: $dd-space-3;
174
+ color: var(--dd-text-primary, #{$dd-text-primary});
175
+ font-size: $dd-font-size-body;
176
+ }
177
+
178
+ .dd-submit-bar__price {
179
+ margin-left: $dd-space-1;
180
+ color: var(--dd-error, #{$dd-error});
181
+ }
182
+
183
+ .dd-submit-bar__suffix-label {
184
+ margin-left: $dd-space-1;
185
+ color: var(--dd-text-secondary, #{$dd-text-secondary});
186
+ font-size: $dd-font-size-caption;
187
+ }
188
+
189
+ .dd-submit-bar__button {
190
+ flex-shrink: 0;
191
+ min-width: 200rpx;
192
+ margin-left: $dd-space-2;
193
+ }
194
+ </style>