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,243 @@
|
|
|
1
|
+
# MediaPreview 媒体预览
|
|
2
|
+
|
|
3
|
+
用于单独预览图片或者视频
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
### 代码演示
|
|
8
|
+
#### 基础用法
|
|
9
|
+
- `show`属性控制是否展示预览弹窗,支持`sync`双向绑定
|
|
10
|
+
- `urls`属性为要预览的媒体URL数组
|
|
11
|
+
```html
|
|
12
|
+
<template>
|
|
13
|
+
<ste-button @click="show = true">基础预览</ste-button>
|
|
14
|
+
<view style="width: 100%">
|
|
15
|
+
<ste-media-preview :urls="medias" :show.sync="show" />
|
|
16
|
+
</view>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
export default{
|
|
21
|
+
data(){
|
|
22
|
+
return{
|
|
23
|
+
medias: [
|
|
24
|
+
'https://image.whzb.com/chain/StellarUI/图片.jpg',
|
|
25
|
+
'https://image.whzb.com/chain/StellarUI/竖屏1.mp4',
|
|
26
|
+
'https://image.whzb.com/chain/StellarUI/验证码背景.png',
|
|
27
|
+
'https://image.whzb.com/chain/StellarUI/bg4.jpg',
|
|
28
|
+
'https://image.whzb.com/chain/StellarUI/横屏2.mp4',
|
|
29
|
+
'https://image.whzb.com/chain/StellarUI/bg3.jpg',
|
|
30
|
+
],
|
|
31
|
+
show: false,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### 自动轮播
|
|
39
|
+
- `autoplay`属性控制自动轮播间隔时间,单位为毫秒,为`0`时不轮播
|
|
40
|
+
```html
|
|
41
|
+
<template>
|
|
42
|
+
<ste-button @click="show1 = true">自动轮播</ste-button>
|
|
43
|
+
<view style="width: 100%">
|
|
44
|
+
<ste-media-preview :urls="medias" :show.sync="show1" :autoplay="3000" />
|
|
45
|
+
</view>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
export default{
|
|
50
|
+
data(){
|
|
51
|
+
return{
|
|
52
|
+
show1: false,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
#### 前后衔接循环播放
|
|
59
|
+
- `loop`属性可开启前后衔接循环播放
|
|
60
|
+
```html
|
|
61
|
+
<template>
|
|
62
|
+
<ste-button @click="show2 = true">前后衔接循环播放</ste-button>
|
|
63
|
+
<view style="width: 100%">
|
|
64
|
+
<ste-media-preview :urls="medias" :show.sync="show2" loop />
|
|
65
|
+
</view>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
export default{
|
|
70
|
+
data(){
|
|
71
|
+
return{
|
|
72
|
+
show2: false,
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
```
|
|
78
|
+
#### 默认展示下标为2的媒体资源
|
|
79
|
+
- `index`属性可控制从第几页开始展示
|
|
80
|
+
```html
|
|
81
|
+
<template>
|
|
82
|
+
<ste-button @click="show3 = true">默认展示下标为2的媒体资源</ste-button>
|
|
83
|
+
<view style="width: 100%">
|
|
84
|
+
<ste-media-preview :urls="medias" :show.sync="show3" :index="2" />
|
|
85
|
+
</view>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<script>
|
|
89
|
+
export default{
|
|
90
|
+
data(){
|
|
91
|
+
return{
|
|
92
|
+
show3: false,
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
#### 隐藏左下角索引标签
|
|
99
|
+
- `showIndex`属性可控制左下角页签显示
|
|
100
|
+
```html
|
|
101
|
+
<template>
|
|
102
|
+
<ste-button @click="show4 = true">隐藏左下角索引标签</ste-button>
|
|
103
|
+
<view style="width: 100%">
|
|
104
|
+
<ste-media-preview :urls="medias" :show.sync="show4" :showIndex="false" />
|
|
105
|
+
</view>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<script>
|
|
109
|
+
export default{
|
|
110
|
+
data(){
|
|
111
|
+
return{
|
|
112
|
+
show4: false,
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
</script>
|
|
117
|
+
```
|
|
118
|
+
#### 双指缩放
|
|
119
|
+
- `scale`属性可开启双指缩放功能
|
|
120
|
+
```html
|
|
121
|
+
<template>
|
|
122
|
+
<ste-button @click="show5 = true">双指缩放</ste-button>
|
|
123
|
+
<view style="width: 100%">
|
|
124
|
+
<ste-media-preview :urls="medias" :show.sync="show5" scale />
|
|
125
|
+
</view>
|
|
126
|
+
</template>
|
|
127
|
+
|
|
128
|
+
<script>
|
|
129
|
+
export default{
|
|
130
|
+
data(){
|
|
131
|
+
return{
|
|
132
|
+
show5: false,
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
</script>
|
|
137
|
+
```
|
|
138
|
+
#### 长按触发事件
|
|
139
|
+
- 事件`longpress`在用户长按时触发
|
|
140
|
+
```html
|
|
141
|
+
<template>
|
|
142
|
+
<ste-button @click="show6 = true">长按触发事件</ste-button>
|
|
143
|
+
<view style="width: 100%">
|
|
144
|
+
<ste-media-preview :urls="medias" :show.sync="show6" @longpress="onLongpress" />
|
|
145
|
+
</view>
|
|
146
|
+
</template>
|
|
147
|
+
|
|
148
|
+
<script>
|
|
149
|
+
export default{
|
|
150
|
+
data(){
|
|
151
|
+
return{
|
|
152
|
+
show6: false,
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
methods:{
|
|
156
|
+
onLongpress(index) {
|
|
157
|
+
this.showToast({
|
|
158
|
+
title: `长按了第【${index + 1}】个媒体资源`,
|
|
159
|
+
icon: 'none',
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
</script>
|
|
165
|
+
```
|
|
166
|
+
#### 关闭前/后事件
|
|
167
|
+
- 事件`beforeClose`在关闭前被触发
|
|
168
|
+
- 事件`close`在关闭后被触发
|
|
169
|
+
```html
|
|
170
|
+
<template>
|
|
171
|
+
<ste-button @click="show7 = true">关闭前/后事件</ste-button>
|
|
172
|
+
<view style="width: 100%">
|
|
173
|
+
<ste-media-preview :urls="medias" :show.sync="show7" @beforeClose="onBeforeClose" @close="onClose" />
|
|
174
|
+
</view>
|
|
175
|
+
</template>
|
|
176
|
+
|
|
177
|
+
<script>
|
|
178
|
+
export default{
|
|
179
|
+
data(){
|
|
180
|
+
return{
|
|
181
|
+
show7: false,
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
methods:{
|
|
185
|
+
onBeforeClose(stop, next, prevent) {
|
|
186
|
+
stop();
|
|
187
|
+
uni.showModal({
|
|
188
|
+
title: '确定关闭弹窗吗?',
|
|
189
|
+
success({ cancel, confirm }) {
|
|
190
|
+
if (confirm) {
|
|
191
|
+
console.log('点了确定');
|
|
192
|
+
next();
|
|
193
|
+
}
|
|
194
|
+
if (cancel) {
|
|
195
|
+
console.log('点了取消');
|
|
196
|
+
prevent();
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
fail() {
|
|
200
|
+
prevent();
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
onClose() {
|
|
205
|
+
this.showToast({
|
|
206
|
+
title: '弹窗关闭了',
|
|
207
|
+
icon: 'none',
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
</script>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
---$
|
|
218
|
+
### API
|
|
219
|
+
#### Props
|
|
220
|
+
|
|
221
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
222
|
+
| --- | --- | --- | --- | --- | --- |
|
|
223
|
+
| `show` | 是否显示 | `Boolean` | `false` | - | - |
|
|
224
|
+
| `urls` | 预览的媒体URL数组 | `Array<string>` | `[]` | - | - |
|
|
225
|
+
| `autoplay` | 自动轮播时长,为0不自动轮播,单位ms | `Number` | `0` | - | - |
|
|
226
|
+
| `loop` | 是否前后衔接播放 | `Boolean` | `false` | - | - |
|
|
227
|
+
| `index` | 默认展示的资源下标 | `Number` | `0` | - | - |
|
|
228
|
+
| `showIndex` | 是否显示左下角索引 | `Boolean` | `true` | - | - |
|
|
229
|
+
| `scale` | 是否支持双指缩放 | `Boolean` | `false` | - | - |
|
|
230
|
+
| `showmenu` | 是否开启图片长按菜单 | `Boolean` | `true` | - | 微信小程序`2.13.0` |
|
|
231
|
+
|
|
232
|
+
#### Event
|
|
233
|
+
|
|
234
|
+
|事件名 |说明 |事件参数 |支持版本 |
|
|
235
|
+
|--- |--- |--- |--- |
|
|
236
|
+
| `beforeClose` | 关闭前触发 | - | - |
|
|
237
|
+
| `close` | 关闭后触发 | - | - |
|
|
238
|
+
| `change` | 切换时触发 | `index`:切换后的下标 | - |
|
|
239
|
+
| `longpress` | 长按时触发 | `index`:当前下标 | - |
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
---$
|
|
243
|
+
{{xuyajun}}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export default class TouchScaleing {
|
|
2
|
+
identifiers = [];
|
|
3
|
+
|
|
4
|
+
startParam = {
|
|
5
|
+
id1: null,
|
|
6
|
+
x1: null,
|
|
7
|
+
y1: null,
|
|
8
|
+
id2: null,
|
|
9
|
+
x2: null,
|
|
10
|
+
y2: null,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
scale = 1;
|
|
14
|
+
|
|
15
|
+
rotate = 0;
|
|
16
|
+
|
|
17
|
+
translateX = 0;
|
|
18
|
+
translateY = 0;
|
|
19
|
+
|
|
20
|
+
_setData(changedTouches) {
|
|
21
|
+
changedTouches.forEach((newData) => {
|
|
22
|
+
const data = this.identifiers.find((item) => item.identifier === newData.identifier);
|
|
23
|
+
if (data) {
|
|
24
|
+
Object.assign(data, newData);
|
|
25
|
+
} else {
|
|
26
|
+
this.identifiers.push(newData);
|
|
27
|
+
if (this.identifiers.length > 2) {
|
|
28
|
+
this.identifiers.shift();
|
|
29
|
+
this.startParam.id1 = this.startParam.id2;
|
|
30
|
+
this.startParam.x1 = this.startParam.x2;
|
|
31
|
+
this.startParam.y1 = this.startParam.y2;
|
|
32
|
+
this.startParam.id2 = newData.identifier;
|
|
33
|
+
this.startParam.x2 = newData.pageX;
|
|
34
|
+
this.startParam.y2 = newData.pageY;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
_getTouchPosition() {
|
|
41
|
+
const [m1, m2] = this.identifiers;
|
|
42
|
+
const x1 = m1?.pageX || null;
|
|
43
|
+
const y1 = m1?.pageY || null;
|
|
44
|
+
const x2 = m2?.pageX || null;
|
|
45
|
+
const y2 = m2?.pageY || null;
|
|
46
|
+
const id1 = m1?.identifier || null;
|
|
47
|
+
const id2 = m2?.identifier || null;
|
|
48
|
+
return [x1, y1, x2, y2, id1, id2];
|
|
49
|
+
}
|
|
50
|
+
touchStart(changedTouches) {
|
|
51
|
+
this._setData(changedTouches);
|
|
52
|
+
|
|
53
|
+
const [x1, y1, x2, y2, id1, id2] = this._getTouchPosition();
|
|
54
|
+
if (x1 !== null && y1 !== null) {
|
|
55
|
+
this.startParam.x1 = x1;
|
|
56
|
+
this.startParam.y1 = y1;
|
|
57
|
+
this.startParam.id1 = id1;
|
|
58
|
+
}
|
|
59
|
+
if (x2 !== null && y2 !== null) {
|
|
60
|
+
this.startParam.x2 = x2;
|
|
61
|
+
this.startParam.y2 = y2;
|
|
62
|
+
this.startParam.id2 = id2;
|
|
63
|
+
}
|
|
64
|
+
return [x1, y1, x2, y2];
|
|
65
|
+
}
|
|
66
|
+
touchMove(changedTouches) {
|
|
67
|
+
if (changedTouches.length < 2) return false;
|
|
68
|
+
this._setData(changedTouches);
|
|
69
|
+
|
|
70
|
+
const param = this.startParam;
|
|
71
|
+
const [startX1, startY1, startX2, startY2] = [param.x1, param.y1, param.x2, param.y2];
|
|
72
|
+
const [x1, y1, x2, y2] = this._getTouchPosition();
|
|
73
|
+
|
|
74
|
+
this.scale =
|
|
75
|
+
Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)) /
|
|
76
|
+
Math.sqrt(Math.pow(startX2 - startX1, 2) + Math.pow(startY2 - startY1, 2));
|
|
77
|
+
this.rotate =
|
|
78
|
+
(Math.atan2(y2 - y1, x2 - x1) * 180) / Math.PI -
|
|
79
|
+
(Math.atan2(startY2 - startY1, startX2 - startX1) * 180) / Math.PI;
|
|
80
|
+
this.translateX = (x1 + x2) / 2 - (startX1 + startX2) / 2;
|
|
81
|
+
this.translateY = (y1 + y2) / 2 - (startY1 + startY2) / 2;
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
touchEnd(changedTouches) {
|
|
85
|
+
changedTouches.forEach((item) => {
|
|
86
|
+
const index = this.identifiers.findIndex((m) => m.identifier === item.identifier);
|
|
87
|
+
if (index !== -1) {
|
|
88
|
+
this.identifiers.splice(index, 1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const [x1, y1, x2, y2] = this._getTouchPosition();
|
|
92
|
+
if (x1 !== null && y1 !== null) {
|
|
93
|
+
this.startParam.x1 = null;
|
|
94
|
+
this.startParam.y1 = null;
|
|
95
|
+
}
|
|
96
|
+
if (x2 !== null && y2 !== null) {
|
|
97
|
+
this.startParam.x2 = null;
|
|
98
|
+
this.startParam.y2 = null;
|
|
99
|
+
}
|
|
100
|
+
return !this.identifiers.length;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-media-preview-root" v-if="dataShow">
|
|
3
|
+
<view class="media-preview-content">
|
|
4
|
+
<swiper
|
|
5
|
+
style="width: 100%; height: 100%"
|
|
6
|
+
:autoplay="autoplay > 0"
|
|
7
|
+
:interval="autoplay"
|
|
8
|
+
:circular="loop"
|
|
9
|
+
:current="dataIndex"
|
|
10
|
+
@change="onChange"
|
|
11
|
+
>
|
|
12
|
+
<swiper-item v-for="(item, index) in cmpUrls" :key="index">
|
|
13
|
+
<view
|
|
14
|
+
class="preview-item"
|
|
15
|
+
@click.stop="1"
|
|
16
|
+
@touchstart="onTouchstart"
|
|
17
|
+
@touchmove="onTouchmove"
|
|
18
|
+
@touchend="onTouchend"
|
|
19
|
+
@longpress="onLongpress"
|
|
20
|
+
:style="[dataIndex === index ? cmpTransform : null]"
|
|
21
|
+
>
|
|
22
|
+
<video
|
|
23
|
+
class="video"
|
|
24
|
+
object-fit="contain"
|
|
25
|
+
v-if="item.type === 'video'"
|
|
26
|
+
:src="item.url || item.path"
|
|
27
|
+
@click.stop="1"
|
|
28
|
+
/>
|
|
29
|
+
<ste-image
|
|
30
|
+
v-else
|
|
31
|
+
class="image"
|
|
32
|
+
:showMenuByLongpress="dataShowmenu"
|
|
33
|
+
:src="item.url || item.path"
|
|
34
|
+
mode="aspectFit"
|
|
35
|
+
></ste-image>
|
|
36
|
+
</view>
|
|
37
|
+
</swiper-item>
|
|
38
|
+
</swiper>
|
|
39
|
+
</view>
|
|
40
|
+
<view class="media-preview-footer">
|
|
41
|
+
<view class="footer-index">
|
|
42
|
+
<text v-if="showIndex">{{ dataIndex + 1 }}/{{ cmpUrls.length }}</text>
|
|
43
|
+
</view>
|
|
44
|
+
<view class="footer-close" @click="onClose">
|
|
45
|
+
<ste-icon name="close" size="60" code="" color="#fff" />
|
|
46
|
+
</view>
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script>
|
|
52
|
+
import utils from '../../utils/utils.js';
|
|
53
|
+
import TouchScaleing from './TouchScaleing.js';
|
|
54
|
+
/**
|
|
55
|
+
* ste-media-preview 媒体预览
|
|
56
|
+
* @description 媒体预览组件
|
|
57
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-media-preview
|
|
58
|
+
* @property {Boolean} show 是否显示
|
|
59
|
+
* @property {Array<String>} urls 预览的媒体地址数组
|
|
60
|
+
* @property {Number} autoplay 自动轮播时长,为0不自动轮播,单位ms
|
|
61
|
+
* @property {Boolean} loop 是否前后衔接播放
|
|
62
|
+
* @property {Number} index 默认展示的资源下标
|
|
63
|
+
* @property {Boolean} showIndex 是否显示左下角索引
|
|
64
|
+
* @property {Boolean} scale 是否支持双指缩放
|
|
65
|
+
* @property {Boolean} showmenu 是否开启图片长按菜单
|
|
66
|
+
* @event {Function} beforeClose 关闭前触发
|
|
67
|
+
* @event {Function} close 关闭后触发
|
|
68
|
+
* @event {Function} change 切换时触发
|
|
69
|
+
* @event {Function} longpress 长按触发
|
|
70
|
+
*/
|
|
71
|
+
export default {
|
|
72
|
+
group: '展示组件',
|
|
73
|
+
title: 'MediaPreview 媒体预览',
|
|
74
|
+
name: 'ste-media-preview',
|
|
75
|
+
props: {
|
|
76
|
+
show: {
|
|
77
|
+
type: [Boolean, null],
|
|
78
|
+
default: () => false,
|
|
79
|
+
},
|
|
80
|
+
urls: {
|
|
81
|
+
type: [Array, null],
|
|
82
|
+
default: () => [],
|
|
83
|
+
},
|
|
84
|
+
autoplay: {
|
|
85
|
+
type: [Number, null],
|
|
86
|
+
default: () => 0,
|
|
87
|
+
},
|
|
88
|
+
loop: {
|
|
89
|
+
type: [Boolean, null],
|
|
90
|
+
default: () => false,
|
|
91
|
+
},
|
|
92
|
+
index: {
|
|
93
|
+
type: [Number, null],
|
|
94
|
+
default: () => null,
|
|
95
|
+
},
|
|
96
|
+
showIndex: {
|
|
97
|
+
type: [Boolean, null],
|
|
98
|
+
default: () => true,
|
|
99
|
+
},
|
|
100
|
+
scale: {
|
|
101
|
+
type: [Boolean, null],
|
|
102
|
+
default: () => false,
|
|
103
|
+
},
|
|
104
|
+
showmenu: {
|
|
105
|
+
type: [Boolean, null],
|
|
106
|
+
default: () => true,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
data() {
|
|
110
|
+
return {
|
|
111
|
+
dataIndex: 0,
|
|
112
|
+
dataShow: false,
|
|
113
|
+
touch: null,
|
|
114
|
+
scaling: 1,
|
|
115
|
+
translate: 0,
|
|
116
|
+
rotate: 0,
|
|
117
|
+
transition: 0,
|
|
118
|
+
dataShowmenu: true,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
mounted() {
|
|
122
|
+
if (this.scale) this.touch = new TouchScaleing();
|
|
123
|
+
},
|
|
124
|
+
computed: {
|
|
125
|
+
cmpUrls() {
|
|
126
|
+
return this.urls
|
|
127
|
+
.map((url) => ({ url, type: utils.getMediaFileType(url) }))
|
|
128
|
+
.filter((item) => item.type !== 'audio');
|
|
129
|
+
},
|
|
130
|
+
cmpTransform() {
|
|
131
|
+
return {
|
|
132
|
+
transform: `scale(${this.scaling}) translate(${this.translate}) rotate(${this.rotate}deg)`,
|
|
133
|
+
transition: this.transition,
|
|
134
|
+
};
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
watch: {
|
|
138
|
+
show: {
|
|
139
|
+
handler(v) {
|
|
140
|
+
if (v) {
|
|
141
|
+
// 如果外部指定index,则使用外部index,不然使用内部dataIndex
|
|
142
|
+
if (this.index != null) {
|
|
143
|
+
this.dataIndex = this.index;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
this.dataShow = v;
|
|
147
|
+
},
|
|
148
|
+
immediate: true,
|
|
149
|
+
},
|
|
150
|
+
showmenu: {
|
|
151
|
+
handler(v) {
|
|
152
|
+
this.dataShowmenu = v;
|
|
153
|
+
},
|
|
154
|
+
immediate: true,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
methods: {
|
|
158
|
+
async onClose() {
|
|
159
|
+
let next = true;
|
|
160
|
+
const stop = new Promise((resolve, reject) => {
|
|
161
|
+
this.$emit(
|
|
162
|
+
'beforeClose',
|
|
163
|
+
() => (next = false),
|
|
164
|
+
() => resolve(),
|
|
165
|
+
() => reject()
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
if (!next) {
|
|
169
|
+
await stop;
|
|
170
|
+
}
|
|
171
|
+
this.dataShow = false;
|
|
172
|
+
this.$emit('update:show', false);
|
|
173
|
+
this.$emit('close');
|
|
174
|
+
},
|
|
175
|
+
async onTouchstart(e) {
|
|
176
|
+
if (!this.scale) return;
|
|
177
|
+
|
|
178
|
+
const [x1, y1, x2, y2] = this.touch.touchStart(e.changedTouches);
|
|
179
|
+
if (x1 && y1 && x2 && y2) {
|
|
180
|
+
if (this.dataShowmenu) this.dataShowmenu = false;
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
onTouchmove(e) {
|
|
184
|
+
if (!this.scale) return;
|
|
185
|
+
/**
|
|
186
|
+
* @type {TouchScaleing}
|
|
187
|
+
*/
|
|
188
|
+
const touch = this.touch;
|
|
189
|
+
const bool = touch.touchMove(e.changedTouches);
|
|
190
|
+
if (!bool) return;
|
|
191
|
+
if (this.dataShowmenu) this.dataShowmenu = false;
|
|
192
|
+
this.scaling = touch.scale;
|
|
193
|
+
this.translate = `${touch.translateX}px,${touch.translateY}px`;
|
|
194
|
+
this.rotate = touch.rotate;
|
|
195
|
+
},
|
|
196
|
+
onTouchend(e) {
|
|
197
|
+
if (!this.scale) return;
|
|
198
|
+
if (this.dataShowmenu !== this.showmenu) this.dataShowmenu = this.showmenu;
|
|
199
|
+
const bool = this.touch.touchEnd(e.changedTouches);
|
|
200
|
+
if (!bool) return;
|
|
201
|
+
this.transition = '0.3s';
|
|
202
|
+
setTimeout(() => {
|
|
203
|
+
this.scaling = 1;
|
|
204
|
+
this.translate = 0;
|
|
205
|
+
this.rotate = 0;
|
|
206
|
+
setTimeout(() => {
|
|
207
|
+
this.transition = 0;
|
|
208
|
+
}, 100);
|
|
209
|
+
}, 50);
|
|
210
|
+
},
|
|
211
|
+
onChange({ detail }) {
|
|
212
|
+
this.dataIndex = detail.current;
|
|
213
|
+
this.$emit('update:index', this.dataIndex);
|
|
214
|
+
this.$emit('change', this.dataIndex);
|
|
215
|
+
},
|
|
216
|
+
onLongpress() {
|
|
217
|
+
this.$emit('longpress', this.dataIndex);
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<style lang="scss" scoped>
|
|
224
|
+
.ste-media-preview-root {
|
|
225
|
+
position: fixed;
|
|
226
|
+
top: 0;
|
|
227
|
+
left: 0;
|
|
228
|
+
bottom: 0;
|
|
229
|
+
right: 0;
|
|
230
|
+
width: 100vw;
|
|
231
|
+
height: 100vh;
|
|
232
|
+
background-color: #000;
|
|
233
|
+
color: #fff;
|
|
234
|
+
z-index: 9999999;
|
|
235
|
+
.media-preview-content {
|
|
236
|
+
width: 100%;
|
|
237
|
+
height: calc(100% - 120rpx);
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: center;
|
|
240
|
+
justify-content: center;
|
|
241
|
+
.preview-item {
|
|
242
|
+
width: 100%;
|
|
243
|
+
height: 100%;
|
|
244
|
+
display: flex;
|
|
245
|
+
align-items: center;
|
|
246
|
+
justify-content: center;
|
|
247
|
+
.image,
|
|
248
|
+
.video {
|
|
249
|
+
width: 100%;
|
|
250
|
+
height: 100%;
|
|
251
|
+
}
|
|
252
|
+
.image {
|
|
253
|
+
max-width: 100%;
|
|
254
|
+
max-height: 100%;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
.media-preview-footer {
|
|
259
|
+
width: 100%;
|
|
260
|
+
height: 120rpx;
|
|
261
|
+
padding: 0 30rpx 30rpx 30rpx;
|
|
262
|
+
display: flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
justify-content: space-between;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
</style>
|