@10yun/cv-mobile-ui 0.5.20 → 0.5.21
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/package.json +1 -1
- package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
- package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
- package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
- package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
- package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
- package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
- package/uni-ui/lib/uni-card/uni-card.vue +124 -1
- package/uni-ui/lib/uni-col/uni-col.vue +1 -1
- package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
- package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
- package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
- package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
- package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
- package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
- package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
- package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
- package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
- package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
- package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
- package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
- package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
- package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
- package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
- package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
- package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
- package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
- package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
- package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
- package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
- package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
- package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
- package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
- package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
- package/uni-ui/lib/uni-group/uni-group.vue +85 -1
- package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
- package/uni-ui/lib/uni-list/uni-list.vue +81 -1
- package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
- package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
- package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
- package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
- package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
- package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
- package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
- package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
- package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
- package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
- package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
- package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
- package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
- package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
- package/uni-ui/lib/uni-row/uni-row.vue +1 -1
- package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
- package/uni-ui/lib/uni-section/uni-section.vue +109 -1
- package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
- package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
- package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
- package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
- package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
- package/uni-ui/lib/uni-table/uni-table.vue +297 -1
- package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
- package/uni-ui/lib/uni-td/uni-td.vue +78 -1
- package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
- package/uni-ui/lib/uni-th/uni-th.vue +224 -1
- package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
- package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
- package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
|
@@ -1 +1,177 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-file-picker__files">
|
|
3
2
|
<view v-if="!readonly" class="files-button" @click="choose">
|
|
4
3
|
<slot></slot>
|
|
5
4
|
</view>
|
|
6
5
|
<!-- :class="{'is-text-box':showType === 'list'}" -->
|
|
7
6
|
<view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle">
|
|
8
7
|
<!-- ,'is-list-card':showType === 'list-card' -->
|
|
9
8
|
<view
|
|
10
9
|
class="uni-file-picker__lists-box"
|
|
11
10
|
v-for="(item, index) in list"
|
|
12
11
|
:key="index"
|
|
13
12
|
:class="{
|
|
14
13
|
'files-border': index !== 0 && styles.dividline
|
|
15
14
|
}"
|
|
16
15
|
:style="index !== 0 && styles.dividline && borderLineStyle"
|
|
17
16
|
>
|
|
18
17
|
<view class="uni-file-picker__item">
|
|
19
18
|
<!-- :class="{'is-text-image':showType === 'list'}" -->
|
|
20
19
|
<!-- <view class="files__image is-text-image">
|
|
21
20
|
<view class="files__name">{{ item.name }}</view>
|
|
22
21
|
<view v-if="delIcon && !readonly" class="icon-del-box icon-files" @click="delFile(index)">
|
|
23
22
|
<view class="icon-del icon-files"></view>
|
|
24
23
|
<view class="icon-del rotate"></view>
|
|
25
24
|
</view>
|
|
26
25
|
</view>
|
|
27
26
|
<view v-if="(item.progress && item.progress !== 100) || item.progress === 0" class="file-picker__progress">
|
|
28
27
|
<progress
|
|
29
28
|
class="file-picker__progress-item"
|
|
30
29
|
:percent="item.progress === -1 ? 0 : item.progress"
|
|
31
30
|
stroke-width="4"
|
|
32
31
|
:backgroundColor="item.errMsg ? '#ff5a5f' : '#EBEBEB'"
|
|
33
32
|
/>
|
|
34
33
|
</view>
|
|
35
34
|
<view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item, index)">点击重试</view>
|
|
36
35
|
</view>
|
|
37
36
|
</view>
|
|
38
37
|
</view>
|
|
39
38
|
name: 'uploadFile',
|
|
40
39
|
emits: ['uploadFiles', 'choose', 'delFile'],
|
|
41
40
|
props: {
|
|
42
41
|
filesList: {
|
|
43
42
|
type: Array,
|
|
44
43
|
default() {
|
|
45
44
|
return [];
|
|
46
45
|
}
|
|
47
46
|
},
|
|
48
47
|
delIcon: {
|
|
49
48
|
type: Boolean,
|
|
50
49
|
default: true
|
|
51
50
|
},
|
|
52
51
|
limit: {
|
|
53
52
|
type: [Number, String],
|
|
54
53
|
default: 9
|
|
55
54
|
},
|
|
56
55
|
showType: {
|
|
57
56
|
type: String,
|
|
58
57
|
default: ''
|
|
59
58
|
},
|
|
60
59
|
listStyles: {
|
|
61
60
|
type: Object,
|
|
62
61
|
default() {
|
|
63
62
|
return {
|
|
64
63
|
// 是否显示边框
|
|
65
64
|
border: true,
|
|
66
65
|
// 是否显示分隔线
|
|
67
66
|
dividline: true,
|
|
68
67
|
// 线条样式
|
|
69
68
|
borderStyle: {}
|
|
70
69
|
};
|
|
71
70
|
}
|
|
72
71
|
},
|
|
73
72
|
readonly: {
|
|
74
73
|
type: Boolean,
|
|
75
74
|
default: false
|
|
76
75
|
}
|
|
77
76
|
},
|
|
78
77
|
computed: {
|
|
79
78
|
list() {
|
|
80
79
|
let files = [];
|
|
81
80
|
this.filesList.forEach((v) => {
|
|
82
81
|
files.push(v);
|
|
83
82
|
});
|
|
84
83
|
return files;
|
|
85
84
|
},
|
|
86
85
|
styles() {
|
|
87
86
|
let styles = {
|
|
88
87
|
border: true,
|
|
89
88
|
dividline: true,
|
|
90
89
|
'border-style': {}
|
|
91
90
|
};
|
|
92
91
|
return Object.assign(styles, this.listStyles);
|
|
93
92
|
},
|
|
94
93
|
borderStyle() {
|
|
95
94
|
let { borderStyle, border } = this.styles;
|
|
96
95
|
let obj = {};
|
|
97
96
|
if (!border) {
|
|
98
97
|
obj.border = 'none';
|
|
99
98
|
} else {
|
|
100
99
|
let width = (borderStyle && borderStyle.width) || 1;
|
|
101
100
|
width = this.value2px(width);
|
|
102
101
|
let radius = (borderStyle && borderStyle.radius) || 5;
|
|
103
102
|
radius = this.value2px(radius);
|
|
104
103
|
obj = {
|
|
105
104
|
'border-width': width,
|
|
106
105
|
'border-style': (borderStyle && borderStyle.style) || 'solid',
|
|
107
106
|
'border-color': (borderStyle && borderStyle.color) || '#eee',
|
|
108
107
|
'border-radius': radius
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
110
|
let classles = '';
|
|
112
111
|
for (let i in obj) {
|
|
113
112
|
classles += `${i}:${obj[i]};`;
|
|
114
113
|
}
|
|
115
114
|
return classles;
|
|
116
115
|
},
|
|
117
116
|
borderLineStyle() {
|
|
118
117
|
let obj = {};
|
|
119
118
|
let { borderStyle } = this.styles;
|
|
120
119
|
if (borderStyle && borderStyle.color) {
|
|
121
120
|
obj['border-color'] = borderStyle.color;
|
|
122
121
|
}
|
|
123
122
|
if (borderStyle && borderStyle.width) {
|
|
124
123
|
let width = (borderStyle && borderStyle.width) || 1;
|
|
125
124
|
let style = (borderStyle && borderStyle.style) || 0;
|
|
126
125
|
if (typeof width === 'number') {
|
|
127
126
|
width += 'px';
|
|
128
127
|
} else {
|
|
129
128
|
width = width.indexOf('px') ? width : width + 'px';
|
|
130
129
|
}
|
|
131
130
|
obj['border-width'] = width;
|
|
132
131
|
if (typeof style === 'number') {
|
|
133
132
|
style += 'px';
|
|
134
133
|
} else {
|
|
135
134
|
style = style.indexOf('px') ? style : style + 'px';
|
|
136
135
|
}
|
|
137
136
|
obj['border-top-style'] = style;
|
|
138
137
|
}
|
|
139
138
|
let classles = '';
|
|
140
139
|
for (let i in obj) {
|
|
141
140
|
classles += `${i}:${obj[i]};`;
|
|
142
141
|
}
|
|
143
142
|
return classles;
|
|
144
143
|
}
|
|
145
144
|
},
|
|
146
145
|
methods: {
|
|
147
146
|
uploadFiles(item, index) {
|
|
148
147
|
this.$emit('uploadFiles', {
|
|
149
148
|
item,
|
|
150
149
|
index
|
|
151
150
|
});
|
|
152
151
|
},
|
|
153
152
|
choose() {
|
|
154
153
|
this.$emit('choose');
|
|
155
154
|
},
|
|
156
155
|
delFile(index) {
|
|
157
156
|
this.$emit('delFile', index);
|
|
158
157
|
},
|
|
159
158
|
value2px(value) {
|
|
160
159
|
if (typeof value === 'number') {
|
|
161
160
|
value += 'px';
|
|
162
161
|
} else {
|
|
163
162
|
value = value.indexOf('px') !== -1 ? value : value + 'px';
|
|
164
163
|
}
|
|
165
164
|
return value;
|
|
166
165
|
}
|
|
167
166
|
}
|
|
167
|
+
<template>
|
|
168
|
+
<view class="uni-file-picker__files">
|
|
169
|
+
<view v-if="!readonly" class="files-button" @click="choose">
|
|
170
|
+
<slot></slot>
|
|
171
|
+
</view>
|
|
172
|
+
<!-- :class="{'is-text-box':showType === 'list'}" -->
|
|
173
|
+
<view v-if="list.length > 0" class="uni-file-picker__lists is-text-box" :style="borderStyle">
|
|
174
|
+
<!-- ,'is-list-card':showType === 'list-card' -->
|
|
175
|
+
<view
|
|
176
|
+
class="uni-file-picker__lists-box"
|
|
177
|
+
v-for="(item, index) in list"
|
|
178
|
+
:key="index"
|
|
179
|
+
:class="{
|
|
180
|
+
'files-border': index !== 0 && styles.dividline
|
|
181
|
+
}"
|
|
182
|
+
:style="index !== 0 && styles.dividline && borderLineStyle"
|
|
183
|
+
>
|
|
184
|
+
<view class="uni-file-picker__item">
|
|
185
|
+
<!-- :class="{'is-text-image':showType === 'list'}" -->
|
|
186
|
+
<!-- <view class="files__image is-text-image">
|
|
187
|
+
<image class="header-image" :src="item.logo" mode="aspectFit"></image>
|
|
188
|
+
</view> -->
|
|
189
|
+
<view class="files__name">{{ item.name }}</view>
|
|
190
|
+
<view v-if="delIcon && !readonly" class="icon-del-box icon-files" @click="delFile(index)">
|
|
191
|
+
<view class="icon-del icon-files"></view>
|
|
192
|
+
<view class="icon-del rotate"></view>
|
|
193
|
+
</view>
|
|
194
|
+
</view>
|
|
195
|
+
<view v-if="(item.progress && item.progress !== 100) || item.progress === 0" class="file-picker__progress">
|
|
196
|
+
<progress
|
|
197
|
+
class="file-picker__progress-item"
|
|
198
|
+
:percent="item.progress === -1 ? 0 : item.progress"
|
|
199
|
+
stroke-width="4"
|
|
200
|
+
:backgroundColor="item.errMsg ? '#ff5a5f' : '#EBEBEB'"
|
|
201
|
+
/>
|
|
202
|
+
</view>
|
|
203
|
+
<view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="uploadFiles(item, index)">点击重试</view>
|
|
204
|
+
</view>
|
|
205
|
+
</view>
|
|
206
|
+
</view>
|
|
207
|
+
</template>
|
|
208
|
+
<script>
|
|
209
|
+
export default {
|
|
210
|
+
name: 'uploadFile',
|
|
211
|
+
emits: ['uploadFiles', 'choose', 'delFile'],
|
|
212
|
+
props: {
|
|
213
|
+
filesList: {
|
|
214
|
+
type: Array,
|
|
215
|
+
default() {
|
|
216
|
+
return [];
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
delIcon: {
|
|
220
|
+
type: Boolean,
|
|
221
|
+
default: true
|
|
222
|
+
},
|
|
223
|
+
limit: {
|
|
224
|
+
type: [Number, String],
|
|
225
|
+
default: 9
|
|
226
|
+
},
|
|
227
|
+
showType: {
|
|
228
|
+
type: String,
|
|
229
|
+
default: ''
|
|
230
|
+
},
|
|
231
|
+
listStyles: {
|
|
232
|
+
type: Object,
|
|
233
|
+
default() {
|
|
234
|
+
return {
|
|
235
|
+
// 是否显示边框
|
|
236
|
+
border: true,
|
|
237
|
+
// 是否显示分隔线
|
|
238
|
+
dividline: true,
|
|
239
|
+
// 线条样式
|
|
240
|
+
borderStyle: {}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
readonly: {
|
|
245
|
+
type: Boolean,
|
|
246
|
+
default: false
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
computed: {
|
|
250
|
+
list() {
|
|
251
|
+
let files = [];
|
|
252
|
+
this.filesList.forEach((v) => {
|
|
253
|
+
files.push(v);
|
|
254
|
+
});
|
|
255
|
+
return files;
|
|
256
|
+
},
|
|
257
|
+
styles() {
|
|
258
|
+
let styles = {
|
|
259
|
+
border: true,
|
|
260
|
+
dividline: true,
|
|
261
|
+
'border-style': {}
|
|
262
|
+
};
|
|
263
|
+
return Object.assign(styles, this.listStyles);
|
|
264
|
+
},
|
|
265
|
+
borderStyle() {
|
|
266
|
+
let { borderStyle, border } = this.styles;
|
|
267
|
+
let obj = {};
|
|
268
|
+
if (!border) {
|
|
269
|
+
obj.border = 'none';
|
|
270
|
+
} else {
|
|
271
|
+
let width = (borderStyle && borderStyle.width) || 1;
|
|
272
|
+
width = this.value2px(width);
|
|
273
|
+
let radius = (borderStyle && borderStyle.radius) || 5;
|
|
274
|
+
radius = this.value2px(radius);
|
|
275
|
+
obj = {
|
|
276
|
+
'border-width': width,
|
|
277
|
+
'border-style': (borderStyle && borderStyle.style) || 'solid',
|
|
278
|
+
'border-color': (borderStyle && borderStyle.color) || '#eee',
|
|
279
|
+
'border-radius': radius
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
let classles = '';
|
|
283
|
+
for (let i in obj) {
|
|
284
|
+
classles += `${i}:${obj[i]};`;
|
|
285
|
+
}
|
|
286
|
+
return classles;
|
|
287
|
+
},
|
|
288
|
+
borderLineStyle() {
|
|
289
|
+
let obj = {};
|
|
290
|
+
let { borderStyle } = this.styles;
|
|
291
|
+
if (borderStyle && borderStyle.color) {
|
|
292
|
+
obj['border-color'] = borderStyle.color;
|
|
293
|
+
}
|
|
294
|
+
if (borderStyle && borderStyle.width) {
|
|
295
|
+
let width = (borderStyle && borderStyle.width) || 1;
|
|
296
|
+
let style = (borderStyle && borderStyle.style) || 0;
|
|
297
|
+
if (typeof width === 'number') {
|
|
298
|
+
width += 'px';
|
|
299
|
+
} else {
|
|
300
|
+
width = width.indexOf('px') ? width : width + 'px';
|
|
301
|
+
}
|
|
302
|
+
obj['border-width'] = width;
|
|
303
|
+
if (typeof style === 'number') {
|
|
304
|
+
style += 'px';
|
|
305
|
+
} else {
|
|
306
|
+
style = style.indexOf('px') ? style : style + 'px';
|
|
307
|
+
}
|
|
308
|
+
obj['border-top-style'] = style;
|
|
309
|
+
}
|
|
310
|
+
let classles = '';
|
|
311
|
+
for (let i in obj) {
|
|
312
|
+
classles += `${i}:${obj[i]};`;
|
|
313
|
+
}
|
|
314
|
+
return classles;
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
methods: {
|
|
318
|
+
uploadFiles(item, index) {
|
|
319
|
+
this.$emit('uploadFiles', {
|
|
320
|
+
item,
|
|
321
|
+
index
|
|
322
|
+
});
|
|
323
|
+
},
|
|
324
|
+
choose() {
|
|
325
|
+
this.$emit('choose');
|
|
326
|
+
},
|
|
327
|
+
delFile(index) {
|
|
328
|
+
this.$emit('delFile', index);
|
|
329
|
+
},
|
|
330
|
+
value2px(value) {
|
|
331
|
+
if (typeof value === 'number') {
|
|
332
|
+
value += 'px';
|
|
333
|
+
} else {
|
|
334
|
+
value = value.indexOf('px') !== -1 ? value : value + 'px';
|
|
335
|
+
}
|
|
336
|
+
return value;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
</script>
|
|
341
|
+
<style>
|
|
342
|
+
@import 'style.css';
|
|
343
|
+
</style>
|
|
@@ -1 +1,176 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-file-picker__container">
|
|
3
2
|
<view class="file-picker__box" v-for="(item, index) in filesList" :key="index" :style="boxStyle">
|
|
4
3
|
<view class="file-picker__box-content" :style="borderStyle">
|
|
5
4
|
<image class="file-image" :src="item.url" mode="aspectFill" @click.stop="prviewImage(item, index)"></image>
|
|
6
5
|
<view v-if="delIcon && !readonly" class="icon-del-box" @click.stop="delFile(index)">
|
|
7
6
|
<view class="icon-del"></view>
|
|
8
7
|
<view class="icon-del rotate"></view>
|
|
9
8
|
</view>
|
|
10
9
|
<view v-if="(item.progress && item.progress !== 100) || item.progress === 0" class="file-picker__progress">
|
|
11
10
|
<progress
|
|
12
11
|
class="file-picker__progress-item"
|
|
13
12
|
:percent="item.progress === -1 ? 0 : item.progress"
|
|
14
13
|
stroke-width="4"
|
|
15
14
|
:backgroundColor="item.errMsg ? '#ff5a5f' : '#EBEBEB'"
|
|
16
15
|
/>
|
|
17
16
|
</view>
|
|
18
17
|
<view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item, index)">点击重试</view>
|
|
19
18
|
</view>
|
|
20
19
|
</view>
|
|
21
20
|
<view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle">
|
|
22
21
|
<view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
|
|
23
22
|
<slot>
|
|
24
23
|
<view class="icon-add"></view>
|
|
25
24
|
<view class="icon-add rotate"></view>
|
|
26
25
|
</slot>
|
|
27
26
|
</view>
|
|
28
27
|
</view>
|
|
29
28
|
</view>
|
|
30
29
|
name: 'uploadImage',
|
|
31
30
|
emits: ['uploadFiles', 'choose', 'delFile'],
|
|
32
31
|
props: {
|
|
33
32
|
filesList: {
|
|
34
33
|
type: Array,
|
|
35
34
|
default() {
|
|
36
35
|
return [];
|
|
37
36
|
}
|
|
38
37
|
},
|
|
39
38
|
disabled: {
|
|
40
39
|
type: Boolean,
|
|
41
40
|
default: false
|
|
42
41
|
},
|
|
43
42
|
disablePreview: {
|
|
44
43
|
type: Boolean,
|
|
45
44
|
default: false
|
|
46
45
|
},
|
|
47
46
|
limit: {
|
|
48
47
|
type: [Number, String],
|
|
49
48
|
default: 9
|
|
50
49
|
},
|
|
51
50
|
imageStyles: {
|
|
52
51
|
type: Object,
|
|
53
52
|
default() {
|
|
54
53
|
return {
|
|
55
54
|
width: 'auto',
|
|
56
55
|
height: 'auto',
|
|
57
56
|
border: {}
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
59
|
},
|
|
61
60
|
delIcon: {
|
|
62
61
|
type: Boolean,
|
|
63
62
|
default: true
|
|
64
63
|
},
|
|
65
64
|
readonly: {
|
|
66
65
|
type: Boolean,
|
|
67
66
|
default: false
|
|
68
67
|
}
|
|
69
68
|
},
|
|
70
69
|
computed: {
|
|
71
70
|
styles() {
|
|
72
71
|
let styles = {
|
|
73
72
|
width: 'auto',
|
|
74
73
|
height: 'auto',
|
|
75
74
|
border: {}
|
|
76
75
|
};
|
|
77
76
|
return Object.assign(styles, this.imageStyles);
|
|
78
77
|
},
|
|
79
78
|
boxStyle() {
|
|
80
79
|
const { width = 'auto', height = 'auto' } = this.styles;
|
|
81
80
|
let obj = {};
|
|
82
81
|
if (height === 'auto') {
|
|
83
82
|
if (width !== 'auto') {
|
|
84
83
|
obj.height = this.value2px(width);
|
|
85
84
|
obj['padding-top'] = 0;
|
|
86
85
|
} else {
|
|
87
86
|
obj.height = 0;
|
|
88
87
|
}
|
|
89
88
|
} else {
|
|
90
89
|
obj.height = this.value2px(height);
|
|
91
90
|
obj['padding-top'] = 0;
|
|
92
91
|
}
|
|
93
92
|
if (width === 'auto') {
|
|
94
93
|
if (height !== 'auto') {
|
|
95
94
|
obj.width = this.value2px(height);
|
|
96
95
|
} else {
|
|
97
96
|
obj.width = '33.3%';
|
|
98
97
|
}
|
|
99
98
|
} else {
|
|
100
99
|
obj.width = this.value2px(width);
|
|
101
100
|
}
|
|
102
101
|
let classles = '';
|
|
103
102
|
for (let i in obj) {
|
|
104
103
|
classles += `${i}:${obj[i]};`;
|
|
105
104
|
}
|
|
106
105
|
return classles;
|
|
107
106
|
},
|
|
108
107
|
borderStyle() {
|
|
109
108
|
let { border } = this.styles;
|
|
110
109
|
let obj = {};
|
|
111
110
|
const widthDefaultValue = 1;
|
|
112
111
|
const radiusDefaultValue = 3;
|
|
113
112
|
if (typeof border === 'boolean') {
|
|
114
113
|
obj.border = border ? '1px #eee solid' : 'none';
|
|
115
114
|
} else {
|
|
116
115
|
let width = (border && border.width) || widthDefaultValue;
|
|
117
116
|
width = this.value2px(width);
|
|
118
117
|
let radius = (border && border.radius) || radiusDefaultValue;
|
|
119
118
|
radius = this.value2px(radius);
|
|
120
119
|
obj = {
|
|
121
120
|
'border-width': width,
|
|
122
121
|
'border-style': (border && border.style) || 'solid',
|
|
123
122
|
'border-color': (border && border.color) || '#eee',
|
|
124
123
|
'border-radius': radius
|
|
125
124
|
};
|
|
126
125
|
}
|
|
127
126
|
let classles = '';
|
|
128
127
|
for (let i in obj) {
|
|
129
128
|
classles += `${i}:${obj[i]};`;
|
|
130
129
|
}
|
|
131
130
|
return classles;
|
|
132
131
|
}
|
|
133
132
|
},
|
|
134
133
|
methods: {
|
|
135
134
|
uploadFiles(item, index) {
|
|
136
135
|
this.$emit('uploadFiles', item);
|
|
137
136
|
},
|
|
138
137
|
choose() {
|
|
139
138
|
this.$emit('choose');
|
|
140
139
|
},
|
|
141
140
|
delFile(index) {
|
|
142
141
|
this.$emit('delFile', index);
|
|
143
142
|
},
|
|
144
143
|
prviewImage(img, index) {
|
|
145
144
|
let urls = [];
|
|
146
145
|
if (Number(this.limit) === 1 && this.disablePreview && !this.disabled) {
|
|
147
146
|
this.$emit('choose');
|
|
148
147
|
}
|
|
149
148
|
if (this.disablePreview) return;
|
|
150
149
|
this.filesList.forEach((i) => {
|
|
151
150
|
urls.push(i.url);
|
|
152
151
|
});
|
|
153
152
|
uni.previewImage({
|
|
154
153
|
urls: urls,
|
|
155
154
|
current: index
|
|
156
155
|
});
|
|
157
156
|
},
|
|
158
157
|
value2px(value) {
|
|
159
158
|
if (typeof value === 'number') {
|
|
160
159
|
value += 'px';
|
|
161
160
|
} else {
|
|
162
161
|
if (value.indexOf('%') === -1) {
|
|
163
162
|
value = value.indexOf('px') !== -1 ? value : value + 'px';
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
return value;
|
|
167
166
|
}
|
|
168
167
|
}
|
|
168
|
+
<template>
|
|
169
|
+
<view class="uni-file-picker__container">
|
|
170
|
+
<view class="file-picker__box" v-for="(item, index) in filesList" :key="index" :style="boxStyle">
|
|
171
|
+
<view class="file-picker__box-content" :style="borderStyle">
|
|
172
|
+
<image class="file-image" :src="item.url" mode="aspectFill" @click.stop="prviewImage(item, index)"></image>
|
|
173
|
+
<view v-if="delIcon && !readonly" class="icon-del-box" @click.stop="delFile(index)">
|
|
174
|
+
<view class="icon-del"></view>
|
|
175
|
+
<view class="icon-del rotate"></view>
|
|
176
|
+
</view>
|
|
177
|
+
<view v-if="(item.progress && item.progress !== 100) || item.progress === 0" class="file-picker__progress">
|
|
178
|
+
<progress
|
|
179
|
+
class="file-picker__progress-item"
|
|
180
|
+
:percent="item.progress === -1 ? 0 : item.progress"
|
|
181
|
+
stroke-width="4"
|
|
182
|
+
:backgroundColor="item.errMsg ? '#ff5a5f' : '#EBEBEB'"
|
|
183
|
+
/>
|
|
184
|
+
</view>
|
|
185
|
+
<view v-if="item.errMsg" class="file-picker__mask" @click.stop="uploadFiles(item, index)">点击重试</view>
|
|
186
|
+
</view>
|
|
187
|
+
</view>
|
|
188
|
+
<view v-if="filesList.length < limit && !readonly" class="file-picker__box" :style="boxStyle">
|
|
189
|
+
<view class="file-picker__box-content is-add" :style="borderStyle" @click="choose">
|
|
190
|
+
<slot>
|
|
191
|
+
<view class="icon-add"></view>
|
|
192
|
+
<view class="icon-add rotate"></view>
|
|
193
|
+
</slot>
|
|
194
|
+
</view>
|
|
195
|
+
</view>
|
|
196
|
+
</view>
|
|
197
|
+
</template>
|
|
198
|
+
<script>
|
|
199
|
+
export default {
|
|
200
|
+
name: 'uploadImage',
|
|
201
|
+
emits: ['uploadFiles', 'choose', 'delFile'],
|
|
202
|
+
props: {
|
|
203
|
+
filesList: {
|
|
204
|
+
type: Array,
|
|
205
|
+
default() {
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
disabled: {
|
|
210
|
+
type: Boolean,
|
|
211
|
+
default: false
|
|
212
|
+
},
|
|
213
|
+
disablePreview: {
|
|
214
|
+
type: Boolean,
|
|
215
|
+
default: false
|
|
216
|
+
},
|
|
217
|
+
limit: {
|
|
218
|
+
type: [Number, String],
|
|
219
|
+
default: 9
|
|
220
|
+
},
|
|
221
|
+
imageStyles: {
|
|
222
|
+
type: Object,
|
|
223
|
+
default() {
|
|
224
|
+
return {
|
|
225
|
+
width: 'auto',
|
|
226
|
+
height: 'auto',
|
|
227
|
+
border: {}
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
delIcon: {
|
|
232
|
+
type: Boolean,
|
|
233
|
+
default: true
|
|
234
|
+
},
|
|
235
|
+
readonly: {
|
|
236
|
+
type: Boolean,
|
|
237
|
+
default: false
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
computed: {
|
|
241
|
+
styles() {
|
|
242
|
+
let styles = {
|
|
243
|
+
width: 'auto',
|
|
244
|
+
height: 'auto',
|
|
245
|
+
border: {}
|
|
246
|
+
};
|
|
247
|
+
return Object.assign(styles, this.imageStyles);
|
|
248
|
+
},
|
|
249
|
+
boxStyle() {
|
|
250
|
+
const { width = 'auto', height = 'auto' } = this.styles;
|
|
251
|
+
let obj = {};
|
|
252
|
+
if (height === 'auto') {
|
|
253
|
+
if (width !== 'auto') {
|
|
254
|
+
obj.height = this.value2px(width);
|
|
255
|
+
obj['padding-top'] = 0;
|
|
256
|
+
} else {
|
|
257
|
+
obj.height = 0;
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
obj.height = this.value2px(height);
|
|
261
|
+
obj['padding-top'] = 0;
|
|
262
|
+
}
|
|
263
|
+
if (width === 'auto') {
|
|
264
|
+
if (height !== 'auto') {
|
|
265
|
+
obj.width = this.value2px(height);
|
|
266
|
+
} else {
|
|
267
|
+
obj.width = '33.3%';
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
obj.width = this.value2px(width);
|
|
271
|
+
}
|
|
272
|
+
let classles = '';
|
|
273
|
+
for (let i in obj) {
|
|
274
|
+
classles += `${i}:${obj[i]};`;
|
|
275
|
+
}
|
|
276
|
+
return classles;
|
|
277
|
+
},
|
|
278
|
+
borderStyle() {
|
|
279
|
+
let { border } = this.styles;
|
|
280
|
+
let obj = {};
|
|
281
|
+
const widthDefaultValue = 1;
|
|
282
|
+
const radiusDefaultValue = 3;
|
|
283
|
+
if (typeof border === 'boolean') {
|
|
284
|
+
obj.border = border ? '1px #eee solid' : 'none';
|
|
285
|
+
} else {
|
|
286
|
+
let width = (border && border.width) || widthDefaultValue;
|
|
287
|
+
width = this.value2px(width);
|
|
288
|
+
let radius = (border && border.radius) || radiusDefaultValue;
|
|
289
|
+
radius = this.value2px(radius);
|
|
290
|
+
obj = {
|
|
291
|
+
'border-width': width,
|
|
292
|
+
'border-style': (border && border.style) || 'solid',
|
|
293
|
+
'border-color': (border && border.color) || '#eee',
|
|
294
|
+
'border-radius': radius
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
let classles = '';
|
|
298
|
+
for (let i in obj) {
|
|
299
|
+
classles += `${i}:${obj[i]};`;
|
|
300
|
+
}
|
|
301
|
+
return classles;
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
methods: {
|
|
305
|
+
uploadFiles(item, index) {
|
|
306
|
+
this.$emit('uploadFiles', item);
|
|
307
|
+
},
|
|
308
|
+
choose() {
|
|
309
|
+
this.$emit('choose');
|
|
310
|
+
},
|
|
311
|
+
delFile(index) {
|
|
312
|
+
this.$emit('delFile', index);
|
|
313
|
+
},
|
|
314
|
+
prviewImage(img, index) {
|
|
315
|
+
let urls = [];
|
|
316
|
+
if (Number(this.limit) === 1 && this.disablePreview && !this.disabled) {
|
|
317
|
+
this.$emit('choose');
|
|
318
|
+
}
|
|
319
|
+
if (this.disablePreview) return;
|
|
320
|
+
this.filesList.forEach((i) => {
|
|
321
|
+
urls.push(i.url);
|
|
322
|
+
});
|
|
323
|
+
uni.previewImage({
|
|
324
|
+
urls: urls,
|
|
325
|
+
current: index
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
value2px(value) {
|
|
329
|
+
if (typeof value === 'number') {
|
|
330
|
+
value += 'px';
|
|
331
|
+
} else {
|
|
332
|
+
if (value.indexOf('%') === -1) {
|
|
333
|
+
value = value.indexOf('px') !== -1 ? value : value + 'px';
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return value;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
</script>
|
|
341
|
+
<style>
|
|
342
|
+
@import 'style.css';
|
|
343
|
+
</style>
|