stellar-ui-v2 1.35.3
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/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# Tour 指引
|
|
2
|
+
|
|
3
|
+
> 用于创建一个带有步骤的指引
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
## 使用示例
|
|
8
|
+
- 示例代码中用到的公共CSS样式
|
|
9
|
+
```css
|
|
10
|
+
.button-box {
|
|
11
|
+
display: inline-block;
|
|
12
|
+
padding: 20rpx;
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### 基础用法
|
|
18
|
+
- 属性`show`用于控制显示隐藏
|
|
19
|
+
- 属性`steps`用于设置步骤内容,数组形式,数组中每个元素是一个对象,对象包含以下属性
|
|
20
|
+
- 对象属性`message`:步骤内容,**必须**
|
|
21
|
+
- 对象属性`target`:步骤内容对应的元素ID,**必须**
|
|
22
|
+
- 对象属性`title`:步骤标题
|
|
23
|
+
- 对象属性`position`:步骤位置
|
|
24
|
+
- 若`position`属性不设置,则自动计算合适的位置
|
|
25
|
+
- 可选值`top`、`bottom`、`top-start`、`top-center`、`top-end`、`bottom-start`、`bottom-center`、`bottom-end`
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<template>
|
|
29
|
+
<view class="title">基础用法</view>
|
|
30
|
+
<view id="button" class="button-box">
|
|
31
|
+
<ste-button @click="show = true">基础提示</ste-button>
|
|
32
|
+
</view>
|
|
33
|
+
<ste-tour :show.sync="show" :steps="steps"></ste-tour>
|
|
34
|
+
</template>
|
|
35
|
+
<script>
|
|
36
|
+
export default {
|
|
37
|
+
data(){
|
|
38
|
+
return{
|
|
39
|
+
show:false,
|
|
40
|
+
steps: [{ message: '点这里', target: 'button' }],
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
</script>
|
|
45
|
+
```
|
|
46
|
+
### 位置偏移量
|
|
47
|
+
- 属性`offset`用于设置位置偏移量,数组形式,数组中两个元素分别表示横纵方向上的偏移量
|
|
48
|
+
|
|
49
|
+
```html
|
|
50
|
+
<template>
|
|
51
|
+
<view id="button-2" class="button-box">
|
|
52
|
+
<ste-button @click="show2 = true">描述位置偏移</ste-button>
|
|
53
|
+
</view>
|
|
54
|
+
<ste-tour :show.sync="show2" :steps="steps2" :offset="[20, 10]"></ste-tour>
|
|
55
|
+
</template>
|
|
56
|
+
<script>
|
|
57
|
+
export default {
|
|
58
|
+
data(){
|
|
59
|
+
return{
|
|
60
|
+
show2: false,
|
|
61
|
+
steps2: [{ message: '点这里', target: 'button-2' }],
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
66
|
+
```
|
|
67
|
+
- 默认插槽可以自定义描述内容,插槽参数`item`为当前步骤信息
|
|
68
|
+
- 属性`messageBg`可以将默认背景改为透明,然后通过插槽自定义背景样式,实现自定义描述内容。
|
|
69
|
+
- 如果需要内容区域点击不关闭提示,可使用`@click.stop`阻止内容区域点击冒泡
|
|
70
|
+
```html
|
|
71
|
+
<template>
|
|
72
|
+
<view
|
|
73
|
+
id="button-6"
|
|
74
|
+
style="
|
|
75
|
+
border: 1px solid #ddd;
|
|
76
|
+
width: 120rpx;
|
|
77
|
+
height: 120rpx;
|
|
78
|
+
line-height: 120rpx;
|
|
79
|
+
border-radius: 60rpx;
|
|
80
|
+
text-align: center;
|
|
81
|
+
margin-left: 60rpx;
|
|
82
|
+
"
|
|
83
|
+
@click="show6 = true"
|
|
84
|
+
>
|
|
85
|
+
插槽
|
|
86
|
+
</view>
|
|
87
|
+
<ste-tour :show.sync="show6" :steps="steps6" :offset="[-20, -30]" messageBg="transparent" radius="60">
|
|
88
|
+
<image
|
|
89
|
+
src="https://image.whzb.com/chain/StellarUI/component-icons/tour.png"
|
|
90
|
+
mode="widthFix"
|
|
91
|
+
style="width: 630rpx"
|
|
92
|
+
></image>
|
|
93
|
+
</ste-tour>
|
|
94
|
+
</template>
|
|
95
|
+
<script>
|
|
96
|
+
export default {
|
|
97
|
+
data(){
|
|
98
|
+
return{
|
|
99
|
+
show6: false,
|
|
100
|
+
steps6: [{ message: '点这里', target: 'button-2' }],
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
</script>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### 多步骤,显示标题栏
|
|
108
|
+
- 属性`offset`用于设置位置偏移量,数组形式,数组中两个元素分别表示横纵方向上的偏移量
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<template>
|
|
112
|
+
<ste-button @click="show3 = true">多步骤带标题</ste-button>
|
|
113
|
+
<view style="display: inline-block; padding: 6rpx 20rpx">
|
|
114
|
+
<view id="step-1" class="button-box">步骤1</view>
|
|
115
|
+
<view id="step-2" class="button-box">步骤2</view>
|
|
116
|
+
<view id="step-3" class="button-box">步骤3</view>
|
|
117
|
+
</view>
|
|
118
|
+
<ste-tour showTitleBar :show.sync="show3" :steps="steps3"></ste-tour>
|
|
119
|
+
</template>
|
|
120
|
+
<script>
|
|
121
|
+
export default {
|
|
122
|
+
data(){
|
|
123
|
+
return{
|
|
124
|
+
show3: false,
|
|
125
|
+
steps3: [
|
|
126
|
+
{ title: '步骤1', message: '先点这里', target: 'step-1' },
|
|
127
|
+
{ title: '步骤2', message: '再点这里', target: 'step-2' },
|
|
128
|
+
{ title: '步骤3', message: '然后点这里', target: 'step-3' },
|
|
129
|
+
],
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
</script>
|
|
134
|
+
```
|
|
135
|
+
### 不显示背景蒙层
|
|
136
|
+
- 属性`mask`用于设置是否显示背景蒙层,默认显示
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<template>
|
|
140
|
+
<view id="button-4" class="button-box">
|
|
141
|
+
<ste-button @click="show4 = true">不显示背景蒙层</ste-button>
|
|
142
|
+
</view>
|
|
143
|
+
<ste-tour :show.sync="show4" :steps="steps4" :mask="false"></ste-tour>
|
|
144
|
+
</template>
|
|
145
|
+
<script>
|
|
146
|
+
export default {
|
|
147
|
+
data(){
|
|
148
|
+
return{
|
|
149
|
+
show4: false,
|
|
150
|
+
steps4: [{ message: '点这里', target: 'button-4' }],
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
</script>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
---$
|
|
160
|
+
### API
|
|
161
|
+
#### Props
|
|
162
|
+
背景之外的颜色属性只支持`16进制`、`RGB`、`RGBA`格式
|
|
163
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
164
|
+
| ----- | ----- | ----- | ----- | ----- | ----- |
|
|
165
|
+
| `show` | 是否显示,支持`.sync`双向绑定 | `Boolean` | `false` | - | - |
|
|
166
|
+
| `current` | 当前步骤,多个步骤时有效 | `Number` | `0` | - | - |
|
|
167
|
+
| `steps` | 步骤数组,`Step`对象描述见基础用法说明 | `Array<Step>` | `[]` | - | - |
|
|
168
|
+
| `offset` | 位置偏移量,格式为:[x, y] | `[Number, Number]`| `[0, 0]` | - | - |
|
|
169
|
+
| `showTitleBar`| 是否显示标题栏 | `Boolean` | `false` | - | - |
|
|
170
|
+
| `showFooter` | 是否显示底部按钮栏(仅多步骤时生效) | `Boolean` | `true` | - | - |
|
|
171
|
+
| `mask` | 是否显示遮罩层 | `Boolean` | `true` | - | - |
|
|
172
|
+
| `maskColse` | 是否点击遮罩层关闭 | `Boolean` | `true` | - | - |
|
|
173
|
+
| `showPrevStep`| 是否显示上一步按钮 | `Boolean` | `true` | - | - |
|
|
174
|
+
| `background` | 遮罩层背景色 | `String` | `rgba(0,0,0,.5)`| - | - |
|
|
175
|
+
| `radius` | 提示框圆角,单位rpx | `Number`,`String` | `18` | - | - |
|
|
176
|
+
| `messageBg` | 提示框背景色 | `String` | `#FFF` | - | - |
|
|
177
|
+
| `messageColor`| 提示框文字颜色 | `String` | `#000` | - | - |
|
|
178
|
+
| `nextStepTxt` | 下一步按钮文字 | `String` | `下一步` | - | - |
|
|
179
|
+
| `prevStepTxt` | 上一步按钮文字 | `String` | `上一步` | - | - |
|
|
180
|
+
| `completeTxt` | 完成按钮文字 | `String` | `完成` | - | - |
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
#### Events
|
|
185
|
+
|
|
186
|
+
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
187
|
+
| --- | --- | --- | --- |
|
|
188
|
+
| `change`| 步骤切换时触发 | `current` | - |
|
|
189
|
+
| `close` | 关闭指引时触发 | - | - |
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
---$
|
|
194
|
+
{{xuyajun}}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="ste-tour-root"
|
|
4
|
+
@touchmove.stop="true"
|
|
5
|
+
:class="{ show: dataShow }"
|
|
6
|
+
:style="[cmpRootStyle]"
|
|
7
|
+
@click="clickRoot"
|
|
8
|
+
>
|
|
9
|
+
<view class="ste-tour-view" :style="[dataStyle]"></view>
|
|
10
|
+
<view class="ste-tour-message" :style="[messageStyle]">
|
|
11
|
+
<view class="message-arrows" :style="[arrowsStyle]" />
|
|
12
|
+
<view class="message-content">
|
|
13
|
+
<view class="message-head" v-if="showTitleBar" @click.stop="true">
|
|
14
|
+
<view class="head-title">{{ cmpStep.title }}</view>
|
|
15
|
+
<view class="head-close" @click="close">
|
|
16
|
+
<ste-icon code="" size="30" />
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
<view class="message-content-text">
|
|
20
|
+
<slot>
|
|
21
|
+
<view class="message-text" @click.stop="true">
|
|
22
|
+
{{ cmpStep.message }}
|
|
23
|
+
</view>
|
|
24
|
+
</slot>
|
|
25
|
+
</view>
|
|
26
|
+
<view class="message-step-footer" @click.stop="true" v-if="cmpShowFooter">
|
|
27
|
+
<view class="step-num">{{ dataCurrent + 1 }}/{{ steps.length }}</view>
|
|
28
|
+
<view class="step-btns">
|
|
29
|
+
<ste-button
|
|
30
|
+
:round="false"
|
|
31
|
+
background="#fff"
|
|
32
|
+
borderColor="#0090FF"
|
|
33
|
+
color="#0090FF"
|
|
34
|
+
style="margin-right: 12rpx"
|
|
35
|
+
mode="100"
|
|
36
|
+
@click="onUp"
|
|
37
|
+
v-if="cmpShowPrevStep"
|
|
38
|
+
:rootStyle="{ padding: '0 10px' }"
|
|
39
|
+
>
|
|
40
|
+
{{ prevStepTxt }}
|
|
41
|
+
</ste-button>
|
|
42
|
+
<ste-button :round="false" :rootStyle="{ padding: '0 10px' }" mode="100" @click="onNext">
|
|
43
|
+
{{ dataCurrent < steps.length - 1 ? nextStepTxt : completeTxt }}
|
|
44
|
+
</ste-button>
|
|
45
|
+
</view>
|
|
46
|
+
</view>
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
</view>
|
|
50
|
+
</template>
|
|
51
|
+
|
|
52
|
+
<script>
|
|
53
|
+
import utils from '../../utils/utils.js';
|
|
54
|
+
/**
|
|
55
|
+
* ste-tour 指引
|
|
56
|
+
* @description 指引组件
|
|
57
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-tour
|
|
58
|
+
* @property {Boolean} show 是否显示
|
|
59
|
+
* @property {Number} current 当前步骤,多个步骤时有效
|
|
60
|
+
* @property {Array} steps 步骤数组,格式为:[{title: '', message: '', target:'el-id'}]
|
|
61
|
+
* @property {Array} offset 位置偏移量,格式为:[x, y]
|
|
62
|
+
* @property {Boolean} showTitleBar 是否显示标题栏
|
|
63
|
+
* @property {Boolean} showFooter 是否显示底部按钮栏(仅多步骤时生效)
|
|
64
|
+
* @property {Boolean} mask 是否显示遮罩层
|
|
65
|
+
* @property {Boolean} maskColse 是否点击遮罩层关闭
|
|
66
|
+
* @property {Boolean} showPrevStep 是否显示上一步按钮
|
|
67
|
+
* @property {String} background 遮罩层背景色
|
|
68
|
+
* @property {Number|String} radius 提示框圆角,单位rpx,默认18
|
|
69
|
+
* @property {String} messageBg 提示框背景色
|
|
70
|
+
* @property {String} messageColor 提示框文字颜色
|
|
71
|
+
* @property {String} nextStepTxt 下一步按钮文字
|
|
72
|
+
* @property {String} prevStepTxt 上一步按钮文字
|
|
73
|
+
* @property {String} completeTxt 完成按钮文字
|
|
74
|
+
* @event {Function} change 步骤切换时触发
|
|
75
|
+
*/
|
|
76
|
+
export default {
|
|
77
|
+
group: '展示组件',
|
|
78
|
+
title: 'Tour 指引',
|
|
79
|
+
name: 'ste-tour',
|
|
80
|
+
props: {
|
|
81
|
+
show: { type: [Boolean, null], default: () => false },
|
|
82
|
+
current: { type: [Number, null], default: () => 0 },
|
|
83
|
+
steps: { type: [Array, null], default: () => [] },
|
|
84
|
+
offset: { type: [Array, null], default: () => [0, 0] },
|
|
85
|
+
showTitleBar: { type: [Boolean, null], default: () => false },
|
|
86
|
+
showFooter: { type: [Boolean, null], default: () => true },
|
|
87
|
+
mask: { type: [Boolean, null], default: () => true },
|
|
88
|
+
maskColse: { type: [Boolean, null], default: () => true },
|
|
89
|
+
showPrevStep: { type: [Boolean, null], default: () => true },
|
|
90
|
+
background: { type: [String, null], default: () => 'rgba(0,0,0,.5)' },
|
|
91
|
+
radius: { type: [Number, String, null], default: () => 18 },
|
|
92
|
+
messageBg: { type: [String, null], default: () => '#fff' },
|
|
93
|
+
messageColor: { type: [String, null], default: () => '#000' },
|
|
94
|
+
nextStepTxt: { type: [String, null], default: () => '下一步' },
|
|
95
|
+
prevStepTxt: { type: [String, null], default: () => '上一步' },
|
|
96
|
+
completeTxt: { type: [String, null], default: () => '完成' },
|
|
97
|
+
},
|
|
98
|
+
data() {
|
|
99
|
+
return {
|
|
100
|
+
dataShow: false,
|
|
101
|
+
dataCurrent: 0,
|
|
102
|
+
stepTimeout: null,
|
|
103
|
+
dataStyle: {},
|
|
104
|
+
messageStyle: {},
|
|
105
|
+
arrowsStyle: {},
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
computed: {
|
|
109
|
+
cmpRootStyle() {
|
|
110
|
+
return {
|
|
111
|
+
'--ste-tour-radius': utils.formatPx(this.radius),
|
|
112
|
+
'--ste-tour-mask': this.mask ? `0 0 0 250vh ${this.background}` : 'none',
|
|
113
|
+
'--ste-tour-message-shadow': this.mask ? 'none' : `0 0 ${utils.formatPx(30)} 0 #ccc`,
|
|
114
|
+
'--ste-tour-message-bg': this.messageBg,
|
|
115
|
+
'--ste-tour-message-color': this.messageColor,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
cmpStep() {
|
|
119
|
+
return this.steps[this.dataCurrent];
|
|
120
|
+
},
|
|
121
|
+
windowSize() {
|
|
122
|
+
return {
|
|
123
|
+
vw: utils.System.getWindowWidth(),
|
|
124
|
+
vh: utils.System.getWindowHeight(),
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
cmpShowPrevStep() {
|
|
128
|
+
return this.showPrevStep && this.dataCurrent > 0;
|
|
129
|
+
},
|
|
130
|
+
cmpShowFooter() {
|
|
131
|
+
return this.showFooter && this.steps.length > 1;
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
watch: {
|
|
135
|
+
show: {
|
|
136
|
+
handler(val) {
|
|
137
|
+
this.dataShow = val;
|
|
138
|
+
if (val) this.dataCurrent = 0;
|
|
139
|
+
},
|
|
140
|
+
immediate: true,
|
|
141
|
+
},
|
|
142
|
+
current: {
|
|
143
|
+
handler(val) {
|
|
144
|
+
if (val >= 0 && val <= this.steps.length - 1) this.dataCurrent = val;
|
|
145
|
+
},
|
|
146
|
+
immediate: true,
|
|
147
|
+
},
|
|
148
|
+
dataShow: {
|
|
149
|
+
handler(val) {
|
|
150
|
+
if (val) this.showTour();
|
|
151
|
+
else this.closeTour();
|
|
152
|
+
},
|
|
153
|
+
immediate: true,
|
|
154
|
+
},
|
|
155
|
+
dataCurrent: {
|
|
156
|
+
handler(val) {
|
|
157
|
+
if (this.dataShow) this.showTour();
|
|
158
|
+
else this.closeTour();
|
|
159
|
+
},
|
|
160
|
+
immediate: true,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
methods: {
|
|
164
|
+
clickRoot() {
|
|
165
|
+
if (!this.maskColse) return;
|
|
166
|
+
this.close();
|
|
167
|
+
},
|
|
168
|
+
close() {
|
|
169
|
+
this.dataShow = false;
|
|
170
|
+
this.$emit('update:show', false);
|
|
171
|
+
this.$emit('close');
|
|
172
|
+
},
|
|
173
|
+
showTour() {
|
|
174
|
+
clearTimeout(this.stepTimeout);
|
|
175
|
+
this.stepTimeout = setTimeout(() => {
|
|
176
|
+
const step = this.cmpStep;
|
|
177
|
+
if (!step) return;
|
|
178
|
+
utils.querySelector(`#${step.target}`, this.$parent).then((el) => {
|
|
179
|
+
if (!el) {
|
|
180
|
+
console.error(`未找到ID为${step.target}的元素`);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const { top, left, bottom, right, width, height } = el;
|
|
184
|
+
|
|
185
|
+
this.dataStyle = {
|
|
186
|
+
top: `${el.top}px`,
|
|
187
|
+
left: `${el.left}px`,
|
|
188
|
+
width: `${el.width}px`,
|
|
189
|
+
height: `${el.height}px`,
|
|
190
|
+
display: 'block',
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
let [y, x] = step.position?.split('-') || [];
|
|
194
|
+
const { vw, vh } = this.windowSize;
|
|
195
|
+
const _bottom = vh - bottom;
|
|
196
|
+
const _right = vw - right;
|
|
197
|
+
if (!y) {
|
|
198
|
+
if (top > _bottom) {
|
|
199
|
+
y = 'top';
|
|
200
|
+
} else {
|
|
201
|
+
y = 'bottom';
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (!x) {
|
|
205
|
+
if (_right > 30 && _right > left) {
|
|
206
|
+
x = 'start';
|
|
207
|
+
} else if (left > 30) {
|
|
208
|
+
x = 'end';
|
|
209
|
+
} else {
|
|
210
|
+
x = 'center';
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
const [_x = 0, _y = 0] = this.offset;
|
|
214
|
+
const arrowsWidth = 18;
|
|
215
|
+
const messageStyle = { display: 'block' };
|
|
216
|
+
const arrowsStyle = {};
|
|
217
|
+
|
|
218
|
+
switch (y) {
|
|
219
|
+
case 'top':
|
|
220
|
+
messageStyle.bottom = `${_bottom + height + _y + (arrowsWidth - 5)}px`;
|
|
221
|
+
arrowsStyle.bottom = `-${arrowsWidth}px`;
|
|
222
|
+
arrowsStyle.borderColor = `${this.messageBg} transparent transparent`;
|
|
223
|
+
|
|
224
|
+
break;
|
|
225
|
+
case 'bottom':
|
|
226
|
+
messageStyle.top = `${bottom + _y + (arrowsWidth - 5)}px`;
|
|
227
|
+
arrowsStyle.top = `-${arrowsWidth}px`;
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
switch (x) {
|
|
231
|
+
case 'start':
|
|
232
|
+
messageStyle.left = `${left + _x}px`;
|
|
233
|
+
arrowsStyle.left = `${arrowsWidth}px`;
|
|
234
|
+
break;
|
|
235
|
+
case 'end':
|
|
236
|
+
messageStyle.right = `${_right + _x}px`;
|
|
237
|
+
arrowsStyle.right = `${arrowsWidth}px`;
|
|
238
|
+
break;
|
|
239
|
+
case 'center':
|
|
240
|
+
messageStyle.left = '50%';
|
|
241
|
+
messageStyle.transform = `translateX(calc(-50% + ${_x}px))`;
|
|
242
|
+
arrowsStyle.left = '50%';
|
|
243
|
+
arrowsStyle.transform = 'translateX(-50%)';
|
|
244
|
+
}
|
|
245
|
+
this.messageStyle = messageStyle;
|
|
246
|
+
this.arrowsStyle = arrowsStyle;
|
|
247
|
+
});
|
|
248
|
+
}, 50);
|
|
249
|
+
},
|
|
250
|
+
closeTour() {
|
|
251
|
+
this.dataStyle = {};
|
|
252
|
+
this.messageStyle = {};
|
|
253
|
+
this.arrowsStyle = {};
|
|
254
|
+
},
|
|
255
|
+
onNext() {
|
|
256
|
+
if (this.dataCurrent < this.steps.length - 1) {
|
|
257
|
+
this.dataCurrent += 1;
|
|
258
|
+
this.$emit('update:current', this.dataCurrent);
|
|
259
|
+
this.$emit('change', this.dataCurrent);
|
|
260
|
+
} else {
|
|
261
|
+
this.close();
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
onUp() {
|
|
265
|
+
if (this.dataCurrent > 0) {
|
|
266
|
+
this.dataCurrent -= 1;
|
|
267
|
+
this.$emit('update:current', this.dataCurrent);
|
|
268
|
+
this.$emit('change', this.dataCurrent);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
</script>
|
|
274
|
+
|
|
275
|
+
<style scoped lang="scss">
|
|
276
|
+
.ste-tour-root {
|
|
277
|
+
position: fixed;
|
|
278
|
+
z-index: 1001;
|
|
279
|
+
width: 100vw;
|
|
280
|
+
height: 100vh;
|
|
281
|
+
top: 0;
|
|
282
|
+
left: 0;
|
|
283
|
+
overflow: hidden;
|
|
284
|
+
display: none;
|
|
285
|
+
&.show {
|
|
286
|
+
display: block;
|
|
287
|
+
}
|
|
288
|
+
.ste-tour-view {
|
|
289
|
+
border-radius: var(--ste-tour-radius);
|
|
290
|
+
position: fixed;
|
|
291
|
+
z-index: 1001;
|
|
292
|
+
box-shadow: var(--ste-tour-mask);
|
|
293
|
+
display: none;
|
|
294
|
+
}
|
|
295
|
+
.ste-tour-message {
|
|
296
|
+
background-color: var(--ste-tour-message-bg);
|
|
297
|
+
position: fixed;
|
|
298
|
+
z-index: 1002;
|
|
299
|
+
border-radius: var(--ste-tour-radius);
|
|
300
|
+
display: none;
|
|
301
|
+
box-shadow: var(--ste-tour-message-shadow);
|
|
302
|
+
.message-arrows {
|
|
303
|
+
position: absolute;
|
|
304
|
+
width: 0;
|
|
305
|
+
height: 0;
|
|
306
|
+
border-width: 20rpx;
|
|
307
|
+
border-style: solid;
|
|
308
|
+
border-color: transparent transparent var(--ste-tour-message-bg);
|
|
309
|
+
}
|
|
310
|
+
.message-content {
|
|
311
|
+
color: var(--ste-tour-message-color);
|
|
312
|
+
font-size: 24rpx;
|
|
313
|
+
|
|
314
|
+
.message-head {
|
|
315
|
+
display: flex;
|
|
316
|
+
justify-content: space-between;
|
|
317
|
+
align-items: center;
|
|
318
|
+
min-width: 360rpx;
|
|
319
|
+
padding: 20rpx 24rpx;
|
|
320
|
+
.head-title {
|
|
321
|
+
height: 60rpx;
|
|
322
|
+
line-height: 60rpx;
|
|
323
|
+
font-size: 30rpx;
|
|
324
|
+
margin-right: 30rpx;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.head-close {
|
|
328
|
+
width: 60rpx;
|
|
329
|
+
height: 60rpx;
|
|
330
|
+
padding: 15rpx;
|
|
331
|
+
line-height: 30rpx;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
.message-content-text {
|
|
335
|
+
.message-text {
|
|
336
|
+
padding: 20rpx 24rpx;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.message-step-footer {
|
|
341
|
+
display: flex;
|
|
342
|
+
justify-content: space-between;
|
|
343
|
+
align-items: center;
|
|
344
|
+
padding: 20rpx 24rpx;
|
|
345
|
+
min-width: 360rpx;
|
|
346
|
+
.step-num {
|
|
347
|
+
font-size: 24rpx;
|
|
348
|
+
color: var(--ste-tour-message-color);
|
|
349
|
+
margin-right: 30rpx;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
</style>
|