|
@@ -15,6 +15,7 @@ Page({
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ uploadIng: false,
|
|
|
homeworkId: null,
|
|
|
talkFlag: false,
|
|
|
closeName: '开始录音',
|
|
@@ -25,17 +26,17 @@ Page({
|
|
|
audioPause: false,
|
|
|
content: '',
|
|
|
delItems: [],
|
|
|
- contents:null,
|
|
|
+ contents: null,
|
|
|
},
|
|
|
|
|
|
- renderTime:function(date) {
|
|
|
- var dateee = new Date(date).toJSON();
|
|
|
- return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
|
|
|
- },
|
|
|
+ renderTime: function (date) {
|
|
|
+ var dateee = new Date(date).toJSON();
|
|
|
+ return new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
|
|
|
+ },
|
|
|
|
|
|
getRecord: function () {
|
|
|
const that = this
|
|
|
- if(that.data.audioList.length>=6){
|
|
|
+ if (that.data.audioList.length >= 6) {
|
|
|
wx.showToast({
|
|
|
title: '最多上传6段录音',
|
|
|
icon: 'none'
|
|
@@ -44,7 +45,7 @@ Page({
|
|
|
}
|
|
|
if (that.data.talkFlag) {
|
|
|
recordManager.stop()
|
|
|
- recordManager.onStop((res) => { //监听录音停止的事件
|
|
|
+ recordManager.onStop((res) => { //监听录音停止的事件
|
|
|
console.log("监听录音停止事件", res)
|
|
|
if (res.duration < 1000) {
|
|
|
wx.showToast({
|
|
@@ -66,7 +67,9 @@ Page({
|
|
|
title: '上传成功',
|
|
|
})
|
|
|
const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
|
|
|
- const list = [{ url: rs.data[0].url }]
|
|
|
+ const list = [{
|
|
|
+ url: rs.data[0].url
|
|
|
+ }]
|
|
|
that.setData({
|
|
|
audioList: that.data.audioList.concat(list)
|
|
|
})
|
|
@@ -79,7 +82,7 @@ Page({
|
|
|
},
|
|
|
complete(res) {
|
|
|
wx.hideLoading({
|
|
|
- success: (res) => { },
|
|
|
+ success: (res) => {},
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -165,7 +168,7 @@ Page({
|
|
|
|
|
|
uploadTap: function () {
|
|
|
const that = this
|
|
|
- if(that.data.imgList.length>=6){
|
|
|
+ if (that.data.imgList.length >= 6) {
|
|
|
wx.showToast({
|
|
|
title: '最多上传6张图片',
|
|
|
icon: 'none'
|
|
@@ -190,7 +193,9 @@ Page({
|
|
|
title: '上传成功',
|
|
|
})
|
|
|
const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
|
|
|
- const list = [{ url: rs.data[0].url }]
|
|
|
+ const list = [{
|
|
|
+ url: rs.data[0].url
|
|
|
+ }]
|
|
|
that.setData({
|
|
|
imgList: that.data.imgList.concat(list)
|
|
|
})
|
|
@@ -203,7 +208,7 @@ Page({
|
|
|
},
|
|
|
complete(res) {
|
|
|
wx.hideLoading({
|
|
|
- success: (res) => { },
|
|
|
+ success: (res) => {},
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -238,7 +243,7 @@ Page({
|
|
|
|
|
|
upLoadVideo: function () {
|
|
|
const that = this
|
|
|
- if(that.data.videoList.length>=6){
|
|
|
+ if (that.data.videoList.length >= 6) {
|
|
|
wx.showToast({
|
|
|
title: '最多上传6部视频',
|
|
|
icon: 'none'
|
|
@@ -265,6 +270,12 @@ Page({
|
|
|
uploadAddress: d.UploadAddress,
|
|
|
videoId: d.VideoId,
|
|
|
})
|
|
|
+ wx.showLoading({
|
|
|
+ title: '上传中...',
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ uploadIng: true
|
|
|
+ })
|
|
|
uploader.addFile(file, null, null, null, userData)
|
|
|
uploader.startUpload();
|
|
|
// uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress, videoId);
|
|
@@ -323,12 +334,16 @@ Page({
|
|
|
let stu = wx.getStorageSync('student')
|
|
|
let homeworkId = options.homeworkId;
|
|
|
let studentId = stu.studentId;
|
|
|
- this.setData({ homeworkId: homeworkId })
|
|
|
+ this.setData({
|
|
|
+ homeworkId: homeworkId
|
|
|
+ })
|
|
|
|
|
|
- let params = { 'q.homeworkId': homeworkId, 'q.studentId': studentId }
|
|
|
+ let params = {
|
|
|
+ 'q.homeworkId': homeworkId,
|
|
|
+ 'q.studentId': studentId
|
|
|
+ }
|
|
|
|
|
|
- util.apiPost(urls.homework_receive, params).then(rs => {
|
|
|
- });
|
|
|
+ util.apiPost(urls.homework_receive, params).then(rs => {});
|
|
|
|
|
|
util.apiPost(urls.my_homework, params).then(rs => {
|
|
|
if (rs.length > 0) {
|
|
@@ -336,7 +351,7 @@ Page({
|
|
|
let contents;
|
|
|
try {
|
|
|
contents = entity
|
|
|
- contents.receiveDate=this.renderTime(contents.receiveDate)
|
|
|
+ contents.receiveDate = this.renderTime(contents.receiveDate)
|
|
|
this.setData({
|
|
|
contents
|
|
|
})
|
|
@@ -345,7 +360,9 @@ Page({
|
|
|
console.error(e);
|
|
|
}
|
|
|
|
|
|
- this.setData({ content: contents.content })
|
|
|
+ this.setData({
|
|
|
+ content: contents.content
|
|
|
+ })
|
|
|
let images = contents.images == null ? [] : contents.images;
|
|
|
images.forEach(r => {
|
|
|
r.url = urls.oss_file + 'image/' + r.url
|
|
@@ -387,10 +404,7 @@ Page({
|
|
|
retryDuration: 2,
|
|
|
//开始上传
|
|
|
'onUploadstarted': function (uploadInfo) {
|
|
|
- wx.showLoading({
|
|
|
- title: '上传中...',
|
|
|
- mask: true
|
|
|
- })
|
|
|
+ console.log("开始上传")
|
|
|
// console.log("onUploadStarted:" + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object)
|
|
|
//上传方式1,需要根据uploadInfo.videoId是否有值,调用点播的不同接口获取uploadauth和uploadAddress,如果videoId有值,调用刷新视频上传凭证接口,否则调用创建视频上传凭证接口
|
|
|
if (uploadInfo.videoId) {
|
|
@@ -408,7 +422,14 @@ Page({
|
|
|
|
|
|
let vid = uploadInfo.videoId
|
|
|
let stu = wx.getStorageSync('student')
|
|
|
- var video = { name: vid, videoId: vid, orgId: stu.orgId, size: uploadInfo.fileSize, title: '', content: '' };
|
|
|
+ var video = {
|
|
|
+ name: vid,
|
|
|
+ videoId: vid,
|
|
|
+ orgId: stu.orgId,
|
|
|
+ size: uploadInfo.fileSize,
|
|
|
+ title: '',
|
|
|
+ content: ''
|
|
|
+ };
|
|
|
// 保存一个 video
|
|
|
let urls = urlDef.urls
|
|
|
util.apiPost(urls.video_save, video, 'application/json').then((rs) => {
|
|
@@ -425,6 +446,9 @@ Page({
|
|
|
wx.showToast({
|
|
|
title: '上传成功',
|
|
|
})
|
|
|
+ that.setData({
|
|
|
+ uploadIng: false
|
|
|
+ })
|
|
|
})
|
|
|
// console.log("onUploadSucceed: " + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object);
|
|
|
},
|
|
@@ -457,6 +481,18 @@ Page({
|
|
|
uploader = createUpLoad
|
|
|
},
|
|
|
|
|
|
+ removeUpload: function () {
|
|
|
+ uploader.stopUpload()
|
|
|
+ uploader.cleanList();
|
|
|
+ wx.showToast({
|
|
|
+ title: '取消上传',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ uploadIng: false
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|
|
@@ -515,9 +551,14 @@ Page({
|
|
|
this.data.imgList.forEach(r => {
|
|
|
let fid = r.url.substring(r.url.lastIndexOf('/') + 1)
|
|
|
if (r.delete == 1) {
|
|
|
- dlist.push({ id: fid, type: 'image' })
|
|
|
+ dlist.push({
|
|
|
+ id: fid,
|
|
|
+ type: 'image'
|
|
|
+ })
|
|
|
} else {
|
|
|
- images.push({ url: fid })
|
|
|
+ images.push({
|
|
|
+ url: fid
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -527,9 +568,14 @@ Page({
|
|
|
this.data.audioList.forEach(r => {
|
|
|
let fid = r.url.substring(r.url.lastIndexOf('/') + 1)
|
|
|
if (r.delete == 1) {
|
|
|
- dlist.push({ id: fid, type: 'record' })
|
|
|
+ dlist.push({
|
|
|
+ id: fid,
|
|
|
+ type: 'record'
|
|
|
+ })
|
|
|
} else {
|
|
|
- records.push({ url: fid })
|
|
|
+ records.push({
|
|
|
+ url: fid
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -538,14 +584,21 @@ Page({
|
|
|
if (this.data.videoList.length > 0) {
|
|
|
this.data.videoList.forEach(r => {
|
|
|
if (r.delete == 1) {
|
|
|
- dlist.push({ id: r.url, type: 'video' })
|
|
|
+ dlist.push({
|
|
|
+ id: r.url,
|
|
|
+ type: 'video'
|
|
|
+ })
|
|
|
} else {
|
|
|
- videos.push({ url: r.url })
|
|
|
+ videos.push({
|
|
|
+ url: r.url
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- this.setData({ delItems: dlist })
|
|
|
+ this.setData({
|
|
|
+ delItems: dlist
|
|
|
+ })
|
|
|
contents.images = images;
|
|
|
contents.videos = videos;
|
|
|
contents.records = records;
|
|
@@ -561,7 +614,10 @@ Page({
|
|
|
|
|
|
util.apiPost(urls.complete_homework, data).then(rs => {
|
|
|
|
|
|
- const msgParams = { 'homeworkId': this.data.homeworkId, 'studentId': stu.studentId };
|
|
|
+ const msgParams = {
|
|
|
+ 'homeworkId': this.data.homeworkId,
|
|
|
+ 'studentId': stu.studentId
|
|
|
+ };
|
|
|
util.apiPost(urls.homework_complete_send_message, msgParams).then((rs) => {
|
|
|
console.log('发送通知 ' + JSON.stringify(rs));
|
|
|
});
|
|
@@ -590,13 +646,17 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
if (delFiles.length > 0) {
|
|
|
- const params = { 'keys': delFiles };
|
|
|
+ const params = {
|
|
|
+ 'keys': delFiles
|
|
|
+ };
|
|
|
util.apiPost(urls.file_delete, params).then((rs) => {
|
|
|
console.log('删除文件 ... ' + JSON.stringify(params));
|
|
|
});
|
|
|
}
|
|
|
if (delVideos.length > 0) {
|
|
|
- const params = { 'ids[]': delVideos }
|
|
|
+ const params = {
|
|
|
+ 'ids[]': delVideos
|
|
|
+ }
|
|
|
util.apiPost(urls.video_delete, params).then((rs) => {
|
|
|
console.log('删除视频 ... ' + JSON.stringify(params));
|
|
|
});
|
|
@@ -612,9 +672,13 @@ Page({
|
|
|
o = v;
|
|
|
}
|
|
|
})
|
|
|
- this.setData({ videoList: videos })
|
|
|
+ this.setData({
|
|
|
+ videoList: videos
|
|
|
+ })
|
|
|
},
|
|
|
doInput: function (e) {
|
|
|
- this.setData({ content: e.detail.value })
|
|
|
+ this.setData({
|
|
|
+ content: e.detail.value
|
|
|
+ })
|
|
|
}
|
|
|
})
|