mali-applet-ui 1.0.28 → 1.0.30
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.
|
@@ -69,18 +69,21 @@ function normalizeChooseAndUploadFileRes (res, fileType) {
|
|
|
69
69
|
return res
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function compressImages (tempFiles) {
|
|
72
|
+
function compressImages (tempFiles, opts) {
|
|
73
73
|
return Promise.all(
|
|
74
|
-
tempFiles.map(
|
|
74
|
+
tempFiles.map(item => {
|
|
75
75
|
return new Promise(resolve => {
|
|
76
76
|
uni.compressImage({
|
|
77
|
-
src:
|
|
78
|
-
quality:
|
|
77
|
+
src: item.path,
|
|
78
|
+
quality: opts.quality || 80,
|
|
79
79
|
success (compressRes) {
|
|
80
|
-
resolve(
|
|
80
|
+
resolve({
|
|
81
|
+
...item,
|
|
82
|
+
path: compressRes.tempFilePath
|
|
83
|
+
})
|
|
81
84
|
},
|
|
82
85
|
fail () {
|
|
83
|
-
resolve(
|
|
86
|
+
resolve(item)
|
|
84
87
|
}
|
|
85
88
|
})
|
|
86
89
|
})
|
|
@@ -98,8 +101,9 @@ function uploadImageFiles (opts) {
|
|
|
98
101
|
// #endif
|
|
99
102
|
success (chooseRes) {
|
|
100
103
|
const rest = normalizeChooseAndUploadFileRes(chooseRes, 'image')
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
// 如果是图片类型,支持压缩比例
|
|
105
|
+
if (opts.quality) {
|
|
106
|
+
compressImages(rest.tempFiles, opts).then((compressFiles) => {
|
|
103
107
|
resolve({
|
|
104
108
|
...rest,
|
|
105
109
|
tempFiles: compressFiles
|
|
@@ -467,7 +471,8 @@ export default {
|
|
|
467
471
|
chooseMethod({
|
|
468
472
|
sizeType: this.sizeType,
|
|
469
473
|
sourceType: this.sourceType,
|
|
470
|
-
count: this.limit - this.fileList.length
|
|
474
|
+
count: this.limit - this.fileList.length,
|
|
475
|
+
quality: this.imageQuality
|
|
471
476
|
}).then(res => {
|
|
472
477
|
const { tempFiles } = res
|
|
473
478
|
this.loading = true
|