123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- const _Http = getApp().globalData.http,
- MFT = require("../../utils/matchingFeilType");
- let sat_coursewareid = null;
- Page({
- data: {
- },
- onLoad(options) {
- sat_coursewareid = options.id;
- this.getDetail()
- },
- getDetail() {
- _Http.basic({
- "classname": "saletool.courseware.courseware",
- "method": "selectDetail",
- "content": {
- sat_coursewareid
- }
- }).then(res => {
- console.log("详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- let videoList = [], //视频附件列表
- attinfos = []; //其他附件
- if (res.data.attinfos.length) MFT.fileList(res.data.attinfos).filter(v => {
- if (v.usetype != 'cover') v.fileType == 'video' ? videoList.push(v) : attinfos.push(v)
- });
- this.setData({
- videoList,
- attinfos,
- play: videoList[0] || null,
- detailData: res.data,
- });
- })
- },
- /* 选择播放视频 */
- playItem(e) {
- const {
- item
- } = e.currentTarget.dataset;
- if (this.data.play.attachmentid == item.attachmentid) return;
- this.setData({
- play: item
- })
- },
- /* 播放结束更改状态 */
- onEnded() {
- let play = this.data.play;
- if (play.status == '已学习') return;
- _Http.basic({
- "classname": "saletool.courseware.courseware",
- "method": "updateAttInfoLearnLog",
- "content": {
- sat_coursewareid,
- attachmentid: play.attachmentid
- }
- })
- play.status = '已学习';
- this.data.videoList.find(v => v.attachmentid == play.attachmentid).status = '已学习';
- this.setData({
- play,
- videoList: this.data.videoList
- })
- },
- /* 打开文档 */
- openDoc(e) {
- const {
- item
- } = e.currentTarget.dataset,
- that = this;
- if (item.fileType == 'image') {
- wx.previewImage({
- urls: [item.url],
- })
- } else {
- wx.showLoading({
- title: '打开中...',
- mask: true
- })
- wx.downloadFile({
- // 示例 url,并非真实存在
- url: item.url,
- success: function (res) {
- const filePath = res.tempFilePath
- wx.openDocument({
- filePath: filePath,
- success: function (res) {
- console.log('打开文档成功')
- wx.hideLoading()
- },
- fail(err) {
- console.log(err)
- that.copyUrl(item)
- wx.hideLoading()
- }
- })
- },
- fail(err) {
- console.log(err)
- that.copyUrl(item)
- wx.hideLoading()
- }
- })
- };
- if (item.status == '已学习') return;
- _Http.basic({
- "classname": "saletool.courseware.courseware",
- "method": "updateAttInfoLearnLog",
- "content": {
- sat_coursewareid,
- attachmentid: item.attachmentid
- }
- });
- this.data.attinfos.find(v => v.attachmentid == item.attachmentid).status = '已学习';
- this.setData({
- attinfos: this.data.attinfos
- })
- },
- copyUrl(item) {
- wx.showModal({
- title: '提示',
- content: `该文件不支持在线预览,是否复制链接到剪切板在浏览器中尝试打开文件`,
- confirmText: "复制",
- complete: (res) => {
- if (res.confirm) wx.setClipboardData({
- data: item.url,
- success(s) {
- wx.showToast({
- title: '已将文件地址复制到剪切板',
- icon: "none",
- mask: true
- })
- }
- })
- }
- })
- },
- toExam() {
- let that = this;
- _Http.basic({
- "classname": "saletool.courseware.coursewaretest",
- "method": "queryTestList",
- "content": {
- "pageNumber": 1,
- "pageSize": 999,
- sat_coursewareid,
- "where": {
- "status": ""
- }
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- if (res.data.length == 0) {
- this.createTest();
- } else {
- let status = res.data[res.data.length - 1].status;
- if (status == '已完成') {
- wx.showModal({
- title: '提示',
- content: '当前课程已完成考试,是否进入新的考试?',
- confirmText: "进入考试",
- complete: ({
- confirm
- }) => {
- if (confirm) that.createTest();
- }
- });
- } else if (status == '未完成') {
- wx.showModal({
- title: '提示',
- content: '上一次考试未完成,是否继续考试?',
- confirmText: "继续",
- cancelText: "重新考试",
- complete: ({
- cancel,
- confirm
- }) => {
- if (cancel) that.createTest();
- if (confirm) wx.navigateTo({
- url: '/pages/exam/detail?id=' + res.data[res.data.length - 1].sat_courseware_testid,
- })
- }
- })
- }
- }
- })
- },
- createTest() {
- _Http.basic({
- "classname": "saletool.courseware.coursewaretest",
- "method": "createTest",
- "content": {
- sat_coursewareid
- }
- }).then(s => {
- console.log("开始考试", s)
- if (s.msg != '成功') return wx.showToast({
- title: s.msg,
- icon: "none"
- })
- wx.navigateTo({
- url: '/pages/exam/detail?id=' + s.data.sat_courseware_testid,
- })
- })
- }
- })
|