|
@@ -1,100 +1,97 @@
|
|
|
// pages/taskDetail/taskDetail.js
|
|
|
+const app = getApp()
|
|
|
+const util = require("../../utils/util")
|
|
|
+const urlDef = require("../../utils/urls")
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ curStu: null,
|
|
|
+ homeworkId: null,
|
|
|
curVideo: '',
|
|
|
videoFlag: 0,
|
|
|
- imgList:[
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg'
|
|
|
- ],
|
|
|
videoContext: '',
|
|
|
- videoList:[
|
|
|
- {
|
|
|
- img: 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- url: 'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
|
|
|
- },
|
|
|
- {
|
|
|
- img: 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- url: 'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
|
|
|
- },
|
|
|
- {
|
|
|
- img: 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- url: 'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
|
|
|
- },
|
|
|
- {
|
|
|
- img: 'https://file.schoolwisdoms.com/image/26cf1980-5b25-4c2e-af7f-376677d76033.jpg',
|
|
|
- url: 'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'
|
|
|
- }
|
|
|
- ],
|
|
|
- audioList:[
|
|
|
- 'https://gm-sycdn.kuwo.cn/2256fce37c86b5bc25065d780f769260/60347b85/resource/n2/73/81/1062648582.mp3',
|
|
|
- 'https://gm-sycdn.kuwo.cn/2256fce37c86b5bc25065d780f769260/60347b85/resource/n2/73/81/1062648582.mp3',
|
|
|
- ],
|
|
|
curAudio: '',
|
|
|
curAudioIndex: -1,
|
|
|
audioPause: 0,
|
|
|
- doTaskFlag: false
|
|
|
+ doTaskFlag: false,
|
|
|
+ entity: null,
|
|
|
+ teacherFace: '/images/head.png',
|
|
|
},
|
|
|
|
|
|
- bindfullscreenchange:function(){
|
|
|
- if(this.data.videoFlag == 0){
|
|
|
+ bindfullscreenchange: function () {
|
|
|
+ if (this.data.videoFlag == 0) {
|
|
|
this.setData({
|
|
|
- videoFlag : 1
|
|
|
+ videoFlag: 1
|
|
|
})
|
|
|
} else {
|
|
|
this.setData({
|
|
|
- videoFlag : 0,
|
|
|
- curVideo : ""
|
|
|
+ videoFlag: 0,
|
|
|
+ curVideo: ""
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- videoShow:function(e){
|
|
|
+ videoShow: function (e) {
|
|
|
this.setData({
|
|
|
curVideo: e.currentTarget.dataset.url
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
this.videoContext.requestFullScreen({ // 设置全屏时视频的方向,不指定则根据宽高比自动判断。
|
|
|
- direction: 90 // 屏幕逆时针90度
|
|
|
- });
|
|
|
+ direction: 90 // 屏幕逆时针90度
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
- showImg:function(e){
|
|
|
- // var list = e.currentTarget.dataset.url
|
|
|
+ showImg: function (e) {
|
|
|
+ var list = [];
|
|
|
+ this.data.entity.images.map(o => {
|
|
|
+ list.push(o.url);
|
|
|
+ });
|
|
|
+
|
|
|
wx.previewImage({
|
|
|
- urls: this.data.imgList,
|
|
|
+ urls: list
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
- audioShow:function(e){
|
|
|
- if(this.data.audioPause == 0 && this.data.curAudioIndex != e.currentTarget.dataset.index){//播放语音,切换
|
|
|
+ showDoneImg: function (e) {
|
|
|
+ var list = [];
|
|
|
+ this.data.entity.done.images.map(o => {
|
|
|
+ list.push(o.url);
|
|
|
+ });
|
|
|
+ wx.previewImage({
|
|
|
+ urls: list
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showMarkImg: function (e) {
|
|
|
+ var list = [];
|
|
|
+ this.data.entity.mark.images.map(o => {
|
|
|
+ list.push(o.url);
|
|
|
+ });
|
|
|
+ wx.previewImage({
|
|
|
+ urls: list
|
|
|
+ })
|
|
|
+ },
|
|
|
+ audioShow: function (e) {
|
|
|
+ if (this.data.audioPause == 0 && this.data.curAudioIndex != e.currentTarget.dataset.index) {//播放语音,切换
|
|
|
this.setData({
|
|
|
curAudio: ""
|
|
|
})
|
|
|
this.setData({
|
|
|
curAudioIndex: e.currentTarget.dataset.index,
|
|
|
curAudio: e.currentTarget.dataset.url,
|
|
|
-
|
|
|
+
|
|
|
+ })
|
|
|
+ this.audioContext.play()
|
|
|
+ this.setData({
|
|
|
+ audioPause: 0
|
|
|
})
|
|
|
+ } else if (this.data.audioPause == 1 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停后恢复播放
|
|
|
this.audioContext.play()
|
|
|
this.setData({
|
|
|
audioPause: 0
|
|
|
})
|
|
|
- } else if(this.data.audioPause == 1 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停后恢复播放
|
|
|
- this.audioContext.play()
|
|
|
- this.setData({
|
|
|
- audioPause: 0
|
|
|
- })
|
|
|
- } else if(this.data.audioPause == 0 && this.data.curAudioIndex == e.currentTarget.dataset.index){//暂停播放
|
|
|
+ } else if (this.data.audioPause == 0 && this.data.curAudioIndex == e.currentTarget.dataset.index) {//暂停播放
|
|
|
this.audioContext.pause()
|
|
|
this.setData({
|
|
|
audioPause: 1
|
|
@@ -102,7 +99,7 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- bindended:function(){
|
|
|
+ bindended: function () {
|
|
|
this.setData({
|
|
|
audioPause: 0,
|
|
|
curAudioIndex: -1,
|
|
@@ -110,7 +107,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- bindpause:function(){
|
|
|
+ bindpause: function () {
|
|
|
this.setData({
|
|
|
audioPause: 1
|
|
|
})
|
|
@@ -120,14 +117,18 @@ Page({
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
+ let id = options.id;
|
|
|
+ this.setData({ homeworkId: id });
|
|
|
this.audioContext = wx.createAudioContext('audio-play')
|
|
|
this.videoContext = wx.createVideoContext('play-video');// 创建 video 上下文 VideoContext 对象。
|
|
|
const type = options.type
|
|
|
- if(type == 0){
|
|
|
+ if (type == 0) {
|
|
|
this.setData({
|
|
|
doTaskFlag: true
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ this.loadHomework()
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -177,5 +178,162 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
+ },
|
|
|
+ loadHomework: function () {
|
|
|
+ const urls = urlDef.urls;
|
|
|
+ let stu = wx.getStorageSync('student');
|
|
|
+ if (stu) {
|
|
|
+ const body = { 'q.homeworkId': this.data.homeworkId, 'q.studentId': stu.studentId }
|
|
|
+ // 接收作业(第一次查看有效)
|
|
|
+ util.apiPost(urls.homework_receive, body).then((rs) => {
|
|
|
+ console.log('接收作业')
|
|
|
+ })
|
|
|
+ util.apiPost(urls.my_homework, body).then((rs) => {
|
|
|
+ let o = rs[0];
|
|
|
+
|
|
|
+ // 解析内容
|
|
|
+ let workContents;
|
|
|
+ try {
|
|
|
+ workContents = JSON.parse(o.homeworkContent);
|
|
|
+ } catch (e) {
|
|
|
+ workContents = {
|
|
|
+ content: o.homeworkContent,
|
|
|
+ images: [],
|
|
|
+ records: [],
|
|
|
+ videos: []
|
|
|
+ };
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ o.homeworkContent = workContents.content;
|
|
|
+ if (o.receiveDate) {
|
|
|
+ o.receiveDate = o.receiveDate.substring(0, 16).replace('T', ' ')
|
|
|
+ }
|
|
|
+ o.images = workContents.images == null ? [] : workContents.images;
|
|
|
+ o.images.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'image/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ o.records = workContents.records == null ? [] : workContents.records;
|
|
|
+ o.records.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'file/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ o.videos = workContents.videos == null ? [] : workContents.videos;
|
|
|
+ o.videos.forEach(v => {
|
|
|
+ util.apiPost(urls.video_loadInfo + v.url).then((rs) => {
|
|
|
+ v.imgUrl = rs.img
|
|
|
+ v.playUrl = rs.url
|
|
|
+ this.reloadVideo(v)
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ // 完成情况
|
|
|
+ let doneContents;
|
|
|
+ try {
|
|
|
+ doneContents = o.content ? JSON.parse(o.content) : {};
|
|
|
+ } catch (e) {
|
|
|
+ doneContents = {
|
|
|
+ images: [],
|
|
|
+ records: [],
|
|
|
+ videos: [],
|
|
|
+ content: ''
|
|
|
+ };
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ o.done = doneContents;
|
|
|
+ o.done.images = doneContents.images == null ? [] : doneContents.images;
|
|
|
+ o.done.images.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'image/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ o.done.records = doneContents.records == null ? [] : doneContents.records;
|
|
|
+ o.done.records.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'file/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ o.done.videos = doneContents.videos == null ? [] : doneContents.videos;
|
|
|
+ o.done.videos.forEach(v => {
|
|
|
+ util.apiPost(urls.video_loadInfo + v.url).then((rs) => {
|
|
|
+ v.imgUrl = rs.img
|
|
|
+ v.playUrl = rs.url
|
|
|
+ this.reloadDoneVideo(v)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ // 批阅情况
|
|
|
+ let markContents;
|
|
|
+ try {
|
|
|
+ markContents = o.markResult ? JSON.parse(o.markResult) : {};
|
|
|
+ } catch (e) {
|
|
|
+ markContents = {
|
|
|
+ images: [],
|
|
|
+ records: [],
|
|
|
+ videos: [],
|
|
|
+ content: ''
|
|
|
+ };
|
|
|
+ console.error(e);
|
|
|
+ }
|
|
|
+ o.mark = markContents;
|
|
|
+ o.mark.score = o.markScore ? o.markScore : 0
|
|
|
+ o.mark.images = markContents.images == null ? [] : markContents.images;
|
|
|
+ o.mark.images.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'image/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ o.mark.records = markContents.records == null ? [] : markContents.records;
|
|
|
+ o.mark.records.forEach(rs => {
|
|
|
+ rs.url = urls.oss_file + 'file/' + rs.url
|
|
|
+ });
|
|
|
+
|
|
|
+ o.mark.videos = markContents.videos == null ? [] : markContents.videos;
|
|
|
+ o.mark.videos.forEach(v => {
|
|
|
+ util.apiPost(urls.video_loadInfo + v.url).then((rs) => {
|
|
|
+ v.imgUrl = rs.img
|
|
|
+ v.playUrl = rs.url
|
|
|
+ this.reloadMarkVideo(v)
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ this.setData({ entity: o })
|
|
|
+ util.apiPost(urls.get_user_head + '&q.personId=' + rs[0].teacherId).then((fs) => {
|
|
|
+ if (fs && fs.length > 0) {
|
|
|
+ this.setData({ teacherFace: urls.oss_file + 'image/' + fs[0] })
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ reloadVideo: function (t) {
|
|
|
+ let o = this.data.entity
|
|
|
+ let vs = o.videos
|
|
|
+ vs.map(v => {
|
|
|
+ if (t.url == v.url) {
|
|
|
+ v.imgUrl = t.imgUrl
|
|
|
+ v.playUrl = t.playUrl
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({ entity: o })
|
|
|
+ },
|
|
|
+ reloadDoneVideo: function (t) {
|
|
|
+ let o = this.data.entity
|
|
|
+ let vs = o.done.videos
|
|
|
+ vs.map(v => {
|
|
|
+ if (t.url == v.url) {
|
|
|
+ v.imgUrl = t.imgUrl
|
|
|
+ v.playUrl = t.playUrl
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({ entity: o })
|
|
|
+ },
|
|
|
+ reloadMarkVideo: function (t) {
|
|
|
+ let o = this.data.entity
|
|
|
+ let vs = o.mark.videos
|
|
|
+ vs.map(v => {
|
|
|
+ if (t.url == v.url) {
|
|
|
+ v.imgUrl = t.imgUrl
|
|
|
+ v.playUrl = t.playUrl
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.setData({ entity: o })
|
|
|
}
|
|
|
})
|