hy-app 0.6.6 → 0.6.7
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/components/hy-calendar/hy-calendar.vue +2 -3
- package/components/hy-cell-item/props.ts +1 -1
- package/components/hy-grid/hy-grid.vue +33 -12
- package/components/hy-grid/index.scss +18 -0
- package/components/hy-grid/typing.d.ts +8 -7
- package/components/hy-menu/hy-menu.vue +117 -159
- package/components/hy-menu/props.ts +3 -3
- package/components/hy-menu/typing.d.ts +3 -4
- package/components/hy-notice-bar/hy-row-notice.vue +2 -2
- package/components/hy-qrcode/qrcode.js +1189 -1149
- package/components/hy-signature/hy-signature.vue +38 -32
- package/components/hy-steps/hy-steps.vue +276 -275
- package/components/hy-sticky/hy-sticky.vue +2 -1
- package/components/hy-swiper/hy-swiper.vue +230 -224
- package/components/hy-swiper/props.ts +1 -1
- package/libs/composables/useShakeService.ts +64 -64
- package/libs/utils/utils.ts +1 -0
- package/package.json +1 -1
|
@@ -525,7 +525,11 @@ function getContext() {
|
|
|
525
525
|
// #ifndef MP-WEIXIN
|
|
526
526
|
getRect(`#${canvasId.value}`, false, instance).then((canvasRect) => {
|
|
527
527
|
setCanvasState(canvasRect.width!, canvasRect.height!)
|
|
528
|
+
// #ifdef MP-ALIPAY
|
|
529
|
+
canvasState.ctx = uni.createCanvasContext(canvasId.value)
|
|
530
|
+
// #else
|
|
528
531
|
canvasState.ctx = uni.createCanvasContext(canvasId.value, instance.proxy)
|
|
532
|
+
// #endif
|
|
529
533
|
if (canvasState.ctx) {
|
|
530
534
|
canvasState.ctx.scale(pixelRatio.value, pixelRatio.value)
|
|
531
535
|
}
|
|
@@ -579,40 +583,42 @@ function setLine() {
|
|
|
579
583
|
function canvasToImage() {
|
|
580
584
|
const { fileType, quality, exportScale } = props
|
|
581
585
|
const { canvasWidth, canvasHeight } = canvasState
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
success: true
|
|
598
|
-
}
|
|
599
|
-
// #ifdef MP-DINGTALK
|
|
600
|
-
result.tempFilePath = (res as any).filePath
|
|
601
|
-
// #endif
|
|
602
|
-
emit('confirm', result)
|
|
603
|
-
},
|
|
604
|
-
fail: () => {
|
|
605
|
-
const result: SignatureResult = {
|
|
606
|
-
tempFilePath: '',
|
|
607
|
-
width: (canvasWidth * exportScale) / pixelRatio.value,
|
|
608
|
-
height: (canvasHeight * exportScale) / pixelRatio.value,
|
|
609
|
-
success: false
|
|
610
|
-
}
|
|
611
|
-
emit('confirm', result)
|
|
586
|
+
const options = {
|
|
587
|
+
width: canvasWidth * exportScale,
|
|
588
|
+
height: canvasHeight * exportScale,
|
|
589
|
+
destWidth: canvasWidth * exportScale,
|
|
590
|
+
destHeight: canvasHeight * exportScale,
|
|
591
|
+
fileType,
|
|
592
|
+
quality,
|
|
593
|
+
canvasId: canvasId.value,
|
|
594
|
+
canvas: canvas,
|
|
595
|
+
success: (res: any) => {
|
|
596
|
+
const result: SignatureResult = {
|
|
597
|
+
tempFilePath: res.tempFilePath,
|
|
598
|
+
width: (canvasWidth * exportScale) / pixelRatio.value,
|
|
599
|
+
height: (canvasHeight * exportScale) / pixelRatio.value,
|
|
600
|
+
success: true
|
|
612
601
|
}
|
|
602
|
+
// #ifdef MP-DINGTALK
|
|
603
|
+
result.tempFilePath = (res as any).filePath
|
|
604
|
+
// #endif
|
|
605
|
+
emit('confirm', result)
|
|
613
606
|
},
|
|
614
|
-
|
|
615
|
-
|
|
607
|
+
fail: () => {
|
|
608
|
+
const result: SignatureResult = {
|
|
609
|
+
tempFilePath: '',
|
|
610
|
+
width: (canvasWidth * exportScale) / pixelRatio.value,
|
|
611
|
+
height: (canvasHeight * exportScale) / pixelRatio.value,
|
|
612
|
+
success: false
|
|
613
|
+
}
|
|
614
|
+
emit('confirm', result)
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
// #ifdef MP-ALIPAY
|
|
618
|
+
uni.canvasToTempFilePath(options)
|
|
619
|
+
// #else
|
|
620
|
+
uni.canvasToTempFilePath(options, instance.proxy)
|
|
621
|
+
// #endif
|
|
616
622
|
}
|
|
617
623
|
|
|
618
624
|
function clearCanvas() {
|
|
@@ -1,275 +1,276 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view :class="[`hy-steps--${direction}`, 'hy-steps']">
|
|
3
|
-
<template v-for="(item, i) in list" :key="i">
|
|
4
|
-
<view ref="hy-steps-item" :class="[`hy-steps-item--${direction}`, 'hy-steps-item']">
|
|
5
|
-
<!-- 线条 -->
|
|
6
|
-
<view
|
|
7
|
-
v-if="i + 1 < list.length"
|
|
8
|
-
:class="[
|
|
9
|
-
`hy-steps-item__line--${direction}`,
|
|
10
|
-
'hy-steps-item__line',
|
|
11
|
-
statusClass(i + 1, list[i + 1].error)
|
|
12
|
-
]"
|
|
13
|
-
:style="lineStyle(item, i)"
|
|
14
|
-
></view>
|
|
15
|
-
<!-- 线条 -->
|
|
16
|
-
|
|
17
|
-
<!-- 步骤状态 -->
|
|
18
|
-
<view
|
|
19
|
-
:class="[
|
|
20
|
-
`hy-steps-item__wrapper--${direction}`,
|
|
21
|
-
dot ? `hy-steps-item__wrapper--dot` : statusClass(i, item.error),
|
|
22
|
-
'hy-steps-item__wrapper'
|
|
23
|
-
]"
|
|
24
|
-
:style="itemStyleInner"
|
|
25
|
-
>
|
|
26
|
-
<slot v-if="$slots.icon" name="icon" :error="item?.error" :index="i"></slot>
|
|
27
|
-
<template v-else>
|
|
28
|
-
<view
|
|
29
|
-
:class="[
|
|
30
|
-
'hy-steps-item__wrapper--dot__item',
|
|
31
|
-
`hy-steps-item__wrapper--dot__${statusClass(i, item.error)}`
|
|
32
|
-
]"
|
|
33
|
-
v-if="dot"
|
|
34
|
-
:style="{
|
|
35
|
-
backgroundColor: statusColor(i, item?.error)
|
|
36
|
-
}"
|
|
37
|
-
></view>
|
|
38
|
-
<view
|
|
39
|
-
class="hy-steps-item__wrapper__icon"
|
|
40
|
-
v-else-if="activeIcon || inactiveIcon"
|
|
41
|
-
>
|
|
42
|
-
<hy-icon
|
|
43
|
-
:name="i <= current ? activeIcon : inactiveIcon"
|
|
44
|
-
:size="iconSize"
|
|
45
|
-
:color="i <= current ? activeColor : inactiveColor"
|
|
46
|
-
></hy-icon>
|
|
47
|
-
</view>
|
|
48
|
-
<view
|
|
49
|
-
v-else
|
|
50
|
-
:style="{
|
|
51
|
-
backgroundColor:
|
|
52
|
-
statusClass(i, item.error) === 'process'
|
|
53
|
-
? activeColor
|
|
54
|
-
: 'transparent',
|
|
55
|
-
borderColor: statusColor(i, item?.error)
|
|
56
|
-
}"
|
|
57
|
-
class="hy-steps-item__wrapper__circle"
|
|
58
|
-
>
|
|
59
|
-
<text
|
|
60
|
-
v-if="
|
|
61
|
-
statusClass(i, item.error) === 'process' ||
|
|
62
|
-
statusClass(i, item.error) === 'wait'
|
|
63
|
-
"
|
|
64
|
-
class="hy-steps-item__wrapper__circle__text"
|
|
65
|
-
:style="{
|
|
66
|
-
color: textColor(i)
|
|
67
|
-
}"
|
|
68
|
-
>
|
|
69
|
-
{{ i + 1 }}
|
|
70
|
-
</text>
|
|
71
|
-
<hy-icon
|
|
72
|
-
v-else
|
|
73
|
-
:color="
|
|
74
|
-
statusClass(i, item.error) === 'error' ? 'error' : activeColor
|
|
75
|
-
"
|
|
76
|
-
:size="iconSize"
|
|
77
|
-
:name="
|
|
78
|
-
statusClass(i, item.error) === 'error'
|
|
79
|
-
? IconConfig.CLOSE
|
|
80
|
-
: IconConfig.CHECK_MASK
|
|
81
|
-
"
|
|
82
|
-
></hy-icon>
|
|
83
|
-
</view>
|
|
84
|
-
</template>
|
|
85
|
-
</view>
|
|
86
|
-
<!-- 步骤状态 -->
|
|
87
|
-
|
|
88
|
-
<!-- 内容区域 -->
|
|
89
|
-
<view
|
|
90
|
-
class="hy-steps-item__content"
|
|
91
|
-
:class="[`hy-steps-item__content--${direction}`]"
|
|
92
|
-
:style="[contentStyle]"
|
|
93
|
-
>
|
|
94
|
-
<slot v-if="$slots.content" name="content" :record="item" :index="i"></slot>
|
|
95
|
-
<template v-else>
|
|
96
|
-
<slot
|
|
97
|
-
v-if="$slots.title"
|
|
98
|
-
name="title"
|
|
99
|
-
:title="item.title"
|
|
100
|
-
:index="i"
|
|
101
|
-
></slot>
|
|
102
|
-
<text v-else :class="titleClass(i, item.error)">
|
|
103
|
-
{{ item.title }}
|
|
104
|
-
</text>
|
|
105
|
-
<slot v-if="$slots.docs" name="docs" :desc="item.docs" :index="i"></slot>
|
|
106
|
-
<text v-else :style="{ fontSize: '12px', color: '#999' }">{{
|
|
107
|
-
item.docs
|
|
108
|
-
}}</text>
|
|
109
|
-
<text class="hy-steps-item__content--date">{{ item.date }}</text>
|
|
110
|
-
</template>
|
|
111
|
-
</view>
|
|
112
|
-
<!-- 内容区域 -->
|
|
113
|
-
</view>
|
|
114
|
-
</template>
|
|
115
|
-
</view>
|
|
116
|
-
</template>
|
|
117
|
-
|
|
118
|
-
<script lang="ts">
|
|
119
|
-
export default {
|
|
120
|
-
name: 'hy-steps',
|
|
121
|
-
options: {
|
|
122
|
-
addGlobalClass: true,
|
|
123
|
-
virtualHost: true,
|
|
124
|
-
styleIsolation: 'shared'
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
</script>
|
|
128
|
-
|
|
129
|
-
<script setup lang="ts">
|
|
130
|
-
import { computed, ref, onMounted, getCurrentInstance, watch } from 'vue'
|
|
131
|
-
import type { CSSProperties } from 'vue'
|
|
132
|
-
import type { IStepsEmits } from './typing'
|
|
133
|
-
import type { StepListVo } from './typing'
|
|
134
|
-
import { addUnit, getRect, ColorConfig, IconConfig } from '../../libs'
|
|
135
|
-
import stepsProps from './props'
|
|
136
|
-
// 组件
|
|
137
|
-
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* 一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
|
|
141
|
-
* @displayName hy-steps
|
|
142
|
-
*/
|
|
143
|
-
defineOptions({})
|
|
144
|
-
|
|
145
|
-
const props = defineProps(stepsProps)
|
|
146
|
-
const emit = defineEmits<IStepsEmits>()
|
|
147
|
-
|
|
148
|
-
const itemRect = ref<UniApp.NodeInfo[]>([])
|
|
149
|
-
const stepsRects = ref<UniApp.NodeInfo[]>([])
|
|
150
|
-
const instance = getCurrentInstance()
|
|
151
|
-
|
|
152
|
-
watch(
|
|
153
|
-
() => props.current,
|
|
154
|
-
(newVal: number) => {
|
|
155
|
-
if (props.list[newVal - 1]?.error) {
|
|
156
|
-
const index = props.list.findIndex((item) => item.error)
|
|
157
|
-
emit('update:current', index)
|
|
158
|
-
emit('change', index)
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
// 字体标题类名
|
|
164
|
-
const titleClass = computed(() => {
|
|
165
|
-
return (index: number, error: boolean) => {
|
|
166
|
-
const classes = ['hy-steps-item__content__title']
|
|
167
|
-
if (props.current === index) {
|
|
168
|
-
classes.push('hy-steps-item__content__title--active')
|
|
169
|
-
|
|
170
|
-
if (error) {
|
|
171
|
-
classes.push('hy-steps-item__content__title--error')
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return classes
|
|
176
|
-
}
|
|
177
|
-
})
|
|
178
|
-
// 字体颜色
|
|
179
|
-
const textColor = computed(() => {
|
|
180
|
-
return (index: number) => (index === props.current ? '#ffffff' : props.inactiveColor)
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* 线条样式
|
|
185
|
-
* */
|
|
186
|
-
const lineStyle = computed(() => {
|
|
187
|
-
return (temp: StepListVo, index: number): CSSProperties => {
|
|
188
|
-
const style: CSSProperties = {}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
style.
|
|
198
|
-
|
|
199
|
-
style.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
*
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
style.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
style.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="[`hy-steps--${direction}`, 'hy-steps']">
|
|
3
|
+
<template v-for="(item, i) in list" :key="i">
|
|
4
|
+
<view ref="hy-steps-item" :class="[`hy-steps-item--${direction}`, 'hy-steps-item']">
|
|
5
|
+
<!-- 线条 -->
|
|
6
|
+
<view
|
|
7
|
+
v-if="i + 1 < list.length"
|
|
8
|
+
:class="[
|
|
9
|
+
`hy-steps-item__line--${direction}`,
|
|
10
|
+
'hy-steps-item__line',
|
|
11
|
+
statusClass(i + 1, list[i + 1].error)
|
|
12
|
+
]"
|
|
13
|
+
:style="lineStyle(item, i)"
|
|
14
|
+
></view>
|
|
15
|
+
<!-- 线条 -->
|
|
16
|
+
|
|
17
|
+
<!-- 步骤状态 -->
|
|
18
|
+
<view
|
|
19
|
+
:class="[
|
|
20
|
+
`hy-steps-item__wrapper--${direction}`,
|
|
21
|
+
dot ? `hy-steps-item__wrapper--dot` : statusClass(i, item.error),
|
|
22
|
+
'hy-steps-item__wrapper'
|
|
23
|
+
]"
|
|
24
|
+
:style="itemStyleInner"
|
|
25
|
+
>
|
|
26
|
+
<slot v-if="$slots.icon" name="icon" :error="item?.error" :index="i"></slot>
|
|
27
|
+
<template v-else>
|
|
28
|
+
<view
|
|
29
|
+
:class="[
|
|
30
|
+
'hy-steps-item__wrapper--dot__item',
|
|
31
|
+
`hy-steps-item__wrapper--dot__${statusClass(i, item.error)}`
|
|
32
|
+
]"
|
|
33
|
+
v-if="dot"
|
|
34
|
+
:style="{
|
|
35
|
+
backgroundColor: statusColor(i, item?.error)
|
|
36
|
+
}"
|
|
37
|
+
></view>
|
|
38
|
+
<view
|
|
39
|
+
class="hy-steps-item__wrapper__icon"
|
|
40
|
+
v-else-if="activeIcon || inactiveIcon"
|
|
41
|
+
>
|
|
42
|
+
<hy-icon
|
|
43
|
+
:name="i <= current ? activeIcon : inactiveIcon"
|
|
44
|
+
:size="iconSize"
|
|
45
|
+
:color="i <= current ? activeColor : inactiveColor"
|
|
46
|
+
></hy-icon>
|
|
47
|
+
</view>
|
|
48
|
+
<view
|
|
49
|
+
v-else
|
|
50
|
+
:style="{
|
|
51
|
+
backgroundColor:
|
|
52
|
+
statusClass(i, item.error) === 'process'
|
|
53
|
+
? activeColor
|
|
54
|
+
: 'transparent',
|
|
55
|
+
borderColor: statusColor(i, item?.error)
|
|
56
|
+
}"
|
|
57
|
+
class="hy-steps-item__wrapper__circle"
|
|
58
|
+
>
|
|
59
|
+
<text
|
|
60
|
+
v-if="
|
|
61
|
+
statusClass(i, item.error) === 'process' ||
|
|
62
|
+
statusClass(i, item.error) === 'wait'
|
|
63
|
+
"
|
|
64
|
+
class="hy-steps-item__wrapper__circle__text"
|
|
65
|
+
:style="{
|
|
66
|
+
color: textColor(i)
|
|
67
|
+
}"
|
|
68
|
+
>
|
|
69
|
+
{{ i + 1 }}
|
|
70
|
+
</text>
|
|
71
|
+
<hy-icon
|
|
72
|
+
v-else
|
|
73
|
+
:color="
|
|
74
|
+
statusClass(i, item.error) === 'error' ? 'error' : activeColor
|
|
75
|
+
"
|
|
76
|
+
:size="iconSize"
|
|
77
|
+
:name="
|
|
78
|
+
statusClass(i, item.error) === 'error'
|
|
79
|
+
? IconConfig.CLOSE
|
|
80
|
+
: IconConfig.CHECK_MASK
|
|
81
|
+
"
|
|
82
|
+
></hy-icon>
|
|
83
|
+
</view>
|
|
84
|
+
</template>
|
|
85
|
+
</view>
|
|
86
|
+
<!-- 步骤状态 -->
|
|
87
|
+
|
|
88
|
+
<!-- 内容区域 -->
|
|
89
|
+
<view
|
|
90
|
+
class="hy-steps-item__content"
|
|
91
|
+
:class="[`hy-steps-item__content--${direction}`]"
|
|
92
|
+
:style="[contentStyle]"
|
|
93
|
+
>
|
|
94
|
+
<slot v-if="$slots.content" name="content" :record="item" :index="i"></slot>
|
|
95
|
+
<template v-else>
|
|
96
|
+
<slot
|
|
97
|
+
v-if="$slots.title"
|
|
98
|
+
name="title"
|
|
99
|
+
:title="item.title"
|
|
100
|
+
:index="i"
|
|
101
|
+
></slot>
|
|
102
|
+
<text v-else :class="titleClass(i, item.error)">
|
|
103
|
+
{{ item.title }}
|
|
104
|
+
</text>
|
|
105
|
+
<slot v-if="$slots.docs" name="docs" :desc="item.docs" :index="i"></slot>
|
|
106
|
+
<text v-else :style="{ fontSize: '12px', color: '#999' }">{{
|
|
107
|
+
item.docs
|
|
108
|
+
}}</text>
|
|
109
|
+
<text class="hy-steps-item__content--date">{{ item.date }}</text>
|
|
110
|
+
</template>
|
|
111
|
+
</view>
|
|
112
|
+
<!-- 内容区域 -->
|
|
113
|
+
</view>
|
|
114
|
+
</template>
|
|
115
|
+
</view>
|
|
116
|
+
</template>
|
|
117
|
+
|
|
118
|
+
<script lang="ts">
|
|
119
|
+
export default {
|
|
120
|
+
name: 'hy-steps',
|
|
121
|
+
options: {
|
|
122
|
+
addGlobalClass: true,
|
|
123
|
+
virtualHost: true,
|
|
124
|
+
styleIsolation: 'shared'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<script setup lang="ts">
|
|
130
|
+
import { computed, ref, onMounted, getCurrentInstance, watch, nextTick } from 'vue'
|
|
131
|
+
import type { CSSProperties } from 'vue'
|
|
132
|
+
import type { IStepsEmits } from './typing'
|
|
133
|
+
import type { StepListVo } from './typing'
|
|
134
|
+
import { addUnit, getRect, ColorConfig, IconConfig } from '../../libs'
|
|
135
|
+
import stepsProps from './props'
|
|
136
|
+
// 组件
|
|
137
|
+
import HyIcon from '../hy-icon/hy-icon.vue'
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* 一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。
|
|
141
|
+
* @displayName hy-steps
|
|
142
|
+
*/
|
|
143
|
+
defineOptions({})
|
|
144
|
+
|
|
145
|
+
const props = defineProps(stepsProps)
|
|
146
|
+
const emit = defineEmits<IStepsEmits>()
|
|
147
|
+
|
|
148
|
+
const itemRect = ref<UniApp.NodeInfo[]>([])
|
|
149
|
+
const stepsRects = ref<UniApp.NodeInfo[]>([])
|
|
150
|
+
const instance = getCurrentInstance()
|
|
151
|
+
|
|
152
|
+
watch(
|
|
153
|
+
() => props.current,
|
|
154
|
+
(newVal: number) => {
|
|
155
|
+
if (props.list[newVal - 1]?.error) {
|
|
156
|
+
const index = props.list.findIndex((item) => item.error)
|
|
157
|
+
emit('update:current', index)
|
|
158
|
+
emit('change', index)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
|
|
163
|
+
// 字体标题类名
|
|
164
|
+
const titleClass = computed(() => {
|
|
165
|
+
return (index: number, error: boolean) => {
|
|
166
|
+
const classes = ['hy-steps-item__content__title']
|
|
167
|
+
if (props.current === index) {
|
|
168
|
+
classes.push('hy-steps-item__content__title--active')
|
|
169
|
+
|
|
170
|
+
if (error) {
|
|
171
|
+
classes.push('hy-steps-item__content__title--error')
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return classes
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
// 字体颜色
|
|
179
|
+
const textColor = computed(() => {
|
|
180
|
+
return (index: number) => (index === props.current ? '#ffffff' : props.inactiveColor)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 线条样式
|
|
185
|
+
* */
|
|
186
|
+
const lineStyle = computed(() => {
|
|
187
|
+
return (temp: StepListVo, index: number): CSSProperties => {
|
|
188
|
+
const style: CSSProperties = {}
|
|
189
|
+
style.backgroundColor = temp.error ? '' : index < props.current ? '' : props.inactiveColor
|
|
190
|
+
|
|
191
|
+
if (!stepsRects.value.length || !itemRect.value[index]) return style
|
|
192
|
+
if (props.direction === 'row') {
|
|
193
|
+
style.width = addUnit(stepsRects.value[index].width! - itemRect.value[index].width!)
|
|
194
|
+
style.left = addUnit(
|
|
195
|
+
stepsRects.value[index].width! / 2 + itemRect.value[index].width! / 2
|
|
196
|
+
)
|
|
197
|
+
style.top = addUnit(itemRect.value[index].height! / 2)
|
|
198
|
+
} else {
|
|
199
|
+
style.height = addUnit(stepsRects.value[index].height! - itemRect.value[index].height!)
|
|
200
|
+
style.left = addUnit(itemRect.value[index].width! / 2)
|
|
201
|
+
style.top = addUnit(itemRect.value[index].height)
|
|
202
|
+
}
|
|
203
|
+
return style
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
const itemStyleInner = computed(() => {
|
|
208
|
+
return {}
|
|
209
|
+
})
|
|
210
|
+
/**
|
|
211
|
+
* 状态类名
|
|
212
|
+
* */
|
|
213
|
+
const statusClass = computed(() => {
|
|
214
|
+
return (index: number, error: boolean = false) => {
|
|
215
|
+
if (props.current == index) {
|
|
216
|
+
return error ? 'error' : 'process'
|
|
217
|
+
} else if (props.current > index) {
|
|
218
|
+
return 'finish'
|
|
219
|
+
} else {
|
|
220
|
+
return 'wait'
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
const statusColor = computed(() => {
|
|
225
|
+
return (index: number, error?: boolean) => {
|
|
226
|
+
let colorTmp: string | number
|
|
227
|
+
switch (statusClass.value(index, error)) {
|
|
228
|
+
case 'finish':
|
|
229
|
+
colorTmp = props.activeColor
|
|
230
|
+
break
|
|
231
|
+
case 'error':
|
|
232
|
+
colorTmp = ColorConfig.error
|
|
233
|
+
break
|
|
234
|
+
case 'process':
|
|
235
|
+
colorTmp = props.dot ? props.current : 'transparent'
|
|
236
|
+
break
|
|
237
|
+
default:
|
|
238
|
+
colorTmp = props.inactiveColor
|
|
239
|
+
break
|
|
240
|
+
}
|
|
241
|
+
return colorTmp
|
|
242
|
+
}
|
|
243
|
+
})
|
|
244
|
+
|
|
245
|
+
const contentStyle = computed<CSSProperties>(() => {
|
|
246
|
+
const style: CSSProperties = {}
|
|
247
|
+
if (props.direction === 'column') {
|
|
248
|
+
style.marginLeft = props.dot ? '2px' : '6px'
|
|
249
|
+
style.marginTop = props.dot ? '0px' : '0px'
|
|
250
|
+
} else {
|
|
251
|
+
style.marginTop = props.dot ? '2px' : '6px'
|
|
252
|
+
style.marginLeft = props.dot ? '0px' : '0px'
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return style
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
onMounted(() => {
|
|
259
|
+
getStepsItemRect()
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
// 获取组件的尺寸,用于设置横线的位置
|
|
263
|
+
const getStepsItemRect = () => {
|
|
264
|
+
getRect('.hy-steps-item', true, instance).then((rect) => {
|
|
265
|
+
stepsRects.value = rect as UniApp.NodeInfo[]
|
|
266
|
+
})
|
|
267
|
+
|
|
268
|
+
getRect('.hy-steps-item__wrapper', true, instance).then((rect) => {
|
|
269
|
+
itemRect.value = rect as UniApp.NodeInfo[]
|
|
270
|
+
})
|
|
271
|
+
}
|
|
272
|
+
</script>
|
|
273
|
+
|
|
274
|
+
<style lang="scss" scoped>
|
|
275
|
+
@import './index.scss';
|
|
276
|
+
</style>
|
|
@@ -188,9 +188,10 @@ onMounted(() => {
|
|
|
188
188
|
|
|
189
189
|
// 始终绑定 page scroll 回退(能兼容大多数场景)
|
|
190
190
|
// 注意:如果页面使用 scroll-view(而非页面滚动),你应传入 scrollSelector 以使用 relativeTo(container)
|
|
191
|
-
onPageScroll && onPageScroll(onPageScrollListener)
|
|
191
|
+
// onPageScroll && onPageScroll(onPageScrollListener)
|
|
192
192
|
})
|
|
193
193
|
})
|
|
194
|
+
onPageScroll && onPageScroll(onPageScrollListener)
|
|
194
195
|
|
|
195
196
|
onUnmounted(() => {
|
|
196
197
|
observer?.disconnect()
|