Fix:2510 【商城小程序】店铺主页-发布动态,一次性上传多张图片时最后几张会显示上传进度为0%,但点击发布后所有图片都能正常在资讯显示

This commit is contained in:
linxi
2024-10-22 09:26:21 +08:00
parent 246c66193b
commit 1eac768b76
+11 -3
View File
@@ -7,11 +7,11 @@
class="sunui-uploader-file"
/>
<block v-for="(item, index) in upload_before_list" :key="index">
<view class="sunui-uploader-file" :class="[item.upload_percent < 100 ? 'sunui-uploader-file-status' : '']" :style="'width:' + upload_img_wh + 'rpx; height:' + upload_img_wh + 'rpx;'">
<view class="sunui-uploader-file" :class="[item.upload_percent < 100 ? '' : '']" :style="'width:' + upload_img_wh + 'rpx; height:' + upload_img_wh + 'rpx;'">
<image class="sunui-uploader-img" :style="'width:' + upload_img_wh + 'rpx; height:' + upload_img_wh + 'rpx;'" :src="item.path" mode="aspectFill" @tap="preview(index)" v-if="type === 'image'" />
<video :id="`myVideo_${index}`" :src="item.path" :data-index="index" @play="videoPlay" @error="videoError" controls :enable-play-gesture="true" objectFit="contain" :style="'width:' + upload_img_wh + 'rpx; height:' + upload_img_wh + 'rpx;'" v-if="type === 'video'"></video>
<view class="sunui-img-removeicon right" @tap.stop="remove(index)" v-show="upimg_move">x</view>
<view class="sunui-loader-filecontent" v-if="item.upload_percent < 100">{{item.upload_percent}}%</view>
<!-- <view class="sunui-loader-filecontent" v-if="item.upload_percent < 100">{{item.upload_percent}}%</view> -->
</view>
</block>
<view v-show="upload_before_list.length < upload_count" hover-class="sunui-uploader-hover" class="sunui-uploader-inputbox" @tap="choose" :style="'width:' + upload_img_wh + 'rpx; height:' + upload_img_wh + 'rpx;'">
@@ -185,6 +185,7 @@ export default {
if (Math.ceil(res.size / 1024) < this.upload_video_max * 1024) {
await this.upload_img_size.push(Math.ceil(res.size / 1024));
await this.upload_before_list.push(res);
this.$forceUpdate()
} else {
this.upload_exceeded_list.push(1);
@@ -219,6 +220,7 @@ export default {
if (Math.ceil(res.tempFiles[i].size / 1024) < this.upload_max * 1024) {
await this.upload_img_size.push(Math.ceil(res.tempFiles[i].size / 1024));
await this.upload_before_list.push(res.tempFiles[i]);
this.$forceUpdate()
// TODO v3.1增加图片格式限制
} else {
res.tempFilePaths.splice(i, 1);
@@ -239,6 +241,7 @@ export default {
}
this.upload_cache = await res.tempFilePaths;
this.upload(this.upload_auto);
this.$forceUpdate()
},
fail: (err) => {
console.log(err);
@@ -338,7 +341,12 @@ export default {
uploadTask.onProgressUpdate(async (res) => {
// this.upload_before_list[this.upload_before_list.length-1].upload_percent = await res.progress;
for(let i in this.upload_before_list) { if(this.upload_before_list[i].upload_percent != 100) { this.upload_before_list[i].upload_percent = await res.progress; break; } };
for (let i in this.upload_before_list) {
if (this.upload_before_list[i].upload_percent != 100) {
console.log(res.progress, '-----------res.progress-----------');
this.upload_before_list[i].upload_percent = await res.progress
}
};
});
}
}