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,526 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-upload-root" :style="[cmpRootStyle]">
|
|
3
|
+
<view class="upload-list">
|
|
4
|
+
<block v-if="previewImage">
|
|
5
|
+
<view class="image-item" v-for="(item, index) in dataValue" :key="index" @click="toSelectFile">
|
|
6
|
+
<image
|
|
7
|
+
class="image"
|
|
8
|
+
:src="item.thumbPath || item.url || item.path"
|
|
9
|
+
mode="aspectFit"
|
|
10
|
+
@click="previewItem(index, item)"
|
|
11
|
+
/>
|
|
12
|
+
<view class="uploading" v-if="item.status === 'uploading'">
|
|
13
|
+
<view class="icon"><ste-icon code="" size="48" color="#fff" /></view>
|
|
14
|
+
<view class="text">上传中</view>
|
|
15
|
+
</view>
|
|
16
|
+
<view class="error" v-if="item.status === 'error'">
|
|
17
|
+
<view class="icon"><ste-icon code="" size="48" color="#fff" /></view>
|
|
18
|
+
<view class="text">上传失败</view>
|
|
19
|
+
</view>
|
|
20
|
+
<view
|
|
21
|
+
class="delete"
|
|
22
|
+
v-if="cmpDeletable && item.status !== 'uploading'"
|
|
23
|
+
@click.stop="deleteItem(index)"
|
|
24
|
+
>
|
|
25
|
+
<view class="icon">
|
|
26
|
+
<ste-icon code="" size="20" color="#fff" />
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
29
|
+
<block v-if="!item.status || item.status === 'success'">
|
|
30
|
+
<slot name="preview-cover" :item="item"></slot>
|
|
31
|
+
</block>
|
|
32
|
+
</view>
|
|
33
|
+
</block>
|
|
34
|
+
<view class="add-file" v-if="cmpShowUpload" @click="selectFile">
|
|
35
|
+
<slot>
|
|
36
|
+
<view class="image-item add-file">
|
|
37
|
+
<view class="upload-btn">
|
|
38
|
+
<ste-icon :code="uploadIcon" :size="60" color="#ddd"></ste-icon>
|
|
39
|
+
<view class="upload-text">{{ uploadText }}</view>
|
|
40
|
+
</view>
|
|
41
|
+
<!-- #ifdef MP-ALIPAY -->
|
|
42
|
+
<view class="delete" v-if="accept === 'media'" @click.stop="setMediaType">
|
|
43
|
+
<view class="icon">
|
|
44
|
+
<view :class="{ video: mediaType === 'video' }">
|
|
45
|
+
<ste-icon
|
|
46
|
+
:code="mediaType === 'video' ? '' : ''"
|
|
47
|
+
size="20"
|
|
48
|
+
color="#fff"
|
|
49
|
+
/>
|
|
50
|
+
</view>
|
|
51
|
+
</view>
|
|
52
|
+
</view>
|
|
53
|
+
<!-- #endif -->
|
|
54
|
+
</view>
|
|
55
|
+
</slot>
|
|
56
|
+
</view>
|
|
57
|
+
</view>
|
|
58
|
+
<ste-media-preview
|
|
59
|
+
:show="previewIndex || previewIndex === 0"
|
|
60
|
+
:urls="cmpPreviewList"
|
|
61
|
+
:index.sync="previewIndex"
|
|
62
|
+
@close="previewIndex = null"
|
|
63
|
+
/>
|
|
64
|
+
</view>
|
|
65
|
+
</template>
|
|
66
|
+
|
|
67
|
+
<script>
|
|
68
|
+
import utils from '../../utils/utils.js';
|
|
69
|
+
import { readMediaFile, readFile } from './ReadFile.js';
|
|
70
|
+
/**
|
|
71
|
+
* ste-upload 文件上传
|
|
72
|
+
* @description 文件上传组件
|
|
73
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-upload
|
|
74
|
+
* @property {Array} value 已经上传的文件列表 {url:string;type:string;name?:string;status?:"uploading"|"error"|"success";path?:string;thumbPath?:string}[]
|
|
75
|
+
* @property {String} accept 文件类型, 可选值为all media image file video
|
|
76
|
+
* @value image 图片类型(默认)
|
|
77
|
+
* @value video 视频类型
|
|
78
|
+
* @value media 媒体类型(可选择图片和视频)
|
|
79
|
+
* @value file 从聊天记录中选取图片视频之外的文件类型(仅微信小程序生效)
|
|
80
|
+
* @value all 从聊天记录中选取全部类型文件(仅微信小程序和H5生效)
|
|
81
|
+
* @property {Array} capture 图片或者视频选取模式,当accept为image | media 类型时生效 类型:("album" | "camera")[]
|
|
82
|
+
* @property {String} camera 相机类型 当 accept 为 image | video | media 时生效,可选值为 back-后置 front-前置
|
|
83
|
+
* @value back 后置(默认)
|
|
84
|
+
* @value front 前置
|
|
85
|
+
* @property {Boolean} compressed 当 accept 为 image | video | media 时生效,是否压缩视频、图片默认为true
|
|
86
|
+
* @property {Number} maxDuration 当 accept 为 video | media 时生效,拍摄视频最长拍摄时间,单位秒
|
|
87
|
+
* @property {Number | String} previewWidth 预览图和上传区域的宽度,单位为rpx
|
|
88
|
+
* @property {Number | String} previewHeight 预览图和上传区域的高度,单位为rpx
|
|
89
|
+
* @property {Boolean} previewImage 是否在上传完成后展示预览图
|
|
90
|
+
* @property {Boolean} previewFullImage 是否在点击预览图后展示全屏图片预览
|
|
91
|
+
* @property {Boolean} multiple 是否支持多选文件,部分安卓机型不支持
|
|
92
|
+
* @property {Boolean} disabled 是否禁用
|
|
93
|
+
* @property {Boolean} showUpload 是否展示文件上传按钮
|
|
94
|
+
* @property {Boolean} deletable 是否展示删除文件按钮
|
|
95
|
+
* @property {Number} maxSize 文件大小限制,单位为kb,0为不限制
|
|
96
|
+
* @property {Number} maxCount 最大上传文件数量,默认为9
|
|
97
|
+
* @property {String} uploadIcon 上传按钮图标,同icon组件code
|
|
98
|
+
* @property {String} uploadText 上传按钮文字
|
|
99
|
+
* @property {Number | String} radius 圆角弧度,单位rpx
|
|
100
|
+
* @property {String} flexWrap 超出内容是否换行,同css的flex-wrap
|
|
101
|
+
* @value wrap 换行(默认)
|
|
102
|
+
* @value nowrap 不换行
|
|
103
|
+
* @event {Function} beforeRead 文件读取前的触发
|
|
104
|
+
* @event {Function} read 文件读取后的回调函数
|
|
105
|
+
* @event {Function} oversize 文件大小超出限制的回调函数
|
|
106
|
+
* @event {Function} beforeDelete 文件删除前的回调函数
|
|
107
|
+
* @event {Function} delete 文件删除后的回调函数
|
|
108
|
+
* */
|
|
109
|
+
export default {
|
|
110
|
+
group: '表单组件',
|
|
111
|
+
title: 'Upload 上传',
|
|
112
|
+
name: 'ste-upload',
|
|
113
|
+
props: {
|
|
114
|
+
/**
|
|
115
|
+
* 已上传的文件列表
|
|
116
|
+
* @type {{url:string;name?:string;type?:string;status?:"uploading"|"error"|"success";path?:string}[]}
|
|
117
|
+
*/
|
|
118
|
+
value: {
|
|
119
|
+
type: [Array, null],
|
|
120
|
+
default: () => [],
|
|
121
|
+
},
|
|
122
|
+
// 接受的文件类型, 可选值为all media image file video
|
|
123
|
+
accept: {
|
|
124
|
+
type: [String, null],
|
|
125
|
+
default: () => 'image',
|
|
126
|
+
},
|
|
127
|
+
// 图片或者视频选取模式,当accept为image | media 类型时设置capture可选值为camera可以直接调起摄像头
|
|
128
|
+
capture: {
|
|
129
|
+
type: [Array, null],
|
|
130
|
+
default: () => ['album', 'camera'],
|
|
131
|
+
},
|
|
132
|
+
// 相机类型 当 accept 为 image | video | media 时生效,可选值为 back-后置 front-前置
|
|
133
|
+
camera: {
|
|
134
|
+
type: [String, null],
|
|
135
|
+
default: () => 'back',
|
|
136
|
+
},
|
|
137
|
+
// 当 accept 为 image | video | media 时生效,是否压缩视频、图片默认为true
|
|
138
|
+
compressed: {
|
|
139
|
+
type: [Boolean, null],
|
|
140
|
+
default: () => true,
|
|
141
|
+
},
|
|
142
|
+
// 当 accept 为 video | media 时生效,拍摄视频最长拍摄时间,单位秒
|
|
143
|
+
maxDuration: {
|
|
144
|
+
type: [Number, null],
|
|
145
|
+
default: () => 60,
|
|
146
|
+
},
|
|
147
|
+
// 预览图和上传区域的宽度,默认单位为rpx
|
|
148
|
+
previewWidth: {
|
|
149
|
+
type: [String, Number, null],
|
|
150
|
+
default: () => 200,
|
|
151
|
+
},
|
|
152
|
+
// 预览图和上传区域的高度,默认单位为rpx
|
|
153
|
+
previewHeight: {
|
|
154
|
+
type: [String, Number, null],
|
|
155
|
+
default: () => 200,
|
|
156
|
+
},
|
|
157
|
+
// 是否在上传完成后展示预览图
|
|
158
|
+
previewImage: {
|
|
159
|
+
type: [Boolean, null],
|
|
160
|
+
default: () => true,
|
|
161
|
+
},
|
|
162
|
+
// 是否在点击预览图后展示全屏图片预览
|
|
163
|
+
previewFullImage: {
|
|
164
|
+
type: [Boolean, null],
|
|
165
|
+
default: () => true,
|
|
166
|
+
},
|
|
167
|
+
// 是否开启图片多选,部分安卓机型不支持
|
|
168
|
+
multiple: {
|
|
169
|
+
type: [Boolean, null],
|
|
170
|
+
default: () => false,
|
|
171
|
+
},
|
|
172
|
+
// 是否禁用文件上传
|
|
173
|
+
disabled: {
|
|
174
|
+
type: [Boolean, null],
|
|
175
|
+
default: () => false,
|
|
176
|
+
},
|
|
177
|
+
// 是否展示文件上传按钮
|
|
178
|
+
showUpload: {
|
|
179
|
+
type: [Boolean, null],
|
|
180
|
+
default: () => true,
|
|
181
|
+
},
|
|
182
|
+
// 是否展示删除按钮
|
|
183
|
+
deletable: {
|
|
184
|
+
type: [Boolean, null],
|
|
185
|
+
default: () => true,
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
// 文件大小限制,单位为kb,0为不限制
|
|
189
|
+
maxSize: {
|
|
190
|
+
type: [Number, null],
|
|
191
|
+
default: () => 0,
|
|
192
|
+
},
|
|
193
|
+
// 文件上传数量限制,0为不限制
|
|
194
|
+
maxCount: {
|
|
195
|
+
type: [Number, null],
|
|
196
|
+
default: () => 9,
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
// 上传区域图标,可选值见 Icon 组件
|
|
200
|
+
uploadIcon: {
|
|
201
|
+
type: [String, null],
|
|
202
|
+
default: () => '',
|
|
203
|
+
},
|
|
204
|
+
// 上传区域文字提示
|
|
205
|
+
uploadText: {
|
|
206
|
+
type: [String, null],
|
|
207
|
+
default: () => '点击上传',
|
|
208
|
+
},
|
|
209
|
+
// 圆角弧度
|
|
210
|
+
radius: {
|
|
211
|
+
type: [String, Number, null],
|
|
212
|
+
default: () => 9,
|
|
213
|
+
},
|
|
214
|
+
// 子元素是否换行
|
|
215
|
+
flexWrap: {
|
|
216
|
+
type: [String, null],
|
|
217
|
+
default: () => 'wrap',
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
data() {
|
|
221
|
+
return {
|
|
222
|
+
dataValue: [],
|
|
223
|
+
previewIndex: null,
|
|
224
|
+
// #ifdef MP-ALIPAY
|
|
225
|
+
mediaType: 'image',
|
|
226
|
+
// #endif
|
|
227
|
+
menuButtonBounding: null,
|
|
228
|
+
reading: null,
|
|
229
|
+
deleting: null,
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
computed: {
|
|
233
|
+
cmpRootStyle() {
|
|
234
|
+
const style = {
|
|
235
|
+
'--ste-upload-width': utils.formatPx(this.previewWidth),
|
|
236
|
+
'--ste-upload-height': utils.formatPx(this.previewHeight),
|
|
237
|
+
'--ste-upload-radius': utils.formatPx(this.radius),
|
|
238
|
+
'--ste-upload-flex-wrap': utils.formatPx(this.flexWrap),
|
|
239
|
+
'--ste-upload-item-margin': this.maxCount.toString() === '1' ? 0 : utils.formatPx(18),
|
|
240
|
+
};
|
|
241
|
+
return style;
|
|
242
|
+
},
|
|
243
|
+
cmpShowUpload() {
|
|
244
|
+
let bool =
|
|
245
|
+
(!this.disabled || !this.dataValue.length) &&
|
|
246
|
+
this.showUpload &&
|
|
247
|
+
(this.maxCount == 0 || this.dataValue.length < this.maxCount);
|
|
248
|
+
return bool;
|
|
249
|
+
},
|
|
250
|
+
cmpDeletable() {
|
|
251
|
+
return !this.disabled && this.deletable;
|
|
252
|
+
},
|
|
253
|
+
cmpPreviewList() {
|
|
254
|
+
return this.dataValue
|
|
255
|
+
.filter((item) => ['video', 'image'].indexOf(item.type) !== -1)
|
|
256
|
+
.map((item) => item.thumbPath || item.url || item.path);
|
|
257
|
+
},
|
|
258
|
+
cmpPreviewFullImage() {
|
|
259
|
+
return this.previewFullImage && (this.maxCount !== 1 || this.deletable);
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
watch: {
|
|
263
|
+
value: {
|
|
264
|
+
handler(val) {
|
|
265
|
+
let list = [...val];
|
|
266
|
+
if (this.maxCount > 0 && val.length > this.maxCount) {
|
|
267
|
+
list = list.splice(this.maxCount);
|
|
268
|
+
}
|
|
269
|
+
this.dataValue = list.map((item) => {
|
|
270
|
+
if (!item?.type) {
|
|
271
|
+
const url = item.thumbPath || item.url || item.path;
|
|
272
|
+
item.type = utils.getMediaFileType(url);
|
|
273
|
+
}
|
|
274
|
+
return { ...item };
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
immediate: true,
|
|
278
|
+
},
|
|
279
|
+
previewIndex(v) {
|
|
280
|
+
if (v === null) {
|
|
281
|
+
this.$emit('close-preview');
|
|
282
|
+
} else {
|
|
283
|
+
this.$emit('open-preview');
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
methods: {
|
|
288
|
+
toSelectFile() {
|
|
289
|
+
if (this.maxCount !== 1 || this.cmpDeletable) return;
|
|
290
|
+
this.selectFile(() => {
|
|
291
|
+
this.deleteItem(0);
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
selectFile(callback) {
|
|
295
|
+
if (this.disabled) return;
|
|
296
|
+
let accept = this.accept, // 文件类型, 可选值为all media image file video
|
|
297
|
+
capture = this.capture, // 图片或者视频选取模式,当accept为image | media 类型时设置capture可选值为camera可以直接调起摄像头
|
|
298
|
+
camera = this.camera, // 相机类型 当 accept 为 image | video | media 时生效,可选值为 back-后置 front-前置
|
|
299
|
+
compressed = this.compressed, // 是否压缩
|
|
300
|
+
maxDuration = this.maxDuration, // 录制时长
|
|
301
|
+
multiple = this.multiple,
|
|
302
|
+
maxCount = this.maxCount;
|
|
303
|
+
let count = 1;
|
|
304
|
+
if (multiple) {
|
|
305
|
+
if (maxCount === 0) {
|
|
306
|
+
count = 9;
|
|
307
|
+
} else {
|
|
308
|
+
count = maxCount - this.dataValue.length > 9 ? 9 : maxCount - this.dataValue.length;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
if (count === 0) return;
|
|
312
|
+
// #ifdef MP-ALIPAY
|
|
313
|
+
if (accept === 'media') {
|
|
314
|
+
accept = this.mediaType;
|
|
315
|
+
}
|
|
316
|
+
// #endif
|
|
317
|
+
if (['image', 'video', 'media'].indexOf(accept) >= 0) {
|
|
318
|
+
readMediaFile({
|
|
319
|
+
accept,
|
|
320
|
+
capture,
|
|
321
|
+
camera,
|
|
322
|
+
compressed,
|
|
323
|
+
maxDuration,
|
|
324
|
+
multiple,
|
|
325
|
+
count,
|
|
326
|
+
}).then((fileList) => {
|
|
327
|
+
if (typeof callback === 'function') callback(fileList);
|
|
328
|
+
this.readNext(fileList);
|
|
329
|
+
});
|
|
330
|
+
} else {
|
|
331
|
+
readFile(accept, count, multiple).then((fileList) => {
|
|
332
|
+
if (typeof callback === 'function') callback(fileList);
|
|
333
|
+
this.readNext(fileList);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
async readNext(fileList) {
|
|
339
|
+
if (this.reading) return;
|
|
340
|
+
this.reading = true;
|
|
341
|
+
let next = true;
|
|
342
|
+
const stop = new Promise((resolve, reject) => {
|
|
343
|
+
this.$emit(
|
|
344
|
+
'beforeRead',
|
|
345
|
+
fileList,
|
|
346
|
+
() => (next = false),
|
|
347
|
+
() => resolve(),
|
|
348
|
+
() => reject()
|
|
349
|
+
);
|
|
350
|
+
});
|
|
351
|
+
if (!next) {
|
|
352
|
+
try {
|
|
353
|
+
await stop;
|
|
354
|
+
} catch (e) {
|
|
355
|
+
this.reading = false;
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
this.reading = false;
|
|
360
|
+
if (this.maxSize > 0) {
|
|
361
|
+
for (let item of fileList) {
|
|
362
|
+
if (item.size / 1024 > this.maxSize) {
|
|
363
|
+
console.error(`文件大小${Math.floor(item.size / 1024)}kb超过${this.maxSize}kb限制`);
|
|
364
|
+
this.$emit('oversize', item, fileList);
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
fileList.forEach((item) => (item.status = 'uploading'));
|
|
370
|
+
if (this.dataValue.length + fileList.length > this.maxCount) {
|
|
371
|
+
fileList.splice(this.maxCount - this.dataValue.length);
|
|
372
|
+
}
|
|
373
|
+
this.dataValue = this.dataValue.concat(fileList);
|
|
374
|
+
this.$emit('input', this.dataValue);
|
|
375
|
+
this.$emit('read', fileList);
|
|
376
|
+
},
|
|
377
|
+
async deleteItem(index) {
|
|
378
|
+
if (this.disabled) return;
|
|
379
|
+
if (this.deleting) return;
|
|
380
|
+
this.deleting = true;
|
|
381
|
+
let next = true;
|
|
382
|
+
const stop = new Promise((resolve, reject) => {
|
|
383
|
+
this.$emit(
|
|
384
|
+
'beforeDelete',
|
|
385
|
+
index,
|
|
386
|
+
() => (next = false),
|
|
387
|
+
() => resolve(),
|
|
388
|
+
() => reject()
|
|
389
|
+
);
|
|
390
|
+
});
|
|
391
|
+
if (!next) {
|
|
392
|
+
try {
|
|
393
|
+
await stop;
|
|
394
|
+
} catch (e) {
|
|
395
|
+
//TODO handle the exception
|
|
396
|
+
this.deleting = false;
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
this.deleting = false;
|
|
401
|
+
this.dataValue.splice(index, 1);
|
|
402
|
+
this.$emit('input', this.dataValue);
|
|
403
|
+
this.$emit('delete', index, this.dataValue);
|
|
404
|
+
},
|
|
405
|
+
previewItem(index, item) {
|
|
406
|
+
if (!this.cmpPreviewFullImage) return;
|
|
407
|
+
if (['video', 'image'].indexOf(item.type) === -1) return;
|
|
408
|
+
this.previewIndex = index;
|
|
409
|
+
},
|
|
410
|
+
// #ifdef MP-ALIPAY
|
|
411
|
+
setMediaType() {
|
|
412
|
+
this.mediaType = this.mediaType === 'image' ? 'video' : 'image';
|
|
413
|
+
},
|
|
414
|
+
// #endif
|
|
415
|
+
},
|
|
416
|
+
};
|
|
417
|
+
</script>
|
|
418
|
+
|
|
419
|
+
<style lang="scss" scoped>
|
|
420
|
+
@keyframes ste-upload-rotate {
|
|
421
|
+
0% {
|
|
422
|
+
transform: rotate(0deg);
|
|
423
|
+
}
|
|
424
|
+
100% {
|
|
425
|
+
transform: rotate(360deg);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
.ste-upload-root {
|
|
429
|
+
.image {
|
|
430
|
+
width: 100%;
|
|
431
|
+
height: 100%;
|
|
432
|
+
max-width: 100%;
|
|
433
|
+
max-height: 100%;
|
|
434
|
+
}
|
|
435
|
+
.upload-list {
|
|
436
|
+
display: flex;
|
|
437
|
+
flex-direction: row;
|
|
438
|
+
justify-content: flex-start;
|
|
439
|
+
flex-wrap: var(--ste-upload-flex-wrap);
|
|
440
|
+
|
|
441
|
+
.image-item {
|
|
442
|
+
width: var(--ste-upload-width);
|
|
443
|
+
height: var(--ste-upload-height);
|
|
444
|
+
border-radius: var(--ste-upload-radius);
|
|
445
|
+
display: flex;
|
|
446
|
+
align-items: center;
|
|
447
|
+
justify-content: center;
|
|
448
|
+
margin-bottom: var(--ste-upload-item-margin);
|
|
449
|
+
margin-right: var(--ste-upload-item-margin);
|
|
450
|
+
position: relative;
|
|
451
|
+
background: #f7f7f7;
|
|
452
|
+
overflow: hidden;
|
|
453
|
+
|
|
454
|
+
&.add-file {
|
|
455
|
+
.upload-btn {
|
|
456
|
+
display: flex;
|
|
457
|
+
align-items: center;
|
|
458
|
+
justify-content: center;
|
|
459
|
+
flex-direction: column;
|
|
460
|
+
.upload-text {
|
|
461
|
+
color: #ccc;
|
|
462
|
+
font-size: 24rpx;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
.icon {
|
|
466
|
+
.video {
|
|
467
|
+
transform: rotateZ(-90deg);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
.uploading,
|
|
472
|
+
.error {
|
|
473
|
+
position: absolute;
|
|
474
|
+
z-index: 5;
|
|
475
|
+
width: 100%;
|
|
476
|
+
height: 100%;
|
|
477
|
+
background-color: rgba(0, 0, 0, 0.45);
|
|
478
|
+
color: #fff;
|
|
479
|
+
display: flex;
|
|
480
|
+
flex-direction: column;
|
|
481
|
+
justify-content: center;
|
|
482
|
+
align-items: center;
|
|
483
|
+
font-family: PingFang SC, PingFang SC;
|
|
484
|
+
font-weight: 400;
|
|
485
|
+
|
|
486
|
+
.icon {
|
|
487
|
+
width: 48rpx;
|
|
488
|
+
height: 48rpx;
|
|
489
|
+
display: flex;
|
|
490
|
+
align-items: center;
|
|
491
|
+
text-align: center;
|
|
492
|
+
}
|
|
493
|
+
.text {
|
|
494
|
+
margin-top: 16rpx;
|
|
495
|
+
font-size: 28rpx;
|
|
496
|
+
line-height: 40rpx;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.uploading .icon {
|
|
501
|
+
animation: ste-upload-rotate 1s linear infinite;
|
|
502
|
+
}
|
|
503
|
+
.delete {
|
|
504
|
+
position: absolute;
|
|
505
|
+
z-index: 10;
|
|
506
|
+
width: 90rpx;
|
|
507
|
+
height: 90rpx;
|
|
508
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
509
|
+
color: #fff;
|
|
510
|
+
font-size: 12rpx;
|
|
511
|
+
top: -45rpx;
|
|
512
|
+
right: -45rpx;
|
|
513
|
+
border-radius: 50%;
|
|
514
|
+
.icon {
|
|
515
|
+
position: absolute;
|
|
516
|
+
left: 16rpx;
|
|
517
|
+
bottom: 16rpx;
|
|
518
|
+
display: flex;
|
|
519
|
+
align-items: center;
|
|
520
|
+
justify-content: center;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
</style>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Video 视频
|
|
2
|
+
基于uni-app的视频组件二次开发,新增清晰度、倍速选择功能
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### 兼容性
|
|
6
|
+
#### VUE支持
|
|
7
|
+
|VUE2 | VUE3 |
|
|
8
|
+
|----- |----- |
|
|
9
|
+
|√ | × |
|
|
10
|
+
#### 平台支持
|
|
11
|
+
|App|H5应用 |微信小程序 |支付宝小程序 |百度小程序 |字节小程序 |QQ小程序 |
|
|
12
|
+
|:-:|:-: |:-: |:-: |:-: |:-: |:-: |
|
|
13
|
+
|x |× |√ |× |× |× |× |
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### 代码演示
|
|
17
|
+
#### 基础使用
|
|
18
|
+
默认视频宽度会根据父容器的宽度撑满
|
|
19
|
+
```html
|
|
20
|
+
<ste-video
|
|
21
|
+
title="视频标题视频标题"
|
|
22
|
+
src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/2minute-demo.mp4"
|
|
23
|
+
></ste-video>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 可选择清晰度
|
|
27
|
+
配置`resolution`后会在全屏时显示清晰度选择选项,数据结构如下
|
|
28
|
+
```html
|
|
29
|
+
<ste-video title="视频标题视频标题" :resolution="resolutionConfigArr"></ste-video>
|
|
30
|
+
<script>
|
|
31
|
+
export default {
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
resolutionConfigArr: [
|
|
35
|
+
{ text: '流畅', url: 'https://image.whzb.com/chain/StellarUI/video/demo1.mp4' },
|
|
36
|
+
{ text: '高清', url: 'https://image.whzb.com/chain/StellarUI/video/demo2.mp4' },
|
|
37
|
+
],
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
---$
|
|
45
|
+
### API
|
|
46
|
+
#### 组件属性(Props)
|
|
47
|
+
| 参数 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
48
|
+
| --- | --- | --- | --- | --- | --- |
|
|
49
|
+
| `resolution` | 清晰度选择项数据 | `Array` | `` | - | - |
|
|
50
|
+
| `autoHeight` | 是否视频高度跟随父容器 | `Boolean` | `false` | - | - |
|
|
51
|
+
|
|
52
|
+
其他属性可参考原生[video](https://zh.uniapp.dcloud.io/component/video.html)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
#### 组件事件(Events)
|
|
56
|
+
事件可参考原生[video](https://zh.uniapp.dcloud.io/component/video.html)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
---$
|
|
60
|
+
{{fuyuwei}}
|