sadais-piui 1.2.7-beta48 → 1.2.7-beta49

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.
@@ -228,7 +228,6 @@ export default {
228
228
  this.$emit('load')
229
229
  },
230
230
  handleLoad() {
231
- console.log(TAG, '图片加载成功')
232
231
  this.error = false
233
232
  this.loading = false
234
233
  this.$emit('load')
@@ -1,10 +1,10 @@
1
1
  <!--
2
2
  * @Author: zhangzhenfei
3
3
  * @Date: 2021-08-13 11:31:57
4
- * @LastEditTime: 2022-07-21 11:25:37
4
+ * @LastEditTime: 2022-11-03 12:11:22
5
5
  * @LastEditors: zhangzhenfei
6
6
  * @Description: 图片上传组件
7
- * @FilePath: /dt-weitibao-console/Users/feilin/workspace/piui/piui-awesome/src/piui/components/pi-upload-img/index.vue
7
+ * @FilePath: \sadais-visitor-mp\node_modules\sadais-piui\components\pi-upload-img\index.vue
8
8
  -->
9
9
 
10
10
  <template>
@@ -291,6 +291,13 @@ export default {
291
291
  fn: uploadImg.beforeRemove
292
292
  }
293
293
  }
294
+ },
295
+ // 压缩参数
296
+ compressOption: {
297
+ type: Object,
298
+ default() {
299
+ return uploadImg.compressOption
300
+ }
294
301
  }
295
302
  },
296
303
  data() {
@@ -460,6 +467,26 @@ export default {
460
467
  this.showCrop = false
461
468
  this.handleUpload([this.cropedPic])
462
469
  },
470
+ async handleCompressImgs(tempFilePaths) {
471
+ const compressUrls = []
472
+
473
+ for (let index = 0; index < tempFilePaths.length; index++) {
474
+ const url = tempFilePaths[index]
475
+ const [, result] = await uni.compressImage({
476
+ src: url,
477
+ ...this.compressOption
478
+ })
479
+ const { errMsg, tempFilePath } = result
480
+ if (errMsg == 'compressImage:ok' && tempFilePath && typeof tempFilePath == 'string') {
481
+ compressUrls.push(tempFilePath)
482
+ console.log(TAG, '压缩图片成功', tempFilePath, 'src=' + url)
483
+ } else {
484
+ compressUrls.push(url)
485
+ console.log(TAG, '压缩图片成功', tempFilePath, 'src=' + url)
486
+ }
487
+ }
488
+ return compressUrls
489
+ },
463
490
  async handleChooseImage() {
464
491
  if (this.disabled || !this.getUploadMaxCount) return
465
492
  // 检查上传地址
@@ -484,6 +511,12 @@ export default {
484
511
  if (errMsg !== 'chooseImage:ok') {
485
512
  throw new Error(errMsg)
486
513
  }
514
+ // #ifndef H5
515
+ // 压缩图片
516
+ if (this.compressOption && this.$pi.system.systemInfo.platform !== 'devtools') {
517
+ tempFilePaths = await this.handleCompressImgs(tempFilePaths)
518
+ }
519
+ // #endif
487
520
  if (this.getUploadMaxCount === 1 && this.crop && tempFilePaths.length === 1) {
488
521
  // 单张图片设置了剪裁
489
522
  this.showCrop = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sadais-piui",
3
- "version": "1.2.7beta48",
3
+ "version": "1.2.7beta49",
4
4
  "description": "piui组件库",
5
5
  "main": "index.js",
6
6
  "scripts": {