From 910572f2c2bbd678c3983db0ca4a293fa5c0dd33 Mon Sep 17 00:00:00 2001
From: Tevin <tingquanren@163.com>
Date: Thu, 17 Aug 2023 16:01:04 +0800
Subject: [PATCH] 页面筛选组件,增加单项开关子组件

---
 forms/imagePicker/CImageCompressor.vue |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/forms/imagePicker/CImageCompressor.vue b/forms/imagePicker/CImageCompressor.vue
index 4bd1862..a0106dd 100644
--- a/forms/imagePicker/CImageCompressor.vue
+++ b/forms/imagePicker/CImageCompressor.vue
@@ -20,6 +20,12 @@
 
 export default {
     name: 'CImageCompressor',
+    props: {
+        maxSize: {
+            type: Number,
+            default: 1600,
+        },
+    },
     data() {
         return {
             // canvas id
@@ -33,6 +39,7 @@
     },
     methods: {
         $compress(tempPaths, callback) {
+            this.imgBlobs = []; // 重置已转图片
             if (typeof this.canvasContext === 'undefined') {
                 this.canvasContext = Taro.createCanvasContext(this.cavId, this);
             }
@@ -46,7 +53,7 @@
                     }
                     // 完成图片压缩
                     else {
-                        console.log(this.imgBlobs);
+                        callback(this.imgBlobs);
                     }
                 });
             };
@@ -73,12 +80,12 @@
             let width, height;
             // 宽大于高,按宽算
             if (res.width >= res.height) {
-                width = Math.min(res.width, 1600);
+                width = Math.min(res.width, this.maxSize);
                 height = Math.round(width / rate);
             }
             // 按高算
             else {
-                height = Math.min(res.height, 1600);
+                height = Math.min(res.height, this.maxSize);
                 width = Math.round(height * rate);
             }
             return [width, height];

--
Gitblit v1.9.1