litian
2024-06-28 232e4dcf0fc80bdcfff1bdf45431e67c25831fb6
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
// pages/index/resourceCover.js
const app = getApp()
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    webpageSrc: "",
    bookId: 0,
    bookName: '',
    cmsId: '',
    productLinkPath: '',
    parentProductLinkPath: '',
    formPath: ''
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if (options.scene) {
      this.getBookInfo(options.scene)
    }
  },
 
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
 
  },
 
  getBookInfo(refcode) {
    const obj = {
      storeInfo: app.config.jslx,
      path: app.config.jslx,
      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}&storeInfo=${book.storeInfo}&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");
        // wx.redirectTo({
        //   url: "/packageBookService/pages/bookServices/webView/index?url=" + fileLink
        // });
        //提示加载中
        // 单次下载允许的最大文件为 200MB
 
      }
    })
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
 
  }
})