@xtdev/xt-miniprogram-ui 1.2.77 → 1.2.78
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/libs/xt-uploader/index.js +225 -138
- package/libs/xt-uploader/index.json +1 -3
- package/libs/xt-uploader/index.wxml +43 -12
- package/libs/xt-uploader/index.wxss +98 -30
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
// src/xt-uploader/index.js
|
|
2
|
-
const utils = require(
|
|
2
|
+
const utils = require('./utils');
|
|
3
3
|
// 节流函数
|
|
4
|
-
function _throttle(fn, wait = 500, isImmediate = false){
|
|
4
|
+
function _throttle(fn, wait = 500, isImmediate = false) {
|
|
5
5
|
var flag = true;
|
|
6
|
-
return function(){
|
|
7
|
-
if(flag == true){
|
|
8
|
-
var context = this
|
|
9
|
-
var args = arguments
|
|
10
|
-
flag = false
|
|
11
|
-
isImmediate && fn.apply(context,args)
|
|
6
|
+
return function () {
|
|
7
|
+
if (flag == true) {
|
|
8
|
+
var context = this;
|
|
9
|
+
var args = arguments;
|
|
10
|
+
flag = false;
|
|
11
|
+
isImmediate && fn.apply(context, args);
|
|
12
12
|
setTimeout(() => {
|
|
13
|
-
!isImmediate && fn.apply(context,args)
|
|
14
|
-
flag = true
|
|
15
|
-
},wait)
|
|
13
|
+
!isImmediate && fn.apply(context, args);
|
|
14
|
+
flag = true;
|
|
15
|
+
}, wait);
|
|
16
16
|
}
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
Component({
|
|
@@ -24,11 +24,11 @@ Component({
|
|
|
24
24
|
properties: {
|
|
25
25
|
title: {
|
|
26
26
|
type: String,
|
|
27
|
-
value:
|
|
27
|
+
value: '',
|
|
28
28
|
},
|
|
29
29
|
icon: {
|
|
30
30
|
type: String,
|
|
31
|
-
value:
|
|
31
|
+
value: 'https://img.tanjiu.cn/home/DDDsrH7PpNhneQsXGFmGGPcSM3QYXG8N.png',
|
|
32
32
|
},
|
|
33
33
|
fileList: {
|
|
34
34
|
type: Array,
|
|
@@ -40,16 +40,16 @@ Component({
|
|
|
40
40
|
},
|
|
41
41
|
uploadDesc: {
|
|
42
42
|
type: String,
|
|
43
|
-
value:
|
|
43
|
+
value: '',
|
|
44
44
|
},
|
|
45
45
|
// ["album", "camera"]
|
|
46
46
|
sourceType: {
|
|
47
47
|
type: Array,
|
|
48
|
-
value: [
|
|
48
|
+
value: ['album', 'camera'],
|
|
49
49
|
},
|
|
50
50
|
fileType: {
|
|
51
51
|
type: String,
|
|
52
|
-
value:
|
|
52
|
+
value: 'image',
|
|
53
53
|
},
|
|
54
54
|
customUpload: {
|
|
55
55
|
type: Boolean,
|
|
@@ -72,14 +72,45 @@ Component({
|
|
|
72
72
|
*/
|
|
73
73
|
waterData: {
|
|
74
74
|
type: Object | null,
|
|
75
|
-
value: null
|
|
75
|
+
value: null,
|
|
76
76
|
},
|
|
77
77
|
},
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
80
|
* 组件的初始数据
|
|
81
81
|
*/
|
|
82
|
-
data: {
|
|
82
|
+
data: {
|
|
83
|
+
tempFileList: [], // 临时文件列表
|
|
84
|
+
},
|
|
85
|
+
/**
|
|
86
|
+
* 初始化本地数据
|
|
87
|
+
*/
|
|
88
|
+
observers: {
|
|
89
|
+
fileList: function (newVal, oldVal) {
|
|
90
|
+
const { tempFileList } = this.data;
|
|
91
|
+
newVal.forEach(url => {
|
|
92
|
+
const urlIndex = tempFileList.findIndex(item => {
|
|
93
|
+
// 获取文件后缀
|
|
94
|
+
const suffix = url.split('.').pop();
|
|
95
|
+
// 根据文件后缀判断视频还是照片
|
|
96
|
+
if (['mp4', 'mkv', 'avi', 'mov', 'flv'].includes(suffix)) {
|
|
97
|
+
item.fileType = 'video';
|
|
98
|
+
} else {
|
|
99
|
+
item.fileType = 'image';
|
|
100
|
+
}
|
|
101
|
+
// 取图片文件名对比
|
|
102
|
+
const fileName = item.url.split('/').pop();
|
|
103
|
+
return fileName.includes(url.split('/').pop());
|
|
104
|
+
});
|
|
105
|
+
if (urlIndex === -1) {
|
|
106
|
+
tempFileList.push({ url, updateStatus: 'success' });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
this.setData({
|
|
110
|
+
tempFileList,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
},
|
|
83
114
|
|
|
84
115
|
/**
|
|
85
116
|
* 组件的方法列表
|
|
@@ -99,7 +130,7 @@ Component({
|
|
|
99
130
|
const url = e.currentTarget.dataset.url;
|
|
100
131
|
const index = e.currentTarget.dataset.index;
|
|
101
132
|
this.properties.fileList.splice(index, 1);
|
|
102
|
-
this.triggerEvent(
|
|
133
|
+
this.triggerEvent('delete', {
|
|
103
134
|
fileList: this.properties.fileList,
|
|
104
135
|
url,
|
|
105
136
|
index,
|
|
@@ -107,128 +138,187 @@ Component({
|
|
|
107
138
|
},
|
|
108
139
|
// 上传成功
|
|
109
140
|
onUploadSuccess(files, url) {
|
|
110
|
-
this.triggerEvent(
|
|
141
|
+
this.triggerEvent('upload', { fileList: files, url });
|
|
111
142
|
},
|
|
112
143
|
// 上传失败
|
|
113
144
|
onUploadError(errMsg) {
|
|
114
|
-
this.triggerEvent(
|
|
145
|
+
this.triggerEvent('error', { errMsg });
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* 重新上传
|
|
149
|
+
* @param {*} e
|
|
150
|
+
*/
|
|
151
|
+
reUpload(e) {
|
|
152
|
+
const reloadItem = e.currentTarget.dataset.item;
|
|
153
|
+
const url = reloadItem.url;
|
|
154
|
+
const { tempFileList } = this.data;
|
|
155
|
+
tempFileList.forEach(item => {
|
|
156
|
+
if (item.url === url) {
|
|
157
|
+
item.updateStatus = 'uploading';
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
this.setData({
|
|
161
|
+
tempFileList,
|
|
162
|
+
});
|
|
163
|
+
this.startUpload(reloadItem);
|
|
115
164
|
},
|
|
116
165
|
// 点击上传
|
|
117
|
-
startTakePhoto: _throttle(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
customUpload,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const errorList = uploadRes.filter(
|
|
177
|
-
(result) => result.status == "rejected"
|
|
178
|
-
);
|
|
179
|
-
if (errorList.length) {
|
|
180
|
-
_this.onUploadError(errorList[0].value);
|
|
181
|
-
}
|
|
166
|
+
startTakePhoto: _throttle(
|
|
167
|
+
function (e) {
|
|
168
|
+
console.log('onStartTakePhoto', e);
|
|
169
|
+
const _this = this;
|
|
170
|
+
const { customUpload, uploadApi, max, sourceType, fileList, fileType, tempFileList } = this.properties;
|
|
171
|
+
if (customUpload) {
|
|
172
|
+
this.triggerEvent('upload', {});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!uploadApi || !uploadApi.url) {
|
|
176
|
+
wx.showToast({
|
|
177
|
+
title: '请传入上传接口',
|
|
178
|
+
icon: 'error',
|
|
179
|
+
});
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// ios企微环境下不支持该API
|
|
183
|
+
const { platform, environment } = this.getSystemInfo();
|
|
184
|
+
console.log(platform, environment);
|
|
185
|
+
let chooseImgApi =
|
|
186
|
+
environment !== 'wxwork' || platform !== 'ios'
|
|
187
|
+
? wx.chooseMedia
|
|
188
|
+
: fileType == 'video'
|
|
189
|
+
? wx.chooseVideo
|
|
190
|
+
: wx.chooseImage;
|
|
191
|
+
chooseImgApi({
|
|
192
|
+
count: max - fileList.length,
|
|
193
|
+
mediaType: ['image'],
|
|
194
|
+
mediaType: fileType == 'video' ? ['video'] : ['image'],
|
|
195
|
+
sizeType: ['compressed'],
|
|
196
|
+
sourceType,
|
|
197
|
+
maxDuration: 60,
|
|
198
|
+
success(res) {
|
|
199
|
+
console.log(res, '0000');
|
|
200
|
+
let { tempFiles, tempFilePath } = res;
|
|
201
|
+
if (!tempFiles && !tempFilePath) {
|
|
202
|
+
return wx.showToast({ title: '文件读取失败', icon: 'none' });
|
|
203
|
+
}
|
|
204
|
+
// 兼容旧版本 wx.chooseVideo 返回的不是数组
|
|
205
|
+
if (!tempFiles) {
|
|
206
|
+
tempFiles = [res];
|
|
207
|
+
}
|
|
208
|
+
if (fileType == 'video' && res.tempFiles[0].size / 1024 / 1024 > 100) {
|
|
209
|
+
// 视频上传不允许超过100M
|
|
210
|
+
wx.showToast({ title: '视频大小不可超过100M', icon: 'none' });
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const newFileList = tempFiles.map((temp, index) => ({
|
|
214
|
+
url: temp.tempFilePath || temp.path,
|
|
215
|
+
name: temp.fileName || temp.name,
|
|
216
|
+
size: temp.size,
|
|
217
|
+
fileType: temp.fileType || temp.type,
|
|
218
|
+
updateStatus: 'uploading',
|
|
219
|
+
processText: '视频上传中',
|
|
220
|
+
id: temp.id || Date.now() + index,
|
|
221
|
+
}));
|
|
222
|
+
let showTempFiles = tempFileList.concat(newFileList);
|
|
223
|
+
_this.setData({
|
|
224
|
+
tempFileList: showTempFiles,
|
|
182
225
|
});
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
226
|
+
// 校验是否需要打水印
|
|
227
|
+
newFileList.forEach(temp => {
|
|
228
|
+
_this.startUpload(temp);
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
fail(error) {
|
|
232
|
+
_this.onUploadError(error && error.errMsg);
|
|
233
|
+
console.log('-----选取失败', error && error.errMsg);
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
},
|
|
237
|
+
1500,
|
|
238
|
+
true
|
|
239
|
+
),
|
|
191
240
|
getSystemInfo() {
|
|
192
|
-
const environment = wx.getSystemInfoSync().environment ||
|
|
241
|
+
const environment = wx.getSystemInfoSync().environment || 'wechat';
|
|
193
242
|
const platform = wx.getSystemInfoSync().platform;
|
|
194
243
|
return {
|
|
195
244
|
environment,
|
|
196
245
|
platform,
|
|
197
246
|
};
|
|
198
247
|
},
|
|
248
|
+
/**
|
|
249
|
+
* 开始上传
|
|
250
|
+
*/
|
|
251
|
+
async startUpload(temp) {
|
|
252
|
+
const _this = this;
|
|
253
|
+
const { waterData } = this.properties;
|
|
254
|
+
const { tempFileList = [] } = this.data;
|
|
255
|
+
_this[waterData ? 'uploadWaterFile' : 'uploadImage_v'](temp.url, waterData)
|
|
256
|
+
.then(({ url, tempFilePath }) => {
|
|
257
|
+
console.log('----uploadRes', url, temp);
|
|
258
|
+
url = url.replace('http://', 'https://');
|
|
259
|
+
url = url.replace('stsapp.oss-cn-hangzhou.aliyuncs.com', 'img.tanjiu.cn');
|
|
260
|
+
|
|
261
|
+
tempFileList.forEach(temp => {
|
|
262
|
+
if (temp.url == tempFilePath) {
|
|
263
|
+
temp.url = url;
|
|
264
|
+
temp.processText = '上传成功';
|
|
265
|
+
temp.updateStatus = 'success';
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
_this.setData({
|
|
269
|
+
tempFileList,
|
|
270
|
+
});
|
|
271
|
+
const files = tempFileList.map(temp => temp.url);
|
|
272
|
+
_this.onUploadSuccess(files, url);
|
|
273
|
+
})
|
|
274
|
+
.catch(({ url, tempFilePath }) => {
|
|
275
|
+
tempFileList.forEach(temp => {
|
|
276
|
+
if (temp.url == tempFilePath) {
|
|
277
|
+
temp.processText = '上传失败';
|
|
278
|
+
temp.updateStatus = 'failed';
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
_this.setData({
|
|
282
|
+
tempFileList,
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
},
|
|
199
286
|
/** 上传水印照片 */
|
|
200
|
-
async uploadWaterFile(
|
|
201
|
-
path,
|
|
202
|
-
data = {},
|
|
203
|
-
url = "core/file/upload/multiV2",
|
|
204
|
-
baseUrl = "https://gateway.tanjiu.cn/",
|
|
205
|
-
) {
|
|
287
|
+
async uploadWaterFile(path, data = {}, url = 'core/file/upload/multiV2', baseUrl = 'https://gateway.tanjiu.cn/') {
|
|
206
288
|
return new Promise((reslove, reject) => {
|
|
207
289
|
let fullUrl = baseUrl + url;
|
|
208
|
-
wx.showLoading("上传中");
|
|
209
290
|
wx.uploadFile({
|
|
210
291
|
url: fullUrl,
|
|
211
292
|
filePath: path,
|
|
212
|
-
name:
|
|
293
|
+
name: 'file',
|
|
213
294
|
formData: data,
|
|
214
295
|
header: {
|
|
215
|
-
|
|
216
|
-
|
|
296
|
+
'Content-Type': 'multipart/form-data',
|
|
297
|
+
'wow-token': 'c9fbecb5fdeecb78e8745db9225d88e1',
|
|
217
298
|
},
|
|
218
|
-
success:
|
|
299
|
+
success: res => {
|
|
219
300
|
let result = JSON.parse(res.data);
|
|
220
|
-
if (result.code ==
|
|
221
|
-
reslove(
|
|
301
|
+
if (result.code == '0000') {
|
|
302
|
+
reslove({
|
|
303
|
+
url: result.data[0],
|
|
304
|
+
tempFilePath: path, // 原始文件路径
|
|
305
|
+
});
|
|
222
306
|
} else {
|
|
223
|
-
reject(
|
|
307
|
+
reject({
|
|
308
|
+
errMsg: result.msg,
|
|
309
|
+
tempFilePath: path,
|
|
310
|
+
});
|
|
224
311
|
}
|
|
225
312
|
},
|
|
226
|
-
fail:
|
|
313
|
+
fail: err => {
|
|
227
314
|
wx.showToast({
|
|
228
315
|
title: '上传失败',
|
|
229
|
-
icon:
|
|
230
|
-
})
|
|
231
|
-
reject(
|
|
316
|
+
icon: 'error',
|
|
317
|
+
});
|
|
318
|
+
reject({
|
|
319
|
+
errMsg: err.errMsg,
|
|
320
|
+
tempFilePath: path,
|
|
321
|
+
});
|
|
232
322
|
},
|
|
233
323
|
});
|
|
234
324
|
});
|
|
@@ -237,15 +327,14 @@ Component({
|
|
|
237
327
|
uploadImage_v(filePaths) {
|
|
238
328
|
return new Promise((resolve, reject) => {
|
|
239
329
|
const { url, fileDir, ...header } = this.properties.uploadApi;
|
|
240
|
-
wx.showLoading({title: "上传中", mask: true});
|
|
241
330
|
utils.newHttp(
|
|
242
331
|
url,
|
|
243
|
-
|
|
332
|
+
'GET',
|
|
244
333
|
{
|
|
245
|
-
dir: fileDir ||
|
|
334
|
+
dir: fileDir || 'microComponents',
|
|
246
335
|
},
|
|
247
336
|
header,
|
|
248
|
-
|
|
337
|
+
res => {
|
|
249
338
|
const { host, signature, accessKeyId, policy, dir } = res.data;
|
|
250
339
|
if (host) {
|
|
251
340
|
let path = filePaths;
|
|
@@ -253,40 +342,38 @@ Component({
|
|
|
253
342
|
wx.uploadFile({
|
|
254
343
|
url: host,
|
|
255
344
|
filePath: filePaths,
|
|
256
|
-
name:
|
|
345
|
+
name: 'file',
|
|
257
346
|
formData: {
|
|
258
|
-
key: dir +
|
|
347
|
+
key: dir + '/' + name,
|
|
259
348
|
policy,
|
|
260
|
-
success_action_status:
|
|
349
|
+
success_action_status: '200',
|
|
261
350
|
OSSAccessKeyId: accessKeyId,
|
|
262
351
|
signature,
|
|
263
352
|
},
|
|
264
353
|
header: {
|
|
265
354
|
// "Content-Type": "multipart/form-data",
|
|
266
355
|
},
|
|
267
|
-
success:
|
|
356
|
+
success: res => {
|
|
268
357
|
if (res.statusCode == 200) {
|
|
269
|
-
let url = host + dir +
|
|
270
|
-
resolve(
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
// icon: "success",
|
|
275
|
-
// title: "上传成功",
|
|
276
|
-
// });
|
|
358
|
+
let url = host + dir + '/' + name;
|
|
359
|
+
resolve({
|
|
360
|
+
url: url,
|
|
361
|
+
tempFilePath: path, // 原始文件路径
|
|
362
|
+
});
|
|
277
363
|
}
|
|
278
364
|
},
|
|
279
|
-
fail:
|
|
280
|
-
reject(
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
// title: err.errMsg || "网络错误,请重试",
|
|
285
|
-
// });
|
|
365
|
+
fail: err => {
|
|
366
|
+
reject({
|
|
367
|
+
errMsg: err.errMsg || '网络错误,请重试',
|
|
368
|
+
tempFilePath: path,
|
|
369
|
+
});
|
|
286
370
|
},
|
|
287
371
|
});
|
|
288
372
|
} else {
|
|
289
|
-
reject(
|
|
373
|
+
reject({
|
|
374
|
+
errMsg: res.message || '网络错误,请重试',
|
|
375
|
+
tempFilePath: filePaths,
|
|
376
|
+
});
|
|
290
377
|
// _this.onUploadError(res.message);
|
|
291
378
|
}
|
|
292
379
|
}
|
|
@@ -2,21 +2,52 @@
|
|
|
2
2
|
<view class="xt-uploader">
|
|
3
3
|
<view class="title_text" wx:if="{{title}}">{{title}}</view>
|
|
4
4
|
<view class="file_box">
|
|
5
|
-
<view wx:for="{{
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
<view wx:for="{{tempFileList}}" wx:key="index" class="file_wrap">
|
|
6
|
+
<view class="file_item">
|
|
7
|
+
<block wx:if="{{fileType == 'video'}}">
|
|
8
|
+
<video class="file_img" src="{{item.url}}" mode="aspectFill" data-url="{{item.url}}" data-index="{{index}}" />
|
|
9
|
+
<!-- 删除 -->
|
|
10
|
+
<image
|
|
11
|
+
src="https://img.tanjiu.cn/home/idzQXfttSiQryeX3jYEfc5xjWhZPdwY4.png"
|
|
12
|
+
class="close_box"
|
|
13
|
+
mode="aspectFill"
|
|
14
|
+
bindtap="onDelete"
|
|
15
|
+
data-url="{{item.url}}"
|
|
16
|
+
data-index="{{index}}"
|
|
17
|
+
wx:if="{{!disabled}}"
|
|
18
|
+
></image>
|
|
19
|
+
</block>
|
|
20
|
+
<block wx:else>
|
|
21
|
+
<image class="file_img" src="{{item.url}}" mode="aspectFit" bindtap="onPreviewImage" data-url="{{item.url}}" data-index="{{index}}" />
|
|
22
|
+
<!-- 删除 -->
|
|
23
|
+
<image
|
|
24
|
+
src="https://img.tanjiu.cn/home/idzQXfttSiQryeX3jYEfc5xjWhZPdwY4.png"
|
|
25
|
+
class="close_box"
|
|
26
|
+
mode="aspectFill"
|
|
27
|
+
bindtap="onDelete"
|
|
28
|
+
data-url="{{item.url}}"
|
|
29
|
+
data-index="{{index}}"
|
|
30
|
+
wx:if="{{!disabled}}"
|
|
31
|
+
></image>
|
|
32
|
+
</block>
|
|
33
|
+
</view>
|
|
34
|
+
<!-- 上传状态 -->
|
|
35
|
+
<view class="loading-progress" wx:if="{{item.updateStatus == 'uploading'}}">
|
|
36
|
+
<view class="progress-inner"></view>
|
|
37
|
+
</view>
|
|
38
|
+
<view class="upload-progress" wx:if="{{item.updateStatus == 'uploading'}}">{{item.fileType == 'video'? '视频':'照片'}}上传中</view>
|
|
39
|
+
|
|
40
|
+
<view class="upload-success" wx:elif="{{item.updateStatus == 'success'}}">
|
|
41
|
+
<image class="icon" src="https://img.tanjiu.cn/home/DziAN8B4eaB6r2h4WX7b55Zj6F4WW4Kn.png"></image> {{item.fileType == 'video'? '视频':'照片'}}上传成功
|
|
42
|
+
</view>
|
|
43
|
+
<view class="upload-failed" wx:elif="{{item.updateStatus == 'failed'}}">
|
|
44
|
+
<image class="icon" src="https://img.tanjiu.cn/home/dtBtxsJYcQbhnbcZN5hKCyiFkS3TFiHy.png"></image>
|
|
45
|
+
<view bind:tap="reUpload" data-item="{{item}}"> 上传失败,<text class="reupload">重新上传</text> </view>
|
|
46
|
+
</view>
|
|
16
47
|
</view>
|
|
17
48
|
<view class="file_item" wx:if="{{!disabled && fileList.length<max}}" bindtap="startTakePhoto">
|
|
18
49
|
<image src="{{icon}}" class="camera_icon" />
|
|
19
50
|
<view wx:if="{{uploadDesc}}" class="upload_desc">{{uploadDesc}}</view>
|
|
20
51
|
</view>
|
|
21
52
|
</view>
|
|
22
|
-
</view>
|
|
53
|
+
</view>
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
/* src/xt-uploader/index.wxss */
|
|
2
2
|
.xt-uploader {
|
|
3
|
-
background-color
|
|
3
|
+
background-color: #fff;
|
|
4
4
|
/* padding : 32rpx;
|
|
5
5
|
padding-bottom : 0; */
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.title_text {
|
|
9
9
|
line-height: 48rpx;
|
|
10
|
-
font-size
|
|
11
|
-
font-family:
|
|
10
|
+
font-size: 34rpx;
|
|
11
|
+
font-family:
|
|
12
|
+
PingFang SC-Semibold,
|
|
12
13
|
PingFang SC;
|
|
13
|
-
font-weight
|
|
14
|
-
color
|
|
14
|
+
font-weight: 800;
|
|
15
|
+
color: #000000;
|
|
15
16
|
margin-bottom: 16rpx;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
.file_box {
|
|
19
|
-
display
|
|
20
|
+
display: flex;
|
|
20
21
|
flex-wrap: wrap;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
.file_item {
|
|
24
|
-
width
|
|
25
|
-
height
|
|
26
|
-
border-radius
|
|
27
|
-
overflow
|
|
28
|
-
position
|
|
29
|
-
display
|
|
30
|
-
flex-direction
|
|
31
|
-
justify-content
|
|
32
|
-
align-items
|
|
33
|
-
background-color: #
|
|
34
|
-
margin-bottom
|
|
25
|
+
width: 196rpx;
|
|
26
|
+
height: 196rpx;
|
|
27
|
+
border-radius: 8rpx;
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
position: relative;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
background-color: #f5f5f5;
|
|
35
|
+
margin-bottom: 16rpx;
|
|
35
36
|
flex-shrink: 0;
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -40,31 +41,98 @@
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
.camera_icon {
|
|
43
|
-
width
|
|
44
|
+
width: 80rpx;
|
|
44
45
|
height: 80rpx;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
.file_img {
|
|
48
|
-
width
|
|
49
|
+
width: 196rpx;
|
|
49
50
|
height: 196rpx;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
.close_box {
|
|
53
|
-
position
|
|
54
|
+
position: absolute;
|
|
54
55
|
line-height: 48rpx;
|
|
55
|
-
width
|
|
56
|
-
height
|
|
57
|
-
top
|
|
58
|
-
right
|
|
59
|
-
color
|
|
56
|
+
width: 48rpx;
|
|
57
|
+
height: 48rpx;
|
|
58
|
+
top: 0;
|
|
59
|
+
right: 0;
|
|
60
|
+
color: rgba(0, 0, 0, 0.5);
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
.upload_desc {
|
|
63
64
|
line-height: 40rpx;
|
|
64
|
-
font-size
|
|
65
|
-
font-family:
|
|
65
|
+
font-size: 28rpx;
|
|
66
|
+
font-family:
|
|
67
|
+
PingFang SC-Regular,
|
|
66
68
|
PingFang SC;
|
|
67
69
|
font-weight: 400;
|
|
68
|
-
color
|
|
69
|
-
margin-top
|
|
70
|
-
}
|
|
70
|
+
color: #727272;
|
|
71
|
+
margin-top: 8rpx;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.loading-progress {
|
|
75
|
+
width: 100%;
|
|
76
|
+
height: 20rpx;
|
|
77
|
+
background-color: #eee;
|
|
78
|
+
border-radius: 10rpx;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
position: relative;
|
|
81
|
+
}
|
|
82
|
+
.progress-inner {
|
|
83
|
+
height: 100%;
|
|
84
|
+
background-color: #6722ab;
|
|
85
|
+
width: 0;
|
|
86
|
+
border-radius: 10rpx 0 0 10rpx;
|
|
87
|
+
animation: loadProgress 20s forwards ease-in-out;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.upload-progress {
|
|
91
|
+
opacity: 0.8;
|
|
92
|
+
font-size: 28rpx;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.upload-success {
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
gap: 2rpx;
|
|
100
|
+
font-family:
|
|
101
|
+
PingFang SC,
|
|
102
|
+
PingFang SC;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
font-size: 18rpx;
|
|
105
|
+
color: #30bf67;
|
|
106
|
+
line-height: 26rpx;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.upload-success .icon {
|
|
110
|
+
width: 24rpx;
|
|
111
|
+
height: 24rpx;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.upload-failed {
|
|
115
|
+
font-family:
|
|
116
|
+
PingFang SC,
|
|
117
|
+
PingFang SC;
|
|
118
|
+
font-weight: 600;
|
|
119
|
+
font-size: 18rpx;
|
|
120
|
+
color: #ff4d4d;
|
|
121
|
+
line-height: 26rpx;
|
|
122
|
+
text-align: center;
|
|
123
|
+
}
|
|
124
|
+
.upload-failed .icon {
|
|
125
|
+
width: 24rpx;
|
|
126
|
+
height: 24rpx;
|
|
127
|
+
}
|
|
128
|
+
.reupload {
|
|
129
|
+
text-decoration: underline;
|
|
130
|
+
}
|
|
131
|
+
@keyframes loadProgress {
|
|
132
|
+
from {
|
|
133
|
+
width: 0;
|
|
134
|
+
}
|
|
135
|
+
to {
|
|
136
|
+
width: 100%;
|
|
137
|
+
}
|
|
138
|
+
}
|