Commit 7ea5ae6f authored by wangxuelai's avatar wangxuelai

''

parent 7917bc6c
......@@ -143,6 +143,7 @@ Page({
scoreTempArr: [],
imgInfoList:[],
tempFilesImgs:[],// 标记图片返回的本地图片
uploadVideoTask: {},
},
chooseAverageScore () {
......@@ -274,6 +275,11 @@ Page({
audioStorage: {
}
})
for (let i in this.data.uploadVideoTask) {
if (this.data.uploadVideoTask[i]) {
this.data.uploadVideoTask[i].abort();
}
}
clearInterval(this.data.voiceInterval);
},
onPullDownRefresh: function () { // Do something when pull down.
......@@ -1328,7 +1334,11 @@ Page({
const {dataset} = e.currentTarget;
const imageBox = this.data.imageBox;
let currentIndex = this.data.currentIndex - 1;
imageBox.splice(dataset.index, 1)
if (imageBox[dataset.index].type == 'video') {
this.data.uploadVideoTask[imageBox[dataset.index].src].abort();
delete this.data.uploadVideoTask[imageBox[dataset.index].src];
}
imageBox.splice(dataset.index, 1);
this.setData({
imageBox,
currentIndex
......@@ -1415,8 +1425,9 @@ Page({
}
let imageBox = this.data.imageBox
let videoInsertIndex = imageBox.filter(ele => ele.type == 'video').length;
filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
imageBox.splice(videoInsertIndex, 0, {
src: tempFilePath,
src: filename,
status: 'resolving',
type: 'video',
size: size,
......@@ -1425,8 +1436,7 @@ Page({
that.setData({
imageBox
})
filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
that.uploadVideoTask = wx.uploadFile({
that.data.uploadVideoTask[filename] = wx.uploadFile({
url: access.host,
formData: {
key: filename,
......@@ -1450,17 +1460,14 @@ Page({
})
} else {
that.setData({
videostatus: 'fail'
})
[`imageBox[${videoInsertIndex}].status`]: 'fail',
});
}
},
fail () {
that.setData({
videostatus: 'fail'
})
}
})
that.uploadVideoTask.onProgressUpdate((res) => {
that.data.uploadVideoTask[filename].onProgressUpdate((res) => {
imageBox[videoInsertIndex].videoprogress = res.progress > 95 ? 95 : res.progress;
that.setData({
imageBox: imageBox
......
......@@ -488,10 +488,7 @@ Page({
const {dataset} = e.currentTarget;
const imageBox = this.data.imageBox;
let currentIndex = this.data.currentIndex - 1;
console.log(imageBox, 'imageBox');
if (imageBox[dataset.index].type == 'video') {
console.log(this.data.uploadVideoTask, 'this.data.uploadVideoTask');
console.log(imageBox[dataset.index].src, 'imageBox[dataset.index].src');
this.data.uploadVideoTask[imageBox[dataset.index].src].abort();
delete this.data.uploadVideoTask[imageBox[dataset.index].src];
}
......
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