From ec63526c30dad8fbc55823d7d5418b05237de6ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A1=94=E5=AD=90?= Date: Tue, 6 Apr 2021 22:05:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(ImagePicker):=20=E4=BF=AE=E5=A4=8D=20linove?= =?UTF-8?q?rsize=20=E4=BA=8B=E4=BB=B6=E6=AF=8F=E6=AC=A1=E9=83=BD=E4=BC=9A?= =?UTF-8?q?=E8=A2=AB=E8=A7=A6=E5=8F=91=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit close #1352 --- src/image-picker/index.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/image-picker/index.js b/src/image-picker/index.js index fe96e1b1..fa0334f0 100644 --- a/src/image-picker/index.js +++ b/src/image-picker/index.js @@ -1,7 +1,7 @@ import nodeUtil from '../core/utils/node-util'; import deviceUtil from '../utils/device-util'; import eventUtil from '../core/utils/event-util'; -import {promisic} from '../utils/util'; +import { promisic } from '../utils/util'; Component({ @@ -135,7 +135,7 @@ Component({ */ async size(size) { if (!size) { - this.setData({itemSizePercentage: null}); + this.setData({ itemSizePercentage: null }); return; } @@ -145,7 +145,7 @@ Component({ // 根据容器宽度计算单张图片宽度百分比 const itemSizePercentage = ((10 / size * 10) - 20 / widthRpx * 100) + '%;'; - this.setData({itemSizePercentage}); + this.setData({ itemSizePercentage }); }, custom(custom) { @@ -215,7 +215,7 @@ Component({ * @returns {Promise} */ async onTapAdd() { - let {value, count, sizeType, maxImageSize} = this.data; + let { value, count, sizeType, maxImageSize } = this.data; const remainCount = count - value.length; if (value.length >= count || remainCount <= 0) { return; @@ -234,7 +234,7 @@ Component({ const oversizeImageUrlArray = []; chooseImageRes.tempFiles.forEach((tempFile) => { - const {path, size} = tempFile; + const { path, size } = tempFile; if (size > maxImageSize && maxImageSize > 0) { oversizeImageUrlArray.push(path); } else { @@ -255,7 +255,9 @@ Component({ // todo 1.0.0 版本去除 linchange 事件 eventUtil.emit(this, 'linchange', detail); // todo 1.0.0 版本去除 linoversize 事件 - eventUtil.emit(this, 'linoversize', detail); + if (oversizeImageUrlArray.length > 0) { + eventUtil.emit(this, 'linoversize', detail); + } }); }, @@ -283,7 +285,7 @@ Component({ current, all: value }; - this.setData({value}, () => { + this.setData({ value }, () => { eventUtil.emit(this, 'linremove', detail); }); },