// pages/index/resourceCover.js
|
const app = getApp()
|
import {
|
loginInfo
|
} from '../../assets/js/login';
|
Page({
|
|
/**
|
* 页面的初始数据
|
*/
|
data: {
|
webpageSrc: "",
|
bookId: 0,
|
bookName: '',
|
cmsId: '',
|
productLinkPath: '',
|
parentProductLinkPath: '',
|
formPath: '',
|
copyUrl: '',
|
},
|
|
/**
|
* 生命周期函数--监听页面加载
|
*/
|
onLoad(options) {
|
const token = wx.getStorageSync(app.config.tokenKey)
|
if (!token) {
|
loginInfo(app, (data) => {
|
// 如果不是第一次登录,会执行回调
|
if (data) {
|
if (options.scene) {
|
this.getBookInfo(options.scene)
|
}
|
}
|
})
|
} else {
|
if (options.scene) {
|
this.getBookInfo(options.scene)
|
}
|
}
|
|
},
|
|
/**
|
* 生命周期函数--监听页面初次渲染完成
|
*/
|
onReady() {
|
|
},
|
|
/**
|
* 生命周期函数--监听页面显示
|
*/
|
onShow() {
|
|
},
|
|
getBookInfo(refcode) {
|
const obj = {
|
storeInfo: app.config.goodsStore,
|
path: app.config.goodsStore,
|
queryType: 'ProductCmsItem',
|
SysType: "CmsItem",
|
RefCode: refcode,
|
// CmsItemType: 'jsek_resource',
|
paging: {
|
start: 0,
|
size: 99,
|
},
|
coverSize: {
|
width: 260
|
},
|
fields: {
|
ProductLinkInfo: [],
|
productLinkPath: [],
|
selectType: [],
|
freeFile: [],
|
file: [],
|
protectedFile: [],
|
resourcesClassification: [],
|
isDownload: [],
|
jsek_resourceBrief: [],
|
jsek_link: [],
|
jsek_questionBank: [],
|
learnSelectType: [],
|
}
|
}
|
app.MG.resource.getItem(obj).then((res) => {
|
let book = res.datas.length > 0 ? res.datas[0] : {}
|
console.log(book, '资源信息')
|
let url;
|
if (book.selectType == "video" || book.learnSelectType == "video") {
|
url = "/packageDomain/pages/resourceDetails/myVideo/index";
|
} else if (
|
book.selectType == "audio" ||
|
book.learnSelectType == "audio"
|
) {
|
url = "/packageDomain/pages/resourceDetails/myAudio/index";
|
} else if (book.selectType == "picture") {
|
url = "/packageDomain/pages/resourceDetails/document/index";
|
}
|
this.setData({
|
bookId: book.productLinkInfo.ProductId,
|
bookName: book.productLinkInfo.Name,
|
productLinkPath: book.productLinkInfo.LinkPath + "\\" + book.id,
|
parentProductLinkPath: book.productLinkInfo.LinkPath,
|
cmsId: book.id,
|
formPath: book.learnSelectType ? 'jsek_cloudLearning' : ''
|
})
|
wx.redirectTo({
|
url: `${url}?productLinkPath=${this.data.productLinkPath}&parentProductLinkPath=${this.data.parentProductLinkPath}&bookId=${book.productLinkInfo.ProductId}&activeId=${book.id}&bookName=${book.productLinkInfo.Name}&cmsId=${book.id}&formPath=${this.data.formPath}`,
|
});
|
|
if (book.selectType == "pdf" || book.selectType == 'document') {
|
const fileLink = book.file ? book.file : book.freeFile
|
console.log(fileLink);
|
wx.redirectTo({
|
url: "/packageBookService/pages/components/webView/index?md5=" +
|
fileLink +
|
"&fileName=" +
|
book.name +
|
"&fileType=pdf" + "&bookBuy=true"
|
});
|
}
|
if (book.selectType == 'zip') {
|
const fileLink = book.file ?
|
app.config.requestCtx + "/file/api/ApiDownload?md5=" + book.file :
|
app.config.requestCtx +
|
"/file/api/ApiDownload?md5=" +
|
book.freeFile;
|
console.log(fileLink, "fileLink");
|
this.setData({
|
copyUrl: fileLink
|
})
|
// wx.redirectTo({
|
// url: "/packageBookService/pages/bookServices/webView/index?url=" + fileLink
|
// });
|
//提示加载中
|
// 单次下载允许的最大文件为 200MB
|
|
}
|
})
|
},
|
|
copyUrl(e) {
|
|
let url = e.currentTarget.dataset.value
|
console.log(url)
|
// wx.setClipboardData(url)
|
wx.setClipboardData({
|
data: `${e.currentTarget.dataset.value}`,
|
success(res) {
|
console.log(res.data) // data
|
},
|
fail(err) {
|
reject(err);
|
}
|
})
|
},
|
/**
|
* 用户点击右上角分享
|
*/
|
onShareAppMessage() {
|
|
}
|
})
|