@didaoktv/didaoui-uniapp 1.0.0 → 1.2.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.
Files changed (114) hide show
  1. package/README.md +16 -7
  2. package/components/dd-action-sheet/dd-action-sheet.vue +3 -3
  3. package/components/dd-album/album.js +19 -0
  4. package/components/dd-album/dd-album.vue +345 -0
  5. package/components/dd-album/props.js +89 -0
  6. package/components/dd-avatar/avatar.js +19 -0
  7. package/components/dd-avatar/dd-avatar.vue +172 -160
  8. package/components/dd-avatar/props.js +84 -0
  9. package/components/dd-avatar-group/avatarGroup.js +14 -0
  10. package/components/dd-avatar-group/dd-avatar-group.vue +110 -0
  11. package/components/dd-avatar-group/props.js +57 -0
  12. package/components/dd-badge/dd-badge.vue +2 -2
  13. package/components/dd-barcode/dd-barcode.vue +1030 -0
  14. package/components/dd-bill-detail/dd-bill-detail.vue +265 -0
  15. package/components/dd-button/dd-button.vue +17 -17
  16. package/components/dd-calendar/dd-calendar.vue +357 -0
  17. package/components/dd-canvas/dd-canvas.vue +1088 -0
  18. package/components/dd-capsule-button/dd-capsule-button.vue +6 -6
  19. package/components/dd-car-keyboard/carKeyboard.js +6 -0
  20. package/components/dd-car-keyboard/dd-car-keyboard.vue +315 -0
  21. package/components/dd-car-keyboard/props.js +19 -0
  22. package/components/dd-cascader/dd-cascader.vue +405 -0
  23. package/components/dd-cell/dd-cell.vue +50 -23
  24. package/components/dd-cell-group/dd-cell-group.vue +32 -25
  25. package/components/dd-champion-card/dd-champion-card.vue +4 -4
  26. package/components/dd-checkbox/dd-checkbox.vue +30 -39
  27. package/components/dd-checkbox-group/dd-checkbox-group.vue +67 -0
  28. package/components/dd-copy/dd-copy.vue +74 -0
  29. package/components/dd-coupon/dd-coupon.vue +368 -0
  30. package/components/dd-cropper/dd-cropper.vue +1297 -0
  31. package/components/dd-dialog/dd-dialog.vue +1 -1
  32. package/components/dd-divider/dd-divider.vue +3 -3
  33. package/components/dd-dropdown-item/dd-dropdown-item.vue +5 -5
  34. package/components/dd-empty-state/dd-empty-state.vue +1 -1
  35. package/components/dd-field/dd-field.vue +531 -106
  36. package/components/dd-form/dd-form.vue +116 -0
  37. package/components/dd-form/rules.ts +84 -0
  38. package/components/dd-goods-sku/dd-goods-sku.vue +434 -0
  39. package/components/dd-icon/dd-icon.vue +2 -2
  40. package/components/dd-image/dd-image.vue +4 -4
  41. package/components/dd-input/dd-input.vue +5 -5
  42. package/components/dd-keyboard/dd-keyboard.vue +178 -0
  43. package/components/dd-keyboard/keyboard.js +22 -0
  44. package/components/dd-keyboard/props.js +89 -0
  45. package/components/dd-link/dd-link.vue +87 -0
  46. package/components/dd-link/link.js +18 -0
  47. package/components/dd-link/props.js +44 -0
  48. package/components/dd-list-cell/dd-list-cell.vue +4 -4
  49. package/components/dd-loading/dd-loading.vue +1 -1
  50. package/components/dd-loadmore/dd-loadmore.vue +2 -2
  51. package/components/dd-markdown/dd-markdown.vue +344 -0
  52. package/components/dd-markdown/marked.esm.mjs +7 -0
  53. package/components/dd-mini-program-navbar/dd-mini-program-navbar.vue +9 -9
  54. package/components/dd-navigation/dd-navigation.vue +5 -5
  55. package/components/dd-number-keyboard/dd-number-keyboard.vue +200 -0
  56. package/components/dd-number-keyboard/numberKeyboard.js +8 -0
  57. package/components/dd-number-keyboard/props.js +24 -0
  58. package/components/dd-parse/dd-parse.vue +534 -0
  59. package/components/dd-parse/node/handler.wxs +26 -0
  60. package/components/dd-parse/node/node.vue +603 -0
  61. package/components/dd-parse/parse.js +13 -0
  62. package/components/dd-parse/parser.js +1400 -0
  63. package/components/dd-parse/props.js +57 -0
  64. package/components/dd-popover/dd-popover.vue +10 -10
  65. package/components/dd-popover-item/dd-popover-item.vue +3 -3
  66. package/components/dd-popup/dd-popup.vue +5 -5
  67. package/components/dd-poster/dd-poster.vue +695 -0
  68. package/components/dd-progress/dd-progress.vue +3 -3
  69. package/components/dd-pull-refresh/dd-pull-refresh.vue +3 -3
  70. package/components/dd-qrcode/dd-qrcode.vue +509 -0
  71. package/components/dd-qrcode/qrcode.js +1283 -0
  72. package/components/dd-radio/dd-radio.vue +19 -20
  73. package/components/dd-radio-group/dd-radio-group.vue +53 -0
  74. package/components/dd-rate/dd-rate.vue +1 -1
  75. package/components/dd-room-card/dd-room-card.vue +3 -3
  76. package/components/dd-search-bar/dd-search-bar.vue +8 -8
  77. package/components/dd-segmented-tab/dd-segmented-tab.vue +6 -6
  78. package/components/dd-signature/dd-signature.vue +513 -0
  79. package/components/dd-skeleton/dd-skeleton.vue +1 -1
  80. package/components/dd-slider/dd-slider.vue +4 -4
  81. package/components/dd-stat-card/dd-stat-card.vue +5 -5
  82. package/components/dd-step/dd-step.vue +11 -11
  83. package/components/dd-stepper/dd-stepper.vue +6 -6
  84. package/components/dd-swipe-action/dd-swipe-action.vue +1 -1
  85. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -1
  86. package/components/dd-tabbar-item/dd-tabbar-item.vue +8 -8
  87. package/components/dd-tag/dd-tag.vue +17 -1
  88. package/components/dd-text/dd-text.vue +250 -0
  89. package/components/dd-text/props.js +120 -0
  90. package/components/dd-text/text.js +30 -0
  91. package/components/dd-text/value.js +87 -0
  92. package/components/dd-toast/dd-toast.vue +2 -2
  93. package/components/dd-upload/dd-upload.vue +4 -4
  94. package/components/dd-workorder-card/dd-workorder-card.vue +237 -0
  95. package/index.ts +50 -9
  96. package/libs/config/color.js +16 -0
  97. package/libs/config/config.js +25 -0
  98. package/libs/config/props.js +185 -0
  99. package/libs/config/zIndex.js +20 -0
  100. package/libs/function/digit.js +167 -0
  101. package/libs/function/index.js +932 -0
  102. package/libs/function/test.js +327 -0
  103. package/libs/i18n/index.d.ts +2 -0
  104. package/libs/i18n/index.js +89 -0
  105. package/libs/i18n/locales/zh-Hans.js +86 -0
  106. package/libs/mixin/button.js +18 -0
  107. package/libs/mixin/mixin.js +44 -0
  108. package/libs/mixin/mpMixin.js +13 -0
  109. package/libs/mixin/openType.js +27 -0
  110. package/libs/utils.ts +462 -0
  111. package/libs/vue.js +3 -0
  112. package/package.json +1 -1
  113. package/scss/_dd-shared.scss +40 -0
  114. package/scss/_variables.scss +4 -1
