Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ImagePicker): 修复 linoversize 事件每次都会被触发的问题 #1365

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/image-picker/index.js
Original file line number Diff line number Diff line change
@@ -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({

Expand Down Expand Up @@ -135,7 +135,7 @@ Component({
*/
async size(size) {
if (!size) {
this.setData({itemSizePercentage: null});
this.setData({ itemSizePercentage: null });
return;
}

Expand All @@ -145,7 +145,7 @@ Component({

// 根据容器宽度计算单张图片宽度百分比
const itemSizePercentage = ((10 / size * 10) - 20 / widthRpx * 100) + '%;';
this.setData({itemSizePercentage});
this.setData({ itemSizePercentage });
},

custom(custom) {
Expand Down Expand Up @@ -215,7 +215,7 @@ Component({
* @returns {Promise<void>}
*/
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;
Expand All @@ -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 {
Expand All @@ -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);
}
});
},

Expand Down Expand Up @@ -283,7 +285,7 @@ Component({
current,
all: value
};
this.setData({value}, () => {
this.setData({ value }, () => {
eventUtil.emit(this, 'linremove', detail);
});
},
Expand Down