杨磊
4 天以前 ef37c59e055a990ce247b265b27d3fcef430a243
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<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>