Commit d04b2dc8 authored by Mac's avatar Mac

榜单报名图片的上传判断修改

parent 821644c6
...@@ -236,17 +236,6 @@ ...@@ -236,17 +236,6 @@
let listOldLength = this.lists.length; let listOldLength = this.lists.length;
let that = this let that = this
res.tempFiles.forEach((val, index) => { res.tempFiles.forEach((val, index) => {
uni.getImageInfo({
src: val.path,
success: function (image) {
if(image.width>image.height){
uni.showToast({
title:'请上传竖版图片',
icon:'none'
})
}else{
// 如果是非多选,index大于等于1或者超出最大限制数量时,不处理 // 如果是非多选,index大于等于1或者超出最大限制数量时,不处理
if (!multiple && index >= 1) return; if (!multiple && index >= 1) return;
if(val.size< (2*1024*1024)){ if(val.size< (2*1024*1024)){
...@@ -254,36 +243,73 @@ ...@@ -254,36 +243,73 @@
title:'图片不能小于2M', title:'图片不能小于2M',
icon:'none' icon:'none'
}) })
}else if (val.size > maxSize) { }else if(val.size > maxSize) {
that.$emit('on-oversize', val, that.lists); console.log(val.size,maxSize)
that.showToast('超出允许的文件大小'); this.$emit('on-oversize', val, this.lists);
this.showToast('超出允许的文件大小');
} else { } else {
if(maxCount <= that.lists.length) { if(maxCount <= lists.length) {
that.$emit('on-exceed', val, that.lists); this.$emit('on-exceed', val, this.lists);
that.showToast('超出最大允许的文件个数'); this.showToast('超出最大允许的文件个数');
return ; return ;
} }
that.lists.push({ lists.push({
url: val.path, url: val.path,
progress: 0, progress: 0,
error: false error: false
}); });
// 列表发生改变,发出事件,第二个参数为当前发生变化的项的索引 // 列表发生改变,发出事件,第二个参数为当前发生变化的项的索引
that.$emit('on-list-change', that.lists); this.$emit('on-list-change', this.lists);
}
//图片长宽的判断
// uni.getImageInfo({
// src: val.path,
// success: function (image) {
// if(image.width>image.height){
// uni.showToast({
// title:'请上传竖版图片',
// icon:'none'
// })
that.$emit('on-choose-complete', that.lists); // }else{
// // 如果是非多选,index大于等于1或者超出最大限制数量时,不处理
// if (!multiple && index >= 1) return;
// if(val.size< (2*1024*1024)){
// uni.showToast({
// title:'图片不能小于2M',
// icon:'none'
// })
// }else if (val.size > maxSize) {
// that.$emit('on-oversize', val, that.lists);
// that.showToast('超出允许的文件大小');
// } else {
// if(maxCount <= that.lists.length) {
// that.$emit('on-exceed', val, that.lists);
// that.showToast('超出最大允许的文件个数');
// return ;
// }
// that.lists.push({
// url: val.path,
// progress: 0,
// error: false
// });
if(that.autoUpload) that.uploadFile(listOldLength); // // 列表发生改变,发出事件,第二个参数为当前发生变化的项的索引
listOldLength++ // that.$emit('on-list-change', that.lists);
}
} // that.$emit('on-choose-complete', that.lists);
// if(that.autoUpload) that.uploadFile(listOldLength);
// listOldLength++
// }
// }
// },
// fail:function(err){
// console.log(err)
// }
// })
},
fail:function(err){
console.log(err)
}
})
}) })
// 每次图片选择完,抛出一个事件,并将当前内部选择的图片数组抛出去 // 每次图片选择完,抛出一个事件,并将当前内部选择的图片数组抛出去
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment