Commit 7100a624 authored by lvtz's avatar lvtz

Merge branch 'wxl-develop' of git.server:wangxuelai/wechatapp.shangjiadao.com into guide_lvtz

parents 25504edd 7ea5ae6f
......@@ -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
......
......@@ -148,6 +148,8 @@ Page({
loginCode: '',
contentQualified: false, // 所输入内容是否合格
getmobiledialogshow: false,
uploadVideoTask: {
},
},
onLoad: function(options) { // Do some initialize when page load.
this.innerAudioContext = wx.createInnerAudioContext();
......@@ -239,8 +241,10 @@ Page({
audioStorage: {
}
})
if (this.uploadVideoTask) {
this.uploadVideoTask.abort();
for (let i in this.data.uploadVideoTask) {
if (this.data.uploadVideoTask[i]) {
this.data.uploadVideoTask[i].abort();
}
}
clearInterval(this.data.voiceInterval);
},
......@@ -484,6 +488,10 @@ Page({
const {dataset} = e.currentTarget;
const imageBox = this.data.imageBox;
let currentIndex = this.data.currentIndex - 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,
......@@ -509,6 +517,7 @@ Page({
let failVideos = imageBox.filter(ele => (ele.status == 'fail' && ele.type == 'video'));
let fullfilledImages = imageBox.filter(ele => ele.status == 'fullfilled');
let notUploadedImagesAndVideo = imageBox.filter(ele => (ele.status == 'resolving' || ele.status == 'pending'));
console.log(notUploadedImagesAndVideo, 'notUploadedImagesAndVideo');
if (notUploadedImagesAndVideo.length > 0) {
wx.showToast({
title: '您的打卡内容尚未全部上传,请稍后...',
......@@ -516,7 +525,8 @@ Page({
})
return;
}
if (failImages.length > 0 || this.data.videostatus == 'fail') {
// if (failImages.length > 0 || this.data.videostatus == 'fail') {
if (failImages.length > 0) {
let text = '';
text = failImages.length > 0 ? text + `有${failImages.length}个图片上传失败,` : text;
text = failVideos.length > 0 ? text + `${failVideos.length}视频上传失败,` : text;
......@@ -813,8 +823,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,
......@@ -823,8 +834,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,
......@@ -852,17 +862,18 @@ Page({
})
} else {
that.setData({
videostatus: 'fail'
[`imageBox[${videoInsertIndex}].status`]: 'fail'
})
}
},
fail (e) {
that.setData({
videostatus: 'fail'
})
// console.log('失败');
// that.setData({
// [`imageBox[${videoInsertIndex}].status`]: 'fail'
// })
}
})
that.uploadVideoTask.onProgressUpdate((res) => {
that.data.uploadVideoTask[`${filename}`].onProgressUpdate((res) => {
imageBox[videoInsertIndex].videoprogress = res.progress > 95 ? 95 : res.progress;
that.setData({
imageBox: imageBox
......
......@@ -282,6 +282,7 @@ Page({
},
generatePoster (e) {
const {dataset} = e.currentTarget;
console.log(this.data.posterBox);
if (this.data.posterBox[this.data.currentIndex]) {
wx.previewImage({
current: this.data.posterBox[this.data.currentIndex], // 当前显示图片的链接,不填则默认为 urls 的第一张
......
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