<template>
|
<div class="contentBox">
|
<detailInfo :bookInfo="bookInfo" v-loading="loading"></detailInfo>
|
<div style="display: flex">
|
<div class="leftBox">
|
<electronicBooks />
|
<paperCopies />
|
</div>
|
<div class="rightBox">
|
<bookInfo :bookInfo="bookInfo" v-loading="loading" />
|
<resource
|
:resourceSupportList="resourceSupportList"
|
:allResource="allResource"
|
:bookInfo="bookInfo"
|
/>
|
<serviceRelated
|
ref="rela"
|
:bookInfo="bookInfo"
|
:recommendKey="recommendKey"
|
@reloadPage="reloadPage"
|
/>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import config from "@/assets/js/config";
|
import detailInfo from "@/components/detail/detailInfo.vue";
|
import electronicBooks from "@/components/detail/electronicBooks.vue";
|
import bookInfo from "@/components/detail/bookInfo.vue";
|
import resource from "@/components/detail/resource.vue";
|
import paperCopies from "@/components/detail/paperCopies.vue";
|
import serviceRelated from "@/components/detail/serviceRelated.vue";
|
|
export default {
|
components: {
|
detailInfo,
|
electronicBooks,
|
bookInfo,
|
resource,
|
paperCopies,
|
serviceRelated,
|
},
|
data() {
|
return {
|
bookInfo: {},
|
detailRoute: "teachingServices-detail",
|
resourceSupportList: [],
|
allResource: [],
|
recommendKey: "",
|
currentId: null,
|
currentCmsId: null,
|
loading: true,
|
};
|
},
|
created() {
|
if (this.$route.query.id && this.$route.query.cmsPath) {
|
this.currentId = this.$route.query.id;
|
this.currentCmsId = this.$route.query.cmsPath;
|
this.getData();
|
} else {
|
this.getData({ id: this.$route.query.id });
|
}
|
window.scrollTo(0, 0);
|
|
this.setNewView("productId", this.$route.query.id);
|
},
|
methods: {
|
//获取电子书剩余申请次数
|
getEbookTicketRes() {
|
this.MG.app
|
.getTicketResult({
|
ticketRefCodeOrGuid: "electronicSampleBookapplyNum",
|
roleId: this.userInfo.roleId,
|
})
|
.then((res) => {
|
this.ebookTotalCount = res.totalCount - res.usedCount;
|
});
|
},
|
//获取纸质剩余申请次数
|
getPbookTicketRes() {
|
this.MG.app
|
.getTicketResult({
|
ticketRefCodeOrGuid: "paperSampleBookapplyNum",
|
roleId: this.userInfo.roleId,
|
})
|
.then((res) => {
|
this.pbookTotalCount = res.totalCount - res.usedCount;
|
});
|
},
|
|
//获取书籍详情
|
getData(data) {
|
this.loading = true;
|
let query = {
|
path: "*",
|
queryType: "*",
|
productId: data ? data.id : this.currentId,
|
cmsPath: this.currentCmsId, //获取书籍文件夹
|
fields: {
|
caupress_author: [],
|
caupress_content: [],
|
caupress_seriesName: [],
|
caupress_publicationDate: [],
|
caupress_ISBN: [],
|
caupress_pubNumber: [],
|
caupress_authorAbout: [],
|
caupress_recommendationReason: [],
|
caupress_preface: [],
|
caupress_catalog: [],
|
caupress_pdfFreeFile: [],
|
caupress_projectTitle: [],
|
caupress_pdfFile: [],
|
caupress_catalogue: [],
|
caupress_contactEditor: [],
|
},
|
linkTypes: [
|
// 获取关联的编辑信息
|
{
|
linkType: "caupress_editor",
|
fields: {
|
telephone: [],
|
phone: [],
|
qq: [],
|
},
|
},
|
],
|
};
|
|
// 获取书籍详情以及书籍资源文件夹
|
this.MG.store.getProductDetail(query).then((res) => {
|
this.bookInfo = res.datas;
|
if (this.bookInfo.caupress_catalogue) {
|
this.bookInfo.caupress_catalogue = JSON.parse(
|
this.bookInfo.caupress_catalogue
|
);
|
// 获取层次进行相关推荐
|
this.recommendKey = this.bookInfo.caupress_catalogue[0];
|
console.log(this.recommendKey, "this.recommendKey");
|
if (this.recommendKey.length > 0) {
|
this.catalogue = [];
|
this.recommendKey.forEach((item, index) => {
|
if (index == 0) {
|
this.catalogue.push(item);
|
} else {
|
this.catalogue.push("&" + item);
|
}
|
});
|
}
|
this.$refs.rela.getData(this.catalogue);
|
} else {
|
this.recommendKey = "null";
|
}
|
// 获取关联的编辑信息
|
let query = this.bookInfo.cmsDatas.find(
|
(item) => item.queryTag == "QueryLink_" + "caupress_editor"
|
);
|
if (query && query.datas.length) {
|
this.bookInfo.caupress_editor = {
|
name: query.datas[0].name,
|
telephone: query.datas[0].telephone,
|
phone: query.datas[0].phone,
|
qq: query.datas[0].qq,
|
};
|
}
|
if (this.bookInfo.caupress_projectTitle) {
|
this.bookInfo.caupress_projectTitle = JSON.parse(
|
this.bookInfo.caupress_projectTitle
|
);
|
}
|
if (this.bookInfo.caupress_projectTitle instanceof Array) {
|
if (this.bookInfo.caupress_projectTitle.length > 1) {
|
this.bookInfo.caupress_projectTitle =
|
this.bookInfo.caupress_projectTitle.join("、");
|
} else {
|
this.bookInfo.caupress_projectTitle =
|
this.bookInfo.caupress_projectTitle[0];
|
}
|
}
|
this.bookInfo.VirtualPrice =
|
this.bookInfo.saleMethod.length > 0
|
? this.bookInfo.saleMethod[0].VirtualPrice
|
: null;
|
this.bookInfo.caupress_seriesName =
|
config.seriesList[this.bookInfo.caupress_seriesName];
|
if (this.bookInfo.caupress_pubNumber) {
|
this.bookInfo.caupress_pubNumber =
|
this.bookInfo.caupress_pubNumber.split("_")[1];
|
}
|
this.loading = false;
|
|
this.$store.commit("setHistoryBook", this.bookInfo);
|
let folderList = res.datas.cmsDatas[0].datas;
|
console.log(folderList, "folderList");
|
folderList.forEach((item) => {
|
if (item.name == "配套资源") {
|
this.MG.store
|
.getProductDetail({
|
path: "*",
|
cmsPath: res.datas.rootCmsItemId + "\\" + item.id, //书籍文件夹ID获取文件夹中资源
|
productId: this.currentId,
|
queryType: "*",
|
itemFields: {
|
caupress_fileType: [],
|
caupress_file: [],
|
caupress_allowDownload: [],
|
},
|
})
|
.then((dataRes) => {
|
this.resourceSupportList = dataRes.datas.cmsDatas[0].datas;
|
});
|
} else {
|
this.MG.store
|
.getProductDetail({
|
path: "*",
|
cmsPath: res.datas.rootCmsItemId + "\\\\" + item.id, //书籍文件夹ID获取文件夹中资源
|
productId: this.currentId,
|
queryType: "*",
|
itemFields: {
|
caupress_fileType: [],
|
caupress_file: [],
|
caupress_allowDownload: [],
|
},
|
})
|
.then((dataRes) => {
|
this.allResource = dataRes.datas.cmsDatas[0].datas;
|
});
|
}
|
});
|
});
|
},
|
reloadPage(data) {
|
this.getData(data);
|
window.scrollTo(0, 0);
|
},
|
},
|
beforeRouteLeave(to, from, next) {
|
if (to.name != "teachingServices-index") {
|
this.$store.commit("delKeepAlive", "teachingServices-index");
|
}
|
next();
|
},
|
};
|
</script>
|
|
<style></style>
|