@didaoktv/didaoui-uniapp 2.13.0 → 2.15.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 +6 -6
- package/components/dd-album/dd-album.vue +280 -228
- package/components/dd-avatar/dd-avatar.vue +132 -75
- package/components/dd-avatar-group/dd-avatar-group.vue +52 -30
- package/components/dd-barcode/dd-barcode.vue +884 -947
- package/components/dd-button/dd-button.vue +47 -21
- package/components/dd-canvas/dd-canvas.vue +1156 -985
- package/components/dd-car-keyboard/dd-car-keyboard.vue +12 -12
- package/components/dd-champion-card/dd-champion-card.vue +49 -21
- package/components/dd-checkbox-group/dd-checkbox-group.vue +2 -0
- package/components/dd-copy/dd-copy.vue +51 -56
- package/components/dd-cropper/dd-cropper.vue +1224 -1135
- package/components/dd-divider/dd-divider.vue +9 -2
- package/components/dd-form/dd-form.vue +2 -0
- package/components/dd-goods-sku/dd-goods-sku.vue +6 -1
- package/components/dd-icon/dd-icon.vue +1 -1
- package/components/dd-keyboard/dd-keyboard.vue +95 -46
- package/components/dd-link/dd-link.vue +72 -49
- package/components/dd-markdown/dd-markdown.vue +154 -154
- package/components/dd-number-keyboard/dd-number-keyboard.vue +109 -94
- package/components/dd-package-sku/dd-package-sku.vue +24 -1
- package/components/dd-parse/dd-parse.vue +473 -442
- package/components/dd-poster/dd-poster.vue +579 -567
- package/components/dd-pull-refresh/dd-pull-refresh.vue +1 -9
- package/components/dd-qrcode/dd-qrcode.vue +431 -405
- package/components/dd-radio-group/dd-radio-group.vue +1 -1
- package/components/dd-segmented-tab/dd-segmented-tab.vue +61 -16
- package/components/dd-signature/dd-signature.vue +377 -357
- package/components/dd-step/dd-step.vue +1 -1
- package/components/dd-sticky/dd-sticky.vue +5 -10
- package/components/dd-swipe-action/dd-swipe-action.vue +1 -9
- package/components/dd-swipe-item/dd-swipe-item.vue +2 -0
- package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -5
- package/components/dd-switch/dd-switch.vue +1 -1
- package/components/dd-text/dd-text.vue +304 -82
- package/components/dd-waterfall/dd-waterfall.vue +147 -0
- package/components/dd-waterfall/waterfall.ts +17 -0
- package/index.ts +4 -3
- package/libs/function/index.d.ts +88 -0
- package/libs/function/index.js +14 -0
- package/libs/function/test.d.ts +65 -0
- package/package.json +1 -1
- package/scss/_mixins.scss +8 -0
- package/scss/_theme-tokens.scss +7 -0
- package/scss/_variables.scss +283 -156
- package/components/dd-album/album.js +0 -19
- package/components/dd-album/props.js +0 -89
- package/components/dd-avatar/avatar.js +0 -19
- package/components/dd-avatar/props.js +0 -84
- package/components/dd-avatar-group/avatarGroup.js +0 -14
- package/components/dd-avatar-group/props.js +0 -57
- package/components/dd-keyboard/keyboard.js +0 -19
- package/components/dd-keyboard/props.js +0 -79
- package/components/dd-link/link.js +0 -17
- package/components/dd-link/props.js +0 -44
- package/components/dd-number-keyboard/numberKeyboard.js +0 -8
- package/components/dd-number-keyboard/props.js +0 -24
- package/components/dd-parse/props.js +0 -57
- package/components/dd-text/props.js +0 -120
- package/components/dd-text/text.js +0 -30
- package/components/dd-text/value.js +0 -87
- package/libs/config/color.js +0 -16
- package/libs/config/props.js +0 -184
- package/libs/mixin/button.js +0 -18
- package/libs/mixin/mixin.js +0 -44
- package/libs/mixin/mpMixin.js +0 -13
- package/libs/mixin/openType.js +0 -27
- package/libs/vue.js +0 -3
- package/scss/_dd-shared.scss +0 -40
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
|
+
ref="rootRef"
|
|
3
4
|
class="dd-sticky"
|
|
4
5
|
:class="{ 'dd-sticky--disabled': disabled }"
|
|
5
6
|
:style="stickyStyle"
|
|
@@ -12,6 +13,7 @@
|
|
|
12
13
|
import { computed, getCurrentInstance, onMounted, onUnmounted, ref } from 'vue'
|
|
13
14
|
// z-index 统一取 libs/config/zIndex.js:默认吸顶层级取 sticky 档(zIndex prop 保留可覆盖)
|
|
14
15
|
import zIndexConfig from '../../libs/config/zIndex.js'
|
|
16
|
+
import { rpxToPx } from '../../libs/function/index.js'
|
|
15
17
|
|
|
16
18
|
interface Props {
|
|
17
19
|
offsetTop?: number // rpx
|
|
@@ -28,6 +30,8 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
28
30
|
const emit = defineEmits<{ (e: 'change', val: { isFixed: boolean; scrollTop: number }): void }>()
|
|
29
31
|
|
|
30
32
|
const isFixed = ref(false)
|
|
33
|
+
// H5 侧观察自身根节点(避免全局选择器在多实例下取到第一个)
|
|
34
|
+
const rootRef = ref<HTMLElement | null>(null)
|
|
31
35
|
|
|
32
36
|
const stickyStyle = computed(() => {
|
|
33
37
|
if (props.disabled) {
|
|
@@ -44,15 +48,6 @@ const stickyStyle = computed(() => {
|
|
|
44
48
|
let observer: any = null
|
|
45
49
|
const instance = getCurrentInstance()
|
|
46
50
|
|
|
47
|
-
function rpxToPx(rpx: number): number {
|
|
48
|
-
try {
|
|
49
|
-
const info = uni.getWindowInfo()
|
|
50
|
-
return (rpx / 750) * info.windowWidth
|
|
51
|
-
} catch {
|
|
52
|
-
return rpx / 2
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
51
|
onMounted(() => {
|
|
57
52
|
if (props.disabled) return
|
|
58
53
|
// #ifdef H5
|
|
@@ -66,7 +61,7 @@ onMounted(() => {
|
|
|
66
61
|
// H5: 使用原生 IntersectionObserver API
|
|
67
62
|
function setupH5Observer() {
|
|
68
63
|
// #ifdef H5
|
|
69
|
-
const el =
|
|
64
|
+
const el = rootRef.value
|
|
70
65
|
if (!el) return
|
|
71
66
|
const px = rpxToPx(props.offsetTop)
|
|
72
67
|
const io = new IntersectionObserver(
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
|
|
44
44
|
<script setup lang="ts">
|
|
45
45
|
import { computed, ref } from 'vue'
|
|
46
|
+
import { rpxToPx } from '../../libs/function/index.js'
|
|
46
47
|
import DdIcon from '../dd-icon/dd-icon.vue'
|
|
47
48
|
// z-index 统一取 libs/config/zIndex.js(操作层 base 档,内容层档内 +1 盖住操作层)
|
|
48
49
|
import zIndexConfig from '../../libs/config/zIndex.js'
|
|
@@ -92,15 +93,6 @@ const actionWidthPx = computed(() => rpxToPx(props.actionWidth))
|
|
|
92
93
|
const leftWidthPx = computed(() => actionWidthPx.value * props.leftActions.length)
|
|
93
94
|
const rightWidthPx = computed(() => actionWidthPx.value * props.rightActions.length)
|
|
94
95
|
|
|
95
|
-
function rpxToPx(rpx: number): number {
|
|
96
|
-
try {
|
|
97
|
-
const info = uni.getWindowInfo()
|
|
98
|
-
return (rpx / 750) * info.windowWidth
|
|
99
|
-
} catch {
|
|
100
|
-
return rpx / 2
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
96
|
function onTouchStart(e: any) {
|
|
105
97
|
if (props.disabled) return
|
|
106
98
|
dragging = true
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
<script setup lang="ts">
|
|
45
45
|
import { nextTick, onMounted, ref, watch } from 'vue'
|
|
46
46
|
import { getCurrentInstance } from 'vue'
|
|
47
|
+
import { rpxToPx } from '../../libs/function/index.js'
|
|
47
48
|
|
|
48
49
|
interface Props {
|
|
49
50
|
modelValue?: number
|
|
@@ -79,11 +80,6 @@ function onSelect(index: number) {
|
|
|
79
80
|
measure()
|
|
80
81
|
}
|
|
81
82
|
|
|
82
|
-
function rpxToPx(rpx: number): number {
|
|
83
|
-
const w = uni.getWindowInfo?.().windowWidth || 375
|
|
84
|
-
return (rpx * w) / 750
|
|
85
|
-
}
|
|
86
|
-
|
|
87
83
|
function measure() {
|
|
88
84
|
nextTick(() => {
|
|
89
85
|
const query = uni.createSelectorQuery().in(instance)
|
|
@@ -56,7 +56,7 @@ function onToggle() {
|
|
|
56
56
|
top: 50%;
|
|
57
57
|
left: 6rpx;
|
|
58
58
|
transform: translateY(-50%);
|
|
59
|
-
background:
|
|
59
|
+
background: $dd-color-white;
|
|
60
60
|
border-radius: 50%;
|
|
61
61
|
box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.3);
|
|
62
62
|
@include dd-transition(left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1));
|
|
@@ -67,16 +67,14 @@
|
|
|
67
67
|
</view>
|
|
68
68
|
</template>
|
|
69
69
|
|
|
70
|
-
<script>
|
|
71
|
-
import {
|
|
72
|
-
import
|
|
73
|
-
import
|
|
74
|
-
import {
|
|
75
|
-
import
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
function normalizeLineHeight(value) {
|
|
70
|
+
<script setup lang="ts">
|
|
71
|
+
import { computed } from 'vue'
|
|
72
|
+
import DdIcon from '../dd-icon/dd-icon.vue'
|
|
73
|
+
import DdLink from '../dd-link/dd-link.vue'
|
|
74
|
+
import { addStyle, addUnit, deepMerge, error, priceFormat, timeFormat } from '../../libs/function/index.js';
|
|
75
|
+
import test from '../../libs/function/test';
|
|
76
|
+
|
|
77
|
+
function normalizeLineHeight(value: any) {
|
|
80
78
|
const valueString = String(value).trim()
|
|
81
79
|
const numericValue = Number(valueString)
|
|
82
80
|
const isUnitless =
|
|
@@ -105,7 +103,7 @@ function normalizeLineHeight(value) {
|
|
|
105
103
|
* @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
|
|
106
104
|
* @property {String} color 文本颜色(默认 '#303133' )
|
|
107
105
|
* @property {String | Number} size 字体大小(默认 15 )
|
|
108
|
-
* @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '
|
|
106
|
+
* @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '30rpx'} )
|
|
109
107
|
* @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
|
|
110
108
|
* @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 )
|
|
111
109
|
* @property {String | Number} lineHeight 文本行高,支持带单位值或无单位倍数(如 1.2)
|
|
@@ -114,96 +112,320 @@ function normalizeLineHeight(value) {
|
|
|
114
112
|
* @event {Function} click 点击触发事件
|
|
115
113
|
* @example <dd-text text="我用十年青春,赴你最后之约"></dd-text>
|
|
116
114
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
interface Props {
|
|
116
|
+
// 主题颜色
|
|
117
|
+
type?: string
|
|
118
|
+
// 是否显示
|
|
119
|
+
show?: boolean
|
|
120
|
+
// 显示的值
|
|
121
|
+
text?: string | number
|
|
122
|
+
// 前置图标
|
|
123
|
+
prefixIcon?: string
|
|
124
|
+
// 后置图标
|
|
125
|
+
suffixIcon?: string
|
|
126
|
+
// 文本处理的匹配模式
|
|
127
|
+
// text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
|
|
128
|
+
mode?: string
|
|
129
|
+
// mode=link下,配置的链接
|
|
130
|
+
href?: string
|
|
131
|
+
// 格式化规则
|
|
132
|
+
format?: string | ((text: any) => any)
|
|
133
|
+
// mode=phone时,点击文本是否拨打电话
|
|
134
|
+
call?: boolean
|
|
135
|
+
// 小程序的打开方式
|
|
136
|
+
openType?: string
|
|
137
|
+
// 是否粗体,默认normal
|
|
138
|
+
bold?: boolean
|
|
139
|
+
// 是否块状
|
|
140
|
+
block?: boolean
|
|
141
|
+
// 文本显示的行数,如果设置,超出此行数,将会显示省略号
|
|
142
|
+
lines?: string | number
|
|
143
|
+
// 文本颜色
|
|
144
|
+
color?: string
|
|
145
|
+
// 字体大小
|
|
146
|
+
size?: string | number
|
|
147
|
+
// 图标的样式
|
|
148
|
+
iconStyle?: Record<string, any> | string
|
|
149
|
+
// 文字装饰,下划线,中划线等,可选值 none|underline|line-through
|
|
150
|
+
decoration?: string
|
|
151
|
+
// 外边距,对象、字符串,数值形式均可
|
|
152
|
+
margin?: Record<string, any> | string | number
|
|
153
|
+
// 文本行高
|
|
154
|
+
lineHeight?: string | number
|
|
155
|
+
// 文本对齐方式,可选值left|center|right
|
|
156
|
+
align?: string
|
|
157
|
+
// 文字换行,可选值break-word|normal|anywhere
|
|
158
|
+
wordWrap?: string
|
|
159
|
+
// 占满剩余空间
|
|
160
|
+
flex1?: boolean
|
|
161
|
+
// 通用兜底 prop:自定义类名
|
|
162
|
+
customClass?: string
|
|
163
|
+
// 通用兜底 prop:定义需要用到的外部样式
|
|
164
|
+
customStyle?: Record<string, any> | string
|
|
165
|
+
// 小程序 button 透传属性
|
|
166
|
+
lang?: string
|
|
167
|
+
sessionFrom?: string
|
|
168
|
+
sendMessageTitle?: string
|
|
169
|
+
sendMessagePath?: string
|
|
170
|
+
sendMessageImg?: string
|
|
171
|
+
showMessageCard?: boolean
|
|
172
|
+
appParameter?: string
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
176
|
+
type: '',
|
|
177
|
+
show: true,
|
|
178
|
+
text: '',
|
|
179
|
+
prefixIcon: '',
|
|
180
|
+
suffixIcon: '',
|
|
181
|
+
mode: '',
|
|
182
|
+
href: '',
|
|
183
|
+
format: '',
|
|
184
|
+
call: false,
|
|
185
|
+
openType: '',
|
|
186
|
+
bold: false,
|
|
187
|
+
block: false,
|
|
188
|
+
lines: '',
|
|
189
|
+
color: '',
|
|
190
|
+
size: 15,
|
|
191
|
+
iconStyle: () => ({ fontSize: '30rpx' }),
|
|
192
|
+
decoration: 'none',
|
|
193
|
+
margin: 0,
|
|
194
|
+
lineHeight: '',
|
|
195
|
+
align: 'left',
|
|
196
|
+
wordWrap: 'normal',
|
|
197
|
+
flex1: false,
|
|
198
|
+
customClass: '',
|
|
199
|
+
customStyle: () => ({}),
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
const emit = defineEmits<{
|
|
203
|
+
(e: 'click', ev: any): void;
|
|
204
|
+
(e: 'getuserinfo', detail: any): void;
|
|
205
|
+
(e: 'contact', detail: any): void;
|
|
206
|
+
(e: 'getphonenumber', detail: any): void;
|
|
207
|
+
(e: 'error', detail: any): void;
|
|
208
|
+
(e: 'launchapp', detail: any): void;
|
|
209
|
+
(e: 'opensetting', detail: any): void;
|
|
210
|
+
}>()
|
|
211
|
+
|
|
212
|
+
// ponytail: 模板里的 :data-index="index" 沿袭 Options API 行为,取值为 undefined
|
|
213
|
+
const index = undefined
|
|
214
|
+
|
|
215
|
+
const isNvue = computed(() => {
|
|
216
|
+
let nvue = false
|
|
217
|
+
// #ifdef APP-NVUE
|
|
218
|
+
nvue = true
|
|
121
219
|
// #endif
|
|
122
|
-
|
|
123
|
-
|
|
220
|
+
return nvue
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
const isMp = computed(() => {
|
|
224
|
+
let mp = false
|
|
225
|
+
// #ifdef MP
|
|
226
|
+
mp = true
|
|
124
227
|
// #endif
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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
|
|
228
|
+
return mp
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
// 默认的姓名脱敏规则
|
|
232
|
+
function formatName(name: string) {
|
|
233
|
+
let value = ''
|
|
234
|
+
if (name.length === 2) {
|
|
235
|
+
value = name.substr(0, 1) + '*'
|
|
236
|
+
} else if (name.length > 2) {
|
|
237
|
+
let char = ''
|
|
238
|
+
for (let i = 0, len = name.length - 2; i < len; i++) {
|
|
239
|
+
char += '*'
|
|
171
240
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
241
|
+
value = name.substr(0, 1) + char + name.substr(-1, 1)
|
|
242
|
+
} else {
|
|
243
|
+
value = name
|
|
244
|
+
}
|
|
245
|
+
return value
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// 经处理后需要显示的值
|
|
249
|
+
const value = computed(() => {
|
|
250
|
+
const {
|
|
251
|
+
text,
|
|
252
|
+
mode,
|
|
253
|
+
format,
|
|
254
|
+
href
|
|
255
|
+
} = props
|
|
256
|
+
// 价格类型
|
|
257
|
+
if (mode === 'price') {
|
|
258
|
+
// 如果text不为金额进行提示
|
|
259
|
+
if (!/^\d+(\.\d+)?$/.test(String(text))) {
|
|
260
|
+
error('金额模式下,text参数需要为金额格式');
|
|
261
|
+
}
|
|
262
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
|
|
263
|
+
if (typeof format === 'function') {
|
|
264
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
265
|
+
return format(text)
|
|
266
|
+
}
|
|
267
|
+
// 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
|
|
268
|
+
return priceFormat(text, 2)
|
|
269
|
+
} if (mode === 'date') {
|
|
270
|
+
// 判断是否合法的日期或者时间戳
|
|
271
|
+
!test.date(text) && error('日期模式下,text参数需要为日期或时间戳格式')
|
|
272
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
|
|
273
|
+
if (typeof format === 'function') {
|
|
274
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
275
|
+
return format(text)
|
|
276
|
+
} if (format) {
|
|
277
|
+
// 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
|
|
278
|
+
return timeFormat(text, format)
|
|
279
|
+
}
|
|
280
|
+
// 如果没有设置format,则设置为默认的时间格式化形式
|
|
281
|
+
return timeFormat(text, 'yyyy-mm-dd')
|
|
282
|
+
} if (mode === 'phone') {
|
|
283
|
+
// 判断是否合法的手机号
|
|
284
|
+
// !test.mobile(text) && error('手机号模式下,text参数需要为手机号码格式')
|
|
285
|
+
if (typeof format === 'function') {
|
|
286
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
287
|
+
return format(text)
|
|
288
|
+
} if (format === 'encrypt') {
|
|
289
|
+
// 如果format为encrypt,则将手机号进行星号加密处理
|
|
290
|
+
const str = String(text)
|
|
291
|
+
return `${str.substr(0, 3)}****${str.substr(7)}`
|
|
186
292
|
}
|
|
293
|
+
return text
|
|
294
|
+
} if (mode === 'name') {
|
|
295
|
+
// 判断是否合法的字符粗
|
|
296
|
+
!(typeof (text) === 'string') && error('姓名模式下,text参数需要为字符串格式')
|
|
297
|
+
if (typeof format === 'function') {
|
|
298
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
299
|
+
return format(text)
|
|
300
|
+
} if (format === 'encrypt') {
|
|
301
|
+
// 如果format为encrypt,则将姓名进行星号加密处理
|
|
302
|
+
return formatName(String(text))
|
|
303
|
+
}
|
|
304
|
+
return text
|
|
305
|
+
} if (mode === 'link') {
|
|
306
|
+
// 判断是否合法的字符粗
|
|
307
|
+
!test.url(href) && error('超链接模式下,href参数需要为URL格式')
|
|
308
|
+
return text
|
|
309
|
+
}
|
|
310
|
+
return text
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
const wrapStyle = computed(() => {
|
|
314
|
+
let style: Record<string, any> = {
|
|
315
|
+
margin: props.margin,
|
|
316
|
+
justifyContent: props.align === 'left' ? 'flex-start' : props.align === 'center' ? 'center' : 'flex-end'
|
|
317
|
+
}
|
|
318
|
+
// 占满剩余空间
|
|
319
|
+
if (props.flex1) {
|
|
320
|
+
style.flex = 1;
|
|
321
|
+
// #ifndef APP-NVUE
|
|
322
|
+
style.width = '100%';
|
|
323
|
+
// #endif
|
|
324
|
+
}
|
|
325
|
+
return style;
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
const valueStyle = computed(() => {
|
|
329
|
+
const style: Record<string, any> = {
|
|
330
|
+
textDecoration: props.decoration,
|
|
331
|
+
fontWeight: props.bold ? 'bold' : 'normal',
|
|
332
|
+
wordWrap: props.wordWrap,
|
|
333
|
+
fontSize: addUnit(props.size)
|
|
334
|
+
}
|
|
335
|
+
if (!props.type) {
|
|
336
|
+
// ponytail: 剥离运行时主题;未传 color 时继承上下文,跟随设计系统文本色
|
|
337
|
+
style.color = props.color || 'inherit'
|
|
338
|
+
}
|
|
339
|
+
isNvue.value && props.lines && (style.lines = props.lines)
|
|
340
|
+
props.lineHeight &&
|
|
341
|
+
(style.lineHeight = normalizeLineHeight(props.lineHeight))
|
|
342
|
+
!isNvue.value && props.block && (style.display = 'block')
|
|
343
|
+
return deepMerge(style, addStyle(props.customStyle))
|
|
344
|
+
})
|
|
345
|
+
|
|
346
|
+
function clickHandler(e: any) {
|
|
347
|
+
// 如果为手机号模式,拨打电话
|
|
348
|
+
if (props.call && props.mode === 'phone') {
|
|
349
|
+
uni.makePhoneCall({
|
|
350
|
+
phoneNumber: props.text as string
|
|
351
|
+
})
|
|
187
352
|
}
|
|
353
|
+
emit('click', e)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function onGetUserInfo(event: any) {
|
|
357
|
+
emit('getuserinfo', event.detail)
|
|
188
358
|
}
|
|
359
|
+
|
|
360
|
+
function onContact(event: any) {
|
|
361
|
+
emit('contact', event.detail)
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
function onGetPhoneNumber(event: any) {
|
|
365
|
+
emit('getphonenumber', event.detail)
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function onError(event: any) {
|
|
369
|
+
emit('error', event.detail)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function onLaunchApp(event: any) {
|
|
373
|
+
emit('launchapp', event.detail)
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
function onOpenSetting(event: any) {
|
|
377
|
+
emit('opensetting', event.detail)
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
defineExpose({ value, wrapStyle, valueStyle, clickHandler, formatName })
|
|
189
381
|
</script>
|
|
190
382
|
|
|
191
383
|
<style lang="scss" scoped>
|
|
192
384
|
@import '../../scss/variables';
|
|
193
|
-
@import '../../scss/
|
|
385
|
+
@import '../../scss/mixins';
|
|
386
|
+
|
|
387
|
+
// 按钮重置(原 dd-shared 全局工具类,收敛到本组件 scoped 内)
|
|
388
|
+
.dd-reset-button {
|
|
389
|
+
padding: 0;
|
|
390
|
+
background-color: transparent;
|
|
391
|
+
font-size: inherit;
|
|
392
|
+
line-height: inherit;
|
|
393
|
+
color: inherit;
|
|
394
|
+
&::after {
|
|
395
|
+
border: none;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
// 多行省略(模板按 lines 动态拼 dd-line-N)
|
|
400
|
+
@for $i from 1 through 10 {
|
|
401
|
+
.dd-line-#{$i} {
|
|
402
|
+
/* #ifdef APP-NVUE */
|
|
403
|
+
lines: $i;
|
|
404
|
+
text-overflow: ellipsis;
|
|
405
|
+
overflow: hidden;
|
|
406
|
+
flex: 1;
|
|
407
|
+
/* #endif */
|
|
408
|
+
/* #ifndef APP-NVUE */
|
|
409
|
+
display: -webkit-box;
|
|
410
|
+
-webkit-box-orient: vertical;
|
|
411
|
+
-webkit-line-clamp: $i;
|
|
412
|
+
overflow: hidden;
|
|
413
|
+
/* #endif */
|
|
414
|
+
}
|
|
415
|
+
}
|
|
194
416
|
.dd-text {
|
|
195
|
-
@include flex(row);
|
|
417
|
+
@include dd-flex(row);
|
|
196
418
|
align-items: center;
|
|
197
419
|
flex-wrap: nowrap;
|
|
198
420
|
|
|
199
421
|
&__price {
|
|
200
|
-
font-size:
|
|
422
|
+
font-size: $dd-font-size-body;
|
|
201
423
|
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
202
424
|
}
|
|
203
425
|
|
|
204
426
|
&__value {
|
|
205
|
-
font-size:
|
|
206
|
-
@include flex;
|
|
427
|
+
font-size: $dd-font-size-body;
|
|
428
|
+
@include dd-flex;
|
|
207
429
|
color: var(--dd-text-secondary, #{$dd-text-secondary});
|
|
208
430
|
flex-wrap: wrap;
|
|
209
431
|
// flex: 1;
|