mali-applet-ui 1.0.27 → 1.0.28
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,6 +69,25 @@ function normalizeChooseAndUploadFileRes (res, fileType) {
|
|
|
69
69
|
return res
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
function compressImages (tempFiles) {
|
|
73
|
+
return Promise.all(
|
|
74
|
+
tempFiles.map(tempFilePath => {
|
|
75
|
+
return new Promise(resolve => {
|
|
76
|
+
uni.compressImage({
|
|
77
|
+
src: tempFilePath,
|
|
78
|
+
quality: this.imageQuality,
|
|
79
|
+
success (compressRes) {
|
|
80
|
+
resolve(compressRes.tempFilePath)
|
|
81
|
+
},
|
|
82
|
+
fail () {
|
|
83
|
+
resolve(tempFilePath)
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
})
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
function uploadImageFiles (opts) {
|
|
73
92
|
return new Promise((resolve, reject) => {
|
|
74
93
|
uni.chooseImage({
|
|
@@ -77,8 +96,18 @@ function uploadImageFiles (opts) {
|
|
|
77
96
|
// #ifdef MP-WEIXIN
|
|
78
97
|
sizeType: opts.sizeType,
|
|
79
98
|
// #endif
|
|
80
|
-
success (
|
|
81
|
-
|
|
99
|
+
success (chooseRes) {
|
|
100
|
+
const rest = normalizeChooseAndUploadFileRes(chooseRes, 'image')
|
|
101
|
+
if (this.imageQuality) {
|
|
102
|
+
compressImages(rest.tempFiles).then((compressFiles) => {
|
|
103
|
+
resolve({
|
|
104
|
+
...rest,
|
|
105
|
+
tempFiles: compressFiles
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
} else {
|
|
109
|
+
resolve(rest)
|
|
110
|
+
}
|
|
82
111
|
},
|
|
83
112
|
fail (res) {
|
|
84
113
|
reject(res)
|
|
@@ -150,6 +179,7 @@ export default {
|
|
|
150
179
|
type: Object,
|
|
151
180
|
default: () => ({})
|
|
152
181
|
},
|
|
182
|
+
imageQuality: Number,
|
|
153
183
|
sizeType: {
|
|
154
184
|
type: Array,
|
|
155
185
|
default: () => ['original', 'compressed']
|