mali-applet-ui 0.2.76 → 0.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.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="ml-upload" :class="[className || '']">
2
+ <view class="ml-upload" :class="[className || '', {'is-loading': loading}]">
3
3
  <!-- 上传图片 -->
4
4
  <view v-if="mediatype === 'image'" class="ml-upload-image-list">
5
5
  <view class="ml-upload-image-item" v-for="(item, index) in fileList" :key="index">
@@ -8,22 +8,26 @@
8
8
  <ml-icon name="close" />
9
9
  </view>
10
10
  </view>
11
- <view v-if="!isFromReadonly" class="ml-upload-image-add">
11
+ <view v-if="!isFromReadonly && fileList.length < limit" class="ml-upload-image-add">
12
12
  <view class="ml-upload-image-add-btn" @tap="chooseEvent">
13
13
  <view class="ml-upload-image-add-icon">
14
- <ml-icon name="add" />
14
+ <ml-icon v-if="loading" name="loading" roll />
15
+ <ml-icon v-else name="add" />
16
+ <view v-if="loading" class="ml-upload-image-add-loading-text">上传中...</view>
15
17
  </view>
16
18
  </view>
17
19
  </view>
18
20
  </view>
19
21
  <!-- 上传文件 -->
20
22
  <view v-else class="ml-upload-file-list">
21
- <view v-if="!isFromReadonly" class="ml-upload-file-add">
23
+ <view v-if="!isFromReadonly && fileList.length < limit" class="ml-upload-file-add">
22
24
  <view class="ml-upload-file-add-btn" @tap="chooseEvent">
23
25
  <text class="ml-upload-file-add-icon">
24
- <ml-icon name="add" />
26
+ <ml-icon v-if="loading" name="loading" roll />
27
+ <ml-icon v-else name="add" />
25
28
  </text>
26
- <text>添加文件</text>
29
+ <text v-if="loading">上传中...</text>
30
+ <text v-else>添加文件</text>
27
31
  </view>
28
32
  </view>
29
33
  <view class="ml-upload-file-item" v-for="(item, index) in fileList" :key="index">
@@ -41,7 +45,7 @@
41
45
  </view>
42
46
  <view v-if="!isFromReadonly" class="ml-upload-file-right">
43
47
  <view class="ml-upload-file-del-btn" @click="removeEvent(item)">
44
- <ml-icon name="close" />
48
+ <ml-icon name="close" />
45
49
  </view>
46
50
  </view>
47
51
  </view>
@@ -53,7 +57,7 @@
53
57
  import XEUtils from 'xe-utils'
54
58
  import globalStore from '../../config/store'
55
59
  import { uploadAllFiles, uploadImageFiles } from './file-handle'
56
-
60
+
57
61
  export default {
58
62
  name: 'MlUpload',
59
63
  props: {
@@ -106,6 +110,7 @@ export default {
106
110
  },
107
111
  data () {
108
112
  return {
113
+ loading: false,
109
114
  fileList: [],
110
115
  docsTypes: ['doc', 'xls', 'ppt', 'pdf', 'docx', 'xlsx', 'pptx'],
111
116
  imgTypes: ['png', 'jpg']
@@ -286,6 +291,9 @@ export default {
286
291
  itemList: ['保存图片']
287
292
  }
288
293
  })
294
+ },
295
+ fail (e) {
296
+ console.log(e)
289
297
  }
290
298
  })
291
299
  },
@@ -333,6 +341,9 @@ export default {
333
341
  title: '文件已保存:' + res.savedFilePath, //保存路径
334
342
  duration: 3000,
335
343
  })
344
+ },
345
+ fail (e) {
346
+ console.log(e)
336
347
  }
337
348
  })
338
349
  },
@@ -340,20 +351,24 @@ export default {
340
351
  uni.showModal({
341
352
  content: '下载失败',
342
353
  showCancel: false
343
- });
354
+ })
344
355
  }
345
356
  })
346
357
  },
347
358
  chooseEvent () {
359
+ if (this.loading) {
360
+ return
361
+ }
348
362
  let chooseMethod = uploadAllFiles
349
363
  if (this.mediatype === 'image') {
350
364
  chooseMethod = uploadImageFiles
351
365
  }
352
366
  const uploadMethod = this.uploadFile ? this.uploadFile : (globalStore.upload ? globalStore.upload.uploadFile : null)
353
367
  chooseMethod({
354
- count: this.limit
368
+ count: this.limit - this.fileList.length
355
369
  }).then(res => {
356
370
  const { tempFiles } = res
371
+ this.loading = true
357
372
  Promise.all(
358
373
  tempFiles.map(file => {
359
374
  const fileSuffix = this.getSuffix(file.name)
@@ -383,9 +398,13 @@ export default {
383
398
  this.fileList.push(...list)
384
399
  this.isUpdate = true
385
400
  this.updateModel()
401
+ this.loading = false
386
402
  }).catch((e) => {
387
403
  console.log(e)
404
+ this.loading = false
388
405
  })
406
+ }).catch(e => {
407
+ console.log(e)
389
408
  })
390
409
  }
391
410
  }
@@ -427,12 +446,23 @@ export default {
427
446
  .ml-upload-image-add-btn {
428
447
  width: 120rpx;
429
448
  height: 120rpx;
430
- line-height: 120rpx;
431
449
  font-size: 60rpx;
432
450
  color: #c8c8c9;
433
451
  border: 1px dashed #c8c8c9;
434
452
  border-radius: $ml-border-radius;
435
453
  }
454
+ .ml-upload-image-add-icon {
455
+ width: 100%;
456
+ height: 100%;
457
+ display: flex;
458
+ flex-direction: column;
459
+ align-items: center;
460
+ justify-content: center;
461
+ text-align: center;
462
+ }
463
+ .ml-upload-image-add-loading-text {
464
+ font-size: 24rpx;
465
+ }
436
466
  .ml-upload-image-img {
437
467
  width: 120rpx;
438
468
  height: 120rpx;
@@ -469,6 +499,9 @@ export default {
469
499
  border: 1px dashed #c8c8c9;
470
500
  border-radius: $ml-border-radius;
471
501
  }
502
+ .ml-upload-file-add-icon {
503
+ margin-right: 10rpx;
504
+ }
472
505
  .ml-upload-file-del-btn {
473
506
  width: 40rpx;
474
507
  height: 40rpx;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mali-applet-ui",
3
- "version": "0.2.76",
3
+ "version": "0.2.78",
4
4
  "description": "码里云小程序组件库",
5
5
  "scripts": {
6
6
  "release": "node script/release.js && npm publish"