123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <!-- 预览 -->
- <div class="tarcer-dev-Preview" v-loading="loading" v-if="isData">
- <Header />
- <HeaderOne title="教材详情" name="试读PDF" />
- <div class="main" v-if="data">
- <div class="flassify">
- <div class="text">
- <p class="p1">{{ data.name }}</p>
- <p class="p2">
- <span>
- {{ data.author }}
- </span>
- </p>
- </div>
- <div class="pay_collect">
- <div class="download">
- <img
- @click="download"
- src="../../assets/common/download.png"
- alt=""
- />
- <!-- <span>DOWNLOAD</span> -->
- </div>
- </div>
- </div>
- <div v-if="attachment" class="pdf-box">
- <pdf
- ref="pdf"
- :src="attachment"
- v-for="i in numPages"
- :key="i"
- :page="i"
- >
- {{ i / numPages }}
- </pdf>
- </div>
- </div>
- </div>
- </template>
- <script>
- import Header from "@/components/inputModules/common/Header";
- import HeaderOne from "@/components/inputModules/common/HeaderOne";
- import pdf from "vue-pdf";
- import { updateWordPack } from "@/utils/i18n";
- import { getToken } from "@/utils/auth";
- import { Base64 } from "js-base64";
- import { TextbookAPI, LearnWebSI } from "@/api/ajax";
- export default {
- name: "TextbookDetailPdf",
- components: {
- Header,
- HeaderOne,
- pdf,
- },
- data() {
- return {
- numPages: null,
- isCollect: false,
- materialId: null,
- data: null,
- attachment: null,
- loading: false,
- Ispreview: "", // 是不是预览
- NopymentShow: false, //添加订单弹窗
- PymentShow: false, //支付订单弹窗
- orderNumber: null, //订单号
- IsDownload: false, //是否可以下载
- allList: null,
- isData: false,
- };
- },
- computed: {},
- methods: {
- // 下载
- download() {
- let userInfor = JSON.parse(getToken());
- let UserCode = "",
- UserType = "",
- SessionID = "";
- if (userInfor) {
- UserCode = userInfor.user_code;
- UserType = userInfor.user_type;
- SessionID = userInfor.session_id;
- }
- let FileID = Base64.decode(this.$route.query.fileId);
- let data = {
- SessionID,
- UserCode,
- UserType,
- FileID,
- };
- location.href =
- process.env.VUE_APP_BASE_API +
- `/GCLSFileServer/WebFileDownload?UserCode=${data.UserCode}&UserType=${data.UserType}&SessionID=${data.SessionID}&FileID=${data.FileID}`;
- },
- // 获取pdf的页数
- getNumPages() {
- this.loading = true;
- let _this = this;
- let loadingTask = pdf.createLoadingTask(_this.attachment);
- loadingTask.promise
- .then((pdf) => {
- if (_this.data.isPurchased) {
- _this.numPages = pdf.numPages;
- } else {
- _this.numPages = 2;
- }
- _this.loading = false;
- })
- .catch((err) => {
- console.error("Pdf Loading failed", err);
- });
- },
- // 获取学习资料详情
- getdetail() {
- this.loading = true;
- let Mname = "book-book_manager-GetBook";
- // 获取课程详情
- TextbookAPI(Mname, {
- id: this.materialId,
- })
- .then((res) => {
- this.data = res;
- this.loading = false;
- this.attachment =
- process.env.VUE_APP_PDF_API +
- Base64.decode(this.$route.query.relativePath);
- this.getNumPages();
- console.log(this.attachment);
- })
- .catch((res) => {
- this.loading = false;
- });
- },
- },
- async created() {
- await updateWordPack({
- word_key_list: [
- "Key5",
- "Key8",
- "Key9",
- "Key39",
- "Key43",
- "Key52",
- "Key53",
- "Key54",
- "Key55",
- "Key58",
- "Key72",
- "Key94",
- "Key107",
- "Key109",
- "Key214",
- "Key232",
- "Key108",
- "Key396",
- "Key472",
- "Key473",
- "Key474",
- "Key572",
- "Key574",
- "Key575",
- "Key576",
- ],
- });
- this.isData = true;
- },
- mounted() {
- this.materialId = this.$route.query.id;
- if (this.materialId) {
- this.getdetail();
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .tarcer-dev-Preview {
- height: 100%;
- .main {
- min-height: 543px;
- background: #f6f6f6;
- padding-bottom: 20px;
- padding-top: 30px;
- position: relative;
- }
- .flassify {
- position: relative;
- width: 1140px;
- height: 154px;
- margin: 0 auto;
- background-color: #fff;
- border-radius: 8px;
- display: flex;
- justify-content: space-between;
- // align-items: center;
- padding: 0 30px;
- .text {
- height: 100%;
- padding-top: 24px;
- .p1 {
- font-weight: bold;
- font-size: 30px;
- color: #1f2127;
- }
- .p2 {
- margin-top: 8px;
- margin-bottom: 8px;
- font-size: 16px;
- color: #1f2127;
- }
- }
- .pay_collect {
- // position: absolute;
- // right: 30px;
- // bottom: 24px;
- height: 100%;
- padding-top: 90px;
- display: flex;
- align-content: center;
- .price {
- font-weight: bold;
- font-size: 24px;
- margin-right: 20px;
- .price_2 {
- font-size: 16px;
- }
- }
- .pay {
- width: 120px;
- height: 40px;
- background: #ff9900;
- border-radius: 4px;
- color: white;
- font-weight: 600;
- font-size: 20px;
- text-align: center;
- line-height: 40px;
- cursor: pointer;
- margin-right: 20px;
- }
- .collect {
- display: flex;
- align-items: center;
- height: 40px;
- font-weight: bold;
- font-size: 24px;
- color: #1f2127;
- img {
- width: 24px;
- margin-right: 10px;
- cursor: pointer;
- }
- }
- .download {
- height: 40px;
- margin-right: 20px;
- display: flex;
- align-items: center;
- font-weight: bold;
- font-size: 24px;
- color: #1f2127;
- img {
- width: 24px;
- margin-right: 10px;
- cursor: pointer;
- }
- }
- }
- }
- .pdf-box {
- width: 1140px;
- margin: 24px auto;
- }
- .NObuy {
- width: 1200px;
- margin: 24px auto;
- min-height: 1000px;
- filter: blur(8px);
- }
- .buyBtn {
- width: 284px;
- height: 67px;
- background: #ff9900;
- border-radius: 8px;
- text-align: center;
- line-height: 67px;
- color: white;
- font-weight: bold;
- font-size: 22px;
- margin: 0 auto;
- cursor: pointer;
- position: relative;
- top: -150px;
- }
- .dialogTitle {
- }
- }
- </style>
- <style lang="scss">
- .tarcer-dev-Preview {
- .el-dialog__body {
- padding: 30px 32px;
- }
- }
- .cui-ribbonTopBars {
- display: none !important;
- }
- </style>
|