|
|
@@ -0,0 +1,142 @@
|
|
|
+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
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+})
|