Commit 8ab90d40 authored by wangxuelai's avatar wangxuelai

's'

parent 8636be9c
......@@ -225,7 +225,7 @@ Component({
const customerId = LocalStorage.getItem('visitor') && LocalStorage.getItem('visitor').studentId;
const that = this;
wx.navigateTo({
url: `/src/pages/commenteditor/index?id=${that.data.cid}&ptype=2&&tid=${that.data.tid}&cid=${that.data.clock.id}&eid=${dataset.eid}&roottype=${dataset.roottype}`,
url: `/src/pages/commenteditor/index?id=${that.data.cid}&ptype=2&tid=${that.data.tid}&cid=${that.data.clock.id}&eid=${dataset.eid}&roottype=${dataset.roottype}&sid=${this.data.clock.school_id}`,
})
},
// 关于老师的点评回复操作
......
......@@ -35,7 +35,8 @@ Page({
imageRoot: app.globalData.imageRoot,
imageVersion: app.globalData.imageVersion,
tid: 0, // 主题ID
cid: 0, // 打卡记录ID
cid: 0, // 打卡记录ID\
sid: 0,
maxLength: 200,
maxImgCount: 9,
maxVideoCount: 9,
......@@ -87,13 +88,14 @@ Page({
},
},
onLoad: function(options) { // Do some initialize when page load.
const {cid, tid,ptype, eid, roottype} = options;
const {sid, cid, tid,ptype, eid, roottype} = options;
this.setData({
cid,
tid,
p_type: ptype,
pid: eid,
roottype
roottype,
sid
})
},
onShow: function() { // Do something when page show.
......@@ -123,9 +125,13 @@ Page({
})
},
addImg () { // 添加图片的操作
addImg (e, wxFile) { // 添加图片的操作
let imgCount = this.data.imageBox.filter(ele => ele.type == 'image').length;
if (imgCount >= this.data.maxImgCount) { // 当等于10条了不能继续添加
wx.showToast({
title: `上传图片不能超过${this.data.maxImgCount}张`,
icon: 'none'
})
return
} else {
if (!this.data.imageUploaded) {
......@@ -146,12 +152,17 @@ Page({
this.setData({
imageUploaded: false
})
cOssAccess().then((acc) => {
access = acc.data;
return wxChooseImage({
let myPromise = null;
if (wxFile) {
myPromise = new Promise((resolve) => {
resolve(wxFile);
})
} else {
myPromise = wxChooseImage({
count: this.data.maxImgCount - imgCount
})
}).then((res) => {
}
myPromise.then((res) => {
const {tempFiles} = res;
let imageBox = this.data.imageBox;
this.setData({
......@@ -178,47 +189,65 @@ Page({
this.setData({
imageBox: res.imageBox,
})
this.singleUploadFile(access)
this.singleUploadFile()
}).catch((e) => {
wx.hideLoading()
})
},
singleUploadFile(access) {
singleUploadFile() {
wx.showLoading({
title: '图片上传中...',
mask: true
})
let access = {};
let imageBox = this.data.imageBox;
if (this.data.currentIndex == (imageBox.length)) {
wx.hideLoading();
this.setData({
imageUploaded: true
})
if (this.data.activtySchoolInfo.plan == 'planb' && this.data.activtySchoolInfo.tid == this.data.tid) {
this.judgeContentQualified();
}
return;
}
let filename = `${access.dir}${getRandomFilename(imageBox[this.data.currentIndex].src)}`;
imageBox[this.data.currentIndex].status = 'resolving';
this.setData({
imageBox
})
wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
const path = imageBox[this.data.currentIndex].src;
const fileType = path.substr(path.lastIndexOf('.') + 1);
cOssAccess({
school_id: this.data.sid,
ext: fileType
}).then((acc) => {
if (acc.code == 200) {
access = acc.data;
return wxUploadFile({
url: access.host,
formData: {
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: imageBox[this.data.currentIndex].src,
name: 'file',
})
}
}).then((res) => {
let data = JSON.parse(res.data);
if (data.status == 'ok') {
imageBox[this.data.currentIndex].status = 'fullfilled';
imageBox[this.data.currentIndex].src = filename;
imageBox[this.data.currentIndex].src = access.path;
let currentIndex = this.data.currentIndex + 1;
this.setData({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
} else {
imageBox[this.data.currentIndex].status = 'fail';
let currentIndex = this.data.currentIndex + 1;
......@@ -226,16 +255,17 @@ Page({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
}
}).catch(() => {
}).catch((e) => {
console.log('ddddddddddddddddddddd失败')
imageBox[this.data.currentIndex].status = 'fail';
let currentIndex = this.data.currentIndex + 1;
this.setData({
imageBox,
currentIndex
})
this.singleUploadFile(access);
this.singleUploadFile();
})
},
delimg (e) {
......@@ -396,18 +426,28 @@ Page({
})
this.addVideoMethod();
},
addVideoMethod () { // 添加视频的操作
addVideoMethod (e, wxFile) { // 添加视频的操作
const that = this;
let access = {};
let filename = '';
cMediaOssAccess({
type: 1
}).then((res) => {
access = res.data;
return wxChooseVideo({
let videoInsertIndex = 0;
let imageBox = this.data.imageBox;
let size = 0;
let duration = 0;
let tempFilePath ='';
let myPromise = null;
if (wxFile) {
myPromise = new Promise((resolve) => {
resolve(wxFile);
})
}).then((res) => {
const {tempFilePath, duration, size} = res;
} else {
myPromise = wxChooseVideo({
})
}
myPromise.then((res) => {
size = res.size;
duration = res.duration;
tempFilePath = res.tempFilePath;
if (duration > constants.videoConf.duration) {
wx.showModal({
title: '提示',
......@@ -426,58 +466,70 @@ Page({
})
return
}
let imageBox = this.data.imageBox
let videoInsertIndex = imageBox.filter(ele => ele.type == 'video').length;
imageBox.splice(videoInsertIndex, 0, {
src: tempFilePath,
status: 'resolving',
type: 'video',
size: size
videoInsertIndex = imageBox.filter(ele => ele.type == 'video').length;
const path = tempFilePath;
const fileType = path.substr(path.lastIndexOf('.') + 1).toLowerCase();
return cMediaOssAccess({
school_id: this.data.sid,
type: 1
})
that.setData({
imageBox
})
filename = `${access.dir}${getRandomFilename(tempFilePath)}`;
that.uploadVideoTask = wx.uploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: tempFilePath,
name: 'file',
success (res) {
const {data} = res;
if (data == '{"status":"ok"}') {
let imageBox = that.data.imageBox;
imageBox[videoInsertIndex].src = filename;
imageBox[videoInsertIndex].status = 'fullfilled';
imageBox[videoInsertIndex].videoprogress = 100;
}).then((res) => {
if (res.code == 200) {
access = res.data;
imageBox.splice(videoInsertIndex, 0, {
src: access.path,
status: 'resolving',
type: 'video',
size: size,
mode: 'm3u8'
})
that.setData({
imageBox
})
that.data.uploadVideoTask[`${access.path}`] = wx.uploadFile({
url: access.host,
formData: {
key: access.path,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: tempFilePath,
name: 'file',
success (res) {
const {data} = res;
if (data == '{"status":"ok"}') {
let imageBox = that.data.imageBox;
imageBox[videoInsertIndex].src = access.path;
imageBox[videoInsertIndex].status = 'fullfilled';
imageBox[videoInsertIndex].videoprogress = 100;
that.setData({
imageBox: imageBox
}, () => {
if (that.data.activtySchoolInfo.plan == 'planb' && that.data.activtySchoolInfo.tid == that.data.tid) {
that.judgeContentQualified();
}
})
} else {
that.setData({
[`imageBox[${videoInsertIndex}].status`]: 'fail'
})
}
},
fail (e) {
}
})
if (that.data.uploadVideoTask[`${access.path}`].onProgressUpdate) {
that.data.uploadVideoTask[`${access.path}`].onProgressUpdate((res) => {
imageBox[videoInsertIndex].videoprogress = res.progress > 95 ? 95 : res.progress;
that.setData({
imageBox: imageBox
})
} else {
that.setData({
videostatus: 'fail'
})
}
},
fail () {
that.setData({
videostatus: 'fail'
})
}
})
that.uploadVideoTask.onProgressUpdate((res) => {
imageBox[videoInsertIndex].videoprogress = res.progress > 95 ? 95 : res.progress;
that.setData({
imageBox: imageBox
})
})
}
}).catch((err) => {
wx.hideLoading();
});
......
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