@@ -187,7 +187,7 @@ watch(() => props.options, measure)
187
187
  position: absolute;
188
188
  bottom: 0;
189
189
  left: 0;
190
- height: 4rpx;
190
+ height: $dd-space-1;
191
191
  background: $dd-gradient-primary-h;
192
192
  border-radius: $dd-radius-full;
193
193
  box-shadow: $dd-shadow-glow-gold-sm;
@@ -68,7 +68,7 @@ function onClick() {
68
68
  height: 100%;
69
69
  @include dd-flex-center;
70
70
  flex-direction: column;
71
- gap: 4rpx;
71
+ gap: $dd-space-1;
72
72
  box-sizing: border-box;
73
73
  @include dd-transition(color 0.3s);
74
74
 
@@ -95,9 +95,9 @@ function onClick() {
95
95
  top: 0;
96
96
  right: 0;
97
97
  transform: translate(40%, -50%);
98
- min-width: 32rpx;
99
- height: 32rpx;
100
- padding: 0 8rpx;
98
+ min-width: $dd-space-4;
99
+ height: $dd-space-4;
100
+ padding: 0 $dd-space-1;
101
101
  border-radius: $dd-radius-full;
102
102
  background: $dd-error;
103
103
  @include dd-flex-center;
@@ -111,10 +111,10 @@ function onClick() {
111
111
 
112
112
  &__dot {
113
113
  position: absolute;
114
- top: -4rpx;
115
- right: -4rpx;
116
- width: 16rpx;
117
- height: 16rpx;
114
+ top: -$dd-space-1;
115
+ right: -$dd-space-1;
116
+ width: $dd-space-2;
117
+ height: $dd-space-2;
118
118
  border-radius: 50%;
119
119
  background: $dd-error;
120
120
  }
@@ -7,6 +7,7 @@
7
7
  `dd-tag--${size}`,
8
8
  { 'dd-tag--round': round, 'dd-tag--closable': closable },
9
9
  ]"
10
+ :style="customStyle"
10
11
  @click="onClick"
11
12
  >
12
13
  <view v-if="type === 'dot'" class="dd-tag__dot"></view>
@@ -18,7 +19,7 @@
18
19
  </template>
19
20
 
20
21
  <script setup lang="ts">
21
- import { useSlots } from 'vue'
22
+ import { computed, useSlots } from 'vue'
22
23
  import DdIcon from '../dd-icon/dd-icon.vue'
23
24
 
24
25
  interface Props {
@@ -28,6 +29,8 @@ interface Props {
28
29
  round?: boolean
29
30
  closable?: boolean
30
31
  text?: string
32
+ bgColor?: string
33
+ color?: string
31
34
  }
32
35
 
33
36
  const props = withDefaults(defineProps<Props>(), {
@@ -37,6 +40,19 @@ const props = withDefaults(defineProps<Props>(), {
37
40
  round: false,
38
41
  closable: false,
39
42
  text: '',
43
+ bgColor: '',
44
+ color: '',
45
+ })
46
+
47
+ // 自定义配色:bgColor 覆盖背景(outlined 时覆盖边框),color 覆盖文字
48
+ const customStyle = computed(() => {
49
+ const s: Record<string, string> = {}
50
+ if (props.bgColor) {
51
+ if (props.type === 'outlined') s.borderColor = props.bgColor
52
+ else s.background = props.bgColor
53
+ }
54
+ if (props.color) s.color = props.color
55
+ return s
40
56
  })
41
57
 
42
58
  const emit = defineEmits<{ (e: 'click', val: Event): void; (e: 'close', val: Event): void }>()
@@ -0,0 +1,250 @@
1
+ <template>
2
+ <view
3
+ class="dd-text"
4
+ :class="[customClass]"
5
+ v-if="show"
6
+ :style="wrapStyle"
7
+ @tap="clickHandler"
8
+ >
9
+ <text
10
+ :class="['dd-text__price', type && `dd-text__value--${type}`]"
11
+ v-if="mode === 'price'"
12
+ :style="[valueStyle]"
13
+ >¥</text
14
+ >
15
+ <view class="dd-text__prefix-icon" v-if="prefixIcon">
16
+ <dd-icon
17
+ :name="prefixIcon"
18
+ :customStyle="addStyle(iconStyle)"
19
+ ></dd-icon>
20
+ </view>
21
+ <dd-link
22
+ v-if="mode === 'link'" class="dd-text__value"
23
+ :style="{fontWeight: valueStyle.fontWeight, wordWrap: valueStyle.wordWrap, fontSize: valueStyle.fontSize}"
24
+ :class="[type && `dd-text__value--${type}`,lines && `dd-line-${lines}`]" :text="value"
25
+ :href="href"
26
+ underLine
27
+ ></dd-link>
28
+ <template v-else-if="openType && isMp">
29
+ <button
30
+ class="dd-reset-button dd-text__value"
31
+ :style="[valueStyle]"
32
+ :data-index="index"
33
+ :openType="openType"
34
+ @getuserinfo="onGetUserInfo"
35
+ @contact="onContact"
36
+ @getphonenumber="onGetPhoneNumber"
37
+ @error="onError"
38
+ @launchapp="onLaunchApp"
39
+ @opensetting="onOpenSetting"
40
+ :lang="lang"
41
+ :session-from="sessionFrom"
42
+ :send-message-title="sendMessageTitle"
43
+ :send-message-path="sendMessagePath"
44
+ :send-message-img="sendMessageImg"
45
+ :show-message-card="showMessageCard"
46
+ :app-parameter="appParameter"
47
+ >
48
+ {{ value }}
49
+ </button>
50
+ </template>
51
+ <text
52
+ v-else
53
+ class="dd-text__value"
54
+ :style="[valueStyle]"
55
+ :class="[
56
+ type && `dd-text__value--${type}`,
57
+ lines && `dd-line-${lines}`
58
+ ]"
59
+ >{{ value }}</text
60
+ >
61
+ <view class="dd-text__suffix-icon" v-if="suffixIcon">
62
+ <dd-icon
63
+ :name="suffixIcon"
64
+ :customStyle="addStyle(iconStyle)"
65
+ ></dd-icon>
66
+ </view>
67
+ </view>
68
+ </template>
69
+
70
+ <script>
71
+ import { props } from './props'
72
+ import value from './value.js'
73
+ import { mpMixin } from '../../libs/mixin/mpMixin';
74
+ import { mixin } from '../../libs/mixin/mixin';
75
+ import { buttonMixin } from '../../libs/mixin/button';
76
+ import { openType } from '../../libs/mixin/openType';
77
+ import { addStyle, addUnit, deepMerge } from '../../libs/function/index';
78
+
79
+ function normalizeLineHeight(value) {
80
+ const valueString = String(value).trim()
81
+ const numericValue = Number(valueString)
82
+ const isUnitless =
83
+ /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(valueString) &&
84
+ numericValue > 0 &&
85
+ numericValue < 10
86
+
87
+ return isUnitless ? valueString : addUnit(value)
88
+ }
89
+
90
+ /**
91
+ * Text 文本
92
+ * @description 此组件集成了文本类在项目中的常用功能,包括状态,拨打电话,格式化日期,*替换,超链接...等功能。 您大可不必在使用特殊文本时自己定义,text组件几乎涵盖您能使用的大部分场景。
93
+ * @property {String} type 主题颜色
94
+ * @property {Boolean} show 是否显示(默认 true )
95
+ * @property {String | Number} text 显示的值
96
+ * @property {String} prefixIcon 前置图标
97
+ * @property {String} suffixIcon 后置图标
98
+ * @property {String} mode 文本处理的匹配模式 text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
99
+ * @property {String} href mode=link下,配置的链接
100
+ * @property {String | Function} format 格式化规则
101
+ * @property {Boolean} call mode=phone时,点击文本是否拨打电话(默认 false )
102
+ * @property {String} openType 小程序的打开方式
103
+ * @property {Boolean} bold 是否粗体,默认normal(默认 false )
104
+ * @property {Boolean} block 是否块状(默认 false )
105
+ * @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
106
+ * @property {String} color 文本颜色(默认 '#303133' )
107
+ * @property {String | Number} size 字体大小(默认 15 )
108
+ * @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} )
109
+ * @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
110
+ * @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 )
111
+ * @property {String | Number} lineHeight 文本行高,支持带单位值或无单位倍数(如 1.2)
112
+ * @property {String} align 文本对齐方式,可选值left|center|right(默认 'left' )
113
+ * @property {String} wordWrap 文字换行,可选值break-word|normal|anywhere(默认 'normal' )
114
+ * @event {Function} click 点击触发事件
115
+ * @example <dd-text text="我用十年青春,赴你最后之约"></dd-text>
116
+ */
117
+ export default {
118
+ name: 'dd-text',
119
+ // #ifdef MP
120
+ mixins: [mpMixin, mixin, value, buttonMixin, openType, props],
121
+ // #endif
122
+ // #ifndef MP
123
+ mixins: [mpMixin, mixin, value, props],
124
+ // #endif
125
+ emits: ['click'],
126
+ computed: {
127
+ wrapStyle() {
128
+ let style = {
129
+ margin: this.margin,
130
+ justifyContent: this.align === 'left' ? 'flex-start' : this.align === 'center' ? 'center' : 'flex-end'
131
+ }
132
+ // 占满剩余空间
133
+ if (this.flex1) {
134
+ style.flex = 1;
135
+ // #ifndef APP-NVUE
136
+ style.width = '100%';
137
+ // #endif
138
+ }
139
+ return style;
140
+ },
141
+ valueStyle() {
142
+ const style = {
143
+ textDecoration: this.decoration,
144
+ fontWeight: this.bold ? 'bold' : 'normal',
145
+ wordWrap: this.wordWrap,
146
+ fontSize: addUnit(this.size)
147
+ }
148
+ if (!this.type) {
149
+ // ponytail: 剥离运行时主题;未传 color 时继承上下文,跟随设计系统文本色
150
+ style.color = this.color || 'inherit'
151
+ }
152
+ this.isNvue && this.lines && (style.lines = this.lines)
153
+ this.lineHeight &&
154
+ (style.lineHeight = normalizeLineHeight(this.lineHeight))
155
+ !this.isNvue && this.block && (style.display = 'block')
156
+ return deepMerge(style, addStyle(this.customStyle))
157
+ },
158
+ isNvue() {
159
+ let nvue = false
160
+ // #ifdef APP-NVUE
161
+ nvue = true
162
+ // #endif
163
+ return nvue
164
+ },
165
+ isMp() {
166
+ let mp = false
167
+ // #ifdef MP
168
+ mp = true
169
+ // #endif
170
+ return mp
171
+ }
172
+ },
173
+ data() {
174
+ return {}
175
+ },
176
+ methods: {
177
+ addStyle,
178
+ clickHandler(e) {
179
+ // 如果为手机号模式,拨打电话
180
+ if (this.call && this.mode === 'phone') {
181
+ uni.makePhoneCall({
182
+ phoneNumber: this.text
183
+ })
184
+ }
185
+ this.$emit('click', e)
186
+ }
187
+ }
188
+ }
189
+ </script>
190
+
191
+ <style lang="scss" scoped>
192
+ @import '../../scss/variables';
193
+ @import '../../scss/dd-shared';
194
+ .dd-text {
195
+ @include flex(row);
196
+ align-items: center;
197
+ flex-wrap: nowrap;
198
+
199
+ &__price {
200
+ font-size: 14px;
201
+ color: $dd-text-secondary;
202
+ }
203
+
204
+ &__value {
205
+ font-size: 14px;
206
+ @include flex;
207
+ color: $dd-text-secondary;
208
+ flex-wrap: wrap;
209
+ // flex: 1;
210
+ text-overflow: ellipsis;
211
+ align-items: center;
212
+
213
+ &--primary {
214
+ color: $dd-primary-400;
215
+ }
216
+
217
+ &--warning {
218
+ color: $dd-warning-400;
219
+ }
220
+
221
+ &--success {
222
+ color: $dd-success-400;
223
+ }
224
+
225
+ &--info {
226
+ color: $dd-info-400;
227
+ }
228
+
229
+ &--error {
230
+ color: $dd-error-400;
231
+ }
232
+
233
+ &--main {
234
+ color: $dd-text-primary;
235
+ }
236
+
237
+ &--content {
238
+ color: $dd-text-secondary;
239
+ }
240
+
241
+ &--tips {
242
+ color: $dd-text-tertiary;
243
+ }
244
+
245
+ &--light {
246
+ color: $dd-text-tertiary;
247
+ }
248
+ }
249
+ }
250
+ </style>
@@ -0,0 +1,120 @@
1
+ import { defineMixin } from '../../libs/vue'
2
+ import TextDefaultProps from './text'
3
+ import { registerComponentProps } from '../../libs/config/props.js'
4
+
5
+ const defProps = registerComponentProps(TextDefaultProps)
6
+ export const props = defineMixin({
7
+ props: {
8
+ // 主题颜色
9
+ type: {
10
+ type: String,
11
+ default: () => defProps.text.type
12
+ },
13
+ // 是否显示
14
+ show: {
15
+ type: Boolean,
16
+ default: () => defProps.text.show
17
+ },
18
+ // 显示的值
19
+ text: {
20
+ type: [String, Number],
21
+ default: () => defProps.text.text
22
+ },
23
+ // 前置图标
24
+ prefixIcon: {
25
+ type: String,
26
+ default: () => defProps.text.prefixIcon
27
+ },
28
+ // 后置图标
29
+ suffixIcon: {
30
+ type: String,
31
+ default: () => defProps.text.suffixIcon
32
+ },
33
+ // 文本处理的匹配模式
34
+ // text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
35
+ mode: {
36
+ type: String,
37
+ default: () => defProps.text.mode
38
+ },
39
+ // mode=link下,配置的链接
40
+ href: {
41
+ type: String,
42
+ default: () => defProps.text.href
43
+ },
44
+ // 格式化规则
45
+ format: {
46
+ type: [String, Function],
47
+ default: () => defProps.text.format
48
+ },
49
+ // mode=phone时,点击文本是否拨打电话
50
+ call: {
51
+ type: Boolean,
52
+ default: () => defProps.text.call
53
+ },
54
+ // 小程序的打开方式
55
+ openType: {
56
+ type: String,
57
+ default: () => defProps.text.openType
58
+ },
59
+ // 是否粗体,默认normal
60
+ bold: {
61
+ type: Boolean,
62
+ default: () => defProps.text.bold
63
+ },
64
+ // 是否块状
65
+ block: {
66
+ type: Boolean,
67
+ default: () => defProps.text.block
68
+ },
69
+ // 文本显示的行数,如果设置,超出此行数,将会显示省略号
70
+ lines: {
71
+ type: [String, Number],
72
+ default: () => defProps.text.lines
73
+ },
74
+ // 文本颜色
75
+ color: {
76
+ type: String,
77
+ default: () => defProps.text.color
78
+ },
79
+ // 字体大小
80
+ size: {
81
+ type: [String, Number],
82
+ default: () => defProps.text.size
83
+ },
84
+ // 图标的样式
85
+ iconStyle: {
86
+ type: [Object, String],
87
+ default: () => defProps.text.iconStyle
88
+ },
89
+ // 文字装饰,下划线,中划线等,可选值 none|underline|line-through
90
+ decoration: {
91
+ tepe: String,
92
+ default: () => defProps.text.decoration
93
+ },
94
+ // 外边距,对象、字符串,数值形式均可
95
+ margin: {
96
+ type: [Object, String, Number],
97
+ default: () => defProps.text.margin
98
+ },
99
+ // 文本行高
100
+ lineHeight: {
101
+ type: [String, Number],
102
+ default: () => defProps.text.lineHeight
103
+ },
104
+ // 文本对齐方式,可选值left|center|right
105
+ align: {
106
+ type: String,
107
+ default: () => defProps.text.align
108
+ },
109
+ // 文字换行,可选值break-word|normal|anywhere
110
+ wordWrap: {
111
+ type: String,
112
+ default: () => defProps.text.wordWrap
113
+ },
114
+ // 占满剩余空间
115
+ flex1: {
116
+ type: Boolean,
117
+ default: () => defProps.text.flex1
118
+ }
119
+ }
120
+ })
@@ -0,0 +1,30 @@
1
+ export default {
2
+ // text 组件
3
+ text: {
4
+ type: '',
5
+ show: true,
6
+ text: '',
7
+ prefixIcon: '',
8
+ suffixIcon: '',
9
+ mode: '',
10
+ href: '',
11
+ format: '',
12
+ call: false,
13
+ openType: '',
14
+ bold: false,
15
+ block: false,
16
+ lines: '',
17
+ color: '',
18
+ size: 15,
19
+ iconStyle: {
20
+ fontSize: '15px'
21
+ },
22
+ decoration: 'none',
23
+ margin: 0,
24
+ lineHeight: '',
25
+ align: 'left',
26
+ wordWrap: 'normal',
27
+ flex1: false
28
+ }
29
+
30
+ }
@@ -0,0 +1,87 @@
1
+ import { error, priceFormat, timeFormat } from '../../libs/function/index';
2
+ import test from '../../libs/function/test';
3
+ export default {
4
+ computed: {
5
+ // 经处理后需要显示的值
6
+ value() {
7
+ const {
8
+ text,
9
+ mode,
10
+ format,
11
+ href
12
+ } = this
13
+ // 价格类型
14
+ if (mode === 'price') {
15
+ // 如果text不为金额进行提示
16
+ if (!/^\d+(\.\d+)?$/.test(text)) {
17
+ error('金额模式下,text参数需要为金额格式');
18
+ }
19
+ // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
20
+ if (test.func(format)) {
21
+ // 如果用户传入的是函数,使用函数格式化
22
+ return format(text)
23
+ }
24
+ // 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
25
+ return priceFormat(text, 2)
26
+ } if (mode === 'date') {
27
+ // 判断是否合法的日期或者时间戳
28
+ !test.date(text) && error('日期模式下,text参数需要为日期或时间戳格式')
29
+ // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
30
+ if (test.func(format)) {
31
+ // 如果用户传入的是函数,使用函数格式化
32
+ return format(text)
33
+ } if (format) {
34
+ // 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
35
+ return timeFormat(text, format)
36
+ }
37
+ // 如果没有设置format,则设置为默认的时间格式化形式
38
+ return timeFormat(text, 'yyyy-mm-dd')
39
+ } if (mode === 'phone') {
40
+ // 判断是否合法的手机号
41
+ // !test.mobile(text) && error('手机号模式下,text参数需要为手机号码格式')
42
+ if (test.func(format)) {
43
+ // 如果用户传入的是函数,使用函数格式化
44
+ return format(text)
45
+ } if (format === 'encrypt') {
46
+ // 如果format为encrypt,则将手机号进行星号加密处理
47
+ return `${text.substr(0, 3)}****${text.substr(7)}`
48
+ }
49
+ return text
50
+ } if (mode === 'name') {
51
+ // 判断是否合法的字符粗
52
+ !(typeof (text) === 'string') && error('姓名模式下,text参数需要为字符串格式')
53
+ if (test.func(format)) {
54
+ // 如果用户传入的是函数,使用函数格式化
55
+ return format(text)
56
+ } if (format === 'encrypt') {
57
+ // 如果format为encrypt,则将姓名进行星号加密处理
58
+ return this.formatName(text)
59
+ }
60
+ return text
61
+ } if (mode === 'link') {
62
+ // 判断是否合法的字符粗
63
+ !test.url(href) && error('超链接模式下,href参数需要为URL格式')
64
+ return text
65
+ }
66
+ return text
67
+ }
68
+ },
69
+ methods: {
70
+ // 默认的姓名脱敏规则
71
+ formatName(name) {
72
+ let value = ''
73
+ if (name.length === 2) {
74
+ value = name.substr(0, 1) + '*'
75
+ } else if (name.length > 2) {
76
+ let char = ''
77
+ for (let i = 0, len = name.length - 2; i < len; i++) {
78
+ char += '*'
79
+ }
80
+ value = name.substr(0, 1) + char + name.substr(-1, 1)
81
+ } else {
82
+ value = name
83
+ }
84
+ return value
85
+ }
86
+ }
87
+ }
@@ -171,8 +171,8 @@ const iconName = computed(() => {
171
171
  }
172
172
 
173
173
  &__spinner {
174
- width: 64rpx;
175
- height: 64rpx;
174
+ width: $dd-size-icon-xl;
175
+ height: $dd-size-icon-xl;
176
176
  border: 6rpx solid $dd-border-default;
177
177
  border-top-color: $dd-primary-400;
178
178
  border-radius: 50%;
@@ -133,7 +133,7 @@ function onPreview(index: number) {
133
133
  .dd-upload {
134
134
  display: flex;
135
135
  flex-wrap: wrap;
136
- gap: 16rpx;
136
+ gap: $dd-space-2;
137
137
 
138
138
  &__item {
139
139
  position: relative;
@@ -152,8 +152,8 @@ function onPreview(index: number) {
152
152
 
153
153
  &__delete {
154
154
  position: absolute;
155
- top: 8rpx;
156
- right: 8rpx;
155
+ top: $dd-space-1;
156
+ right: $dd-space-1;
157
157
  width: 36rpx;
158
158
  height: 36rpx;
159
159
  border-radius: 50%;
@@ -171,7 +171,7 @@ function onPreview(index: number) {
171
171
  border-radius: $dd-radius-md;
172
172
  background: $dd-neutral-800;
173
173
  color: $dd-text-tertiary;
174
- font-size: 48rpx;
174
+ font-size: $dd-font-size-h1;
175
175
  box-sizing: border-box;
176
176
  @include dd-transition(background 0.2s);
177
177