| | |
| | | import { |
| | | loginInfo |
| | | } from '../../../../assets/js/login'; |
| | | import XLSX from '../../../../utils/xlsx.mini.min'; |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | learnStartTime: 0, |
| | | learnTimeList: [], |
| | | learnTimeData: 0, |
| | | threeLeveData: [] |
| | | threeLeveData: [], |
| | | selectTypeData: '' |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | |
| | | deadline: options.deadline, |
| | | formPath: options.formPath, |
| | | }) |
| | | const token = wx.getStorageSync(app.config.tokenKey) |
| | | if (!token) { |
| | | loginInfo(app, (data) => { |
| | | if (options.formPath == 'jsek_cloudLearning') { |
| | | this.setData({ |
| | | learnStartTime: Date.now(), |
| | | }) |
| | | this.getLearnTime() |
| | | } |
| | | this.getBookInfo(this.data.bookId) |
| | | // if (data) { |
| | | // this.resourceDetailsData() |
| | | // } else { |
| | | // this.resourceDetailsData() |
| | | // } |
| | | if (options.formPath == 'jsek_cloudLearning') { |
| | | this.setData({ |
| | | learnStartTime: Date.now(), |
| | | }) |
| | | } else { |
| | | if (options.formPath == 'jsek_cloudLearning') { |
| | | this.setData({ |
| | | learnStartTime: Date.now(), |
| | | }) |
| | | this.getLearnTime() |
| | | } |
| | | this.getBookInfo(this.data.bookId) |
| | | // this.resourceDetailsData() |
| | | this.getLearnTime() |
| | | } |
| | | this.getBookInfo(this.data.bookId) |
| | | }, |
| | | |
| | | /** |
| | |
| | | isBuy: res.datas.purchasedSaleMethodIdList.includes(res.datas.defaultSaleMethodId) |
| | | }) |
| | | res.datas.cmsDatas[0].datas.forEach((item) => { |
| | | // if (this.data.productLinkPath == item.productLinkPath) { |
| | | // this.handleTeachData(item) |
| | | // this.setData({ |
| | | // titleName: item.name, |
| | | // selectType: item.selectType, |
| | | // learnSelectType: item.learnSelectType |
| | | // }) |
| | | // } else { |
| | | // return wx.showToast({ |
| | | // icon: 'none', |
| | | // title: '暂无资源', |
| | | // }) |
| | | // } |
| | | if (this.data.productLinkPath == item.productLinkPath) { |
| | | this.handleTeachData(item) |
| | | this.setData({ |
| | | titleName: item.name, |
| | | selectType: item.selectType, |
| | | learnSelectType: item.learnSelectType |
| | | }) |
| | | } |
| | | if (this.data.storeInfo == 'jsek_digitalCourses') { |
| | | if (this.data.isBuy) { |
| | | if (this.data.productLinkPath == item.productLinkPath) { |
| | |
| | | learnSelectType: item.learnSelectType, |
| | | }) |
| | | } else { |
| | | wx.showToast({ |
| | | icon: 'none', |
| | | title: '请先返回资源所在图书详情购买视频资源', |
| | | }) |
| | | wx.navigateTo({ |
| | | url: `/packageBookService/pages/bookServices/detail/index?id=${this.data.bookDetail.id}&name=${this.data.bookDetail.name}&tabValue=jsek_cloudLearning`, |
| | | }); |
| | | // wx.showToast({ |
| | | // icon: 'none', |
| | | // title: '请先返回资源所在图书详情购买视频资源', |
| | | // }) |
| | | // wx.navigateTo({ |
| | | // url: `/packageBookService/pages/bookServices/detail/index?id=${this.data.bookDetail.id}&name=${this.data.bookDetail.name}&tabValue=jsek_cloudLearning`, |
| | | // }); |
| | | } |
| | | }) |
| | | }, |
| | |
| | | }, |
| | | //刚进来的时候调用 |
| | | handleTeachData(item) { |
| | | |
| | | let that = this |
| | | //图片 |
| | | if (item.selectType == 'picture' || item.learnSelectType == 'picture') { |
| | | let file = item.file ? item.file : item.protectedFile ? item.protectedFile : item.freeFile |
| | |
| | | //文档等 |
| | | if (item.selectType == 'document' || item.selectType == 'pdf' || item.learnSelectType == 'document' || item.learnSelectType == 'pdf') { |
| | | let md5 = item.file ? item.file : item.protectedFile ? item.protectedFile : item.freeFile |
| | | app.MG.file.getPdfInfo({ |
| | | md5: md5 |
| | | }).then((res) => { |
| | | let naturalResources = [] |
| | | if (res && res.totalPages) { |
| | | for (let i = 0; i < res.totalPages; i++) { |
| | | const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (i + 1) + '&dpi=300' |
| | | naturalResources.push(src) |
| | | } |
| | | } |
| | | if (item.fileMap[md5]?.extension == 'xlsx' || item.fileMap[md5]?.extension == 'xls') { |
| | | this.setData({ |
| | | naturalResources |
| | | selectTypeData: 'excel' |
| | | }) |
| | | wx.hideLoading(); |
| | | }) |
| | | wx.request({ |
| | | url: app.config.requestCtx + '/file/api/ApiDownload?md5=' + md5, |
| | | method: 'GET', // 请求方式 |
| | | responseType: 'arraybuffer', // 指定返回类型为 arraybuffer |
| | | success: (res) => { |
| | | if (res.statusCode === 200) { |
| | | let data = new Uint8Array(res.data) |
| | | let workbook = XLSX.read(data, { |
| | | type: 'array' |
| | | }) |
| | | let worksheet = workbook.Sheets[workbook.SheetNames[0]] |
| | | let innerHTML = XLSX.utils.sheet_to_json(worksheet) |
| | | console.log(innerHTML) |
| | | that.setData({ |
| | | naturalResources: innerHTML |
| | | }) |
| | | wx.hideLoading(); |
| | | } else { |
| | | console.error('请求失败', res.statusCode); |
| | | } |
| | | }, |
| | | fail: function (err) { |
| | | console.error('请求失败', err); |
| | | } |
| | | }); |
| | | } else { |
| | | app.MG.file.getPdfInfo({ |
| | | md5: md5 |
| | | }).then((res) => { |
| | | let naturalResources = [] |
| | | if (res && res.totalPages) { |
| | | for (let i = 0; i < res.totalPages; i++) { |
| | | const src = app.config.requestCtx + '/file/GetPdfPageImage?md5=' + md5 + '&index=' + (i + 1) + '&dpi=300' |
| | | naturalResources.push(src) |
| | | } |
| | | } |
| | | this.setData({ |
| | | naturalResources |
| | | }) |
| | | wx.hideLoading(); |
| | | }) |
| | | } |
| | | } |
| | | |
| | | }, |
| | | |
| | | handleTap: function () { |
| | | const naturalResources = this.data.naturalResources; |
| | | naturalResources.forEach(function (item) {}); |
| | | }, |
| | | |
| | | onClick() { |