yiming
2024-04-19 56b70cdad0a96691eaf37e04a79ef5e92b892480
pages/bibliographyList/index.js
@@ -251,6 +251,8 @@
          fileType: [],
          jsek_resource: [],
          freeFile: [],
          bookshelf_freeEpub: [], //epub试读百分比
          bookshelf_probationPage: [], //pdf试读页数
          ...searchObj
        },
        SysType: 'CmsItem'
@@ -265,44 +267,65 @@
      })
      wx.stopPullDownRefresh()
    },
    // downloadData(event) {
    //   this.setData({
    //     downloadLoadin: true
    //   })
    //   console.log(111);
    //   const item = event.currentTarget.dataset.item;
    //   // console.log(item.datas.freeFile.Value);
    //   const URL = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.datas.freeFile.Value
    //   item.determine = false
    //   console.log(URL, 'URL');
    //   setTimeout(() => {
    //     if (URL) {
    //       item.determine = true
    //     }
    //   }, 600)
    //   wx.downloadFile({
    //     url: URL,
    //     success: function (res) {
    //       const filePath = res.tempFilePath;
    //       wx.openDocument({
    //         filePath: filePath,
    //         success: function (res) {
    //           console.log('打开文档成功');
    //         },
    //         fail: function (res) {
    //           console.log('打开文档失败', res);
    //         }
    //       });
    //     },
    //     fail: function (res) {
    //       console.log('下载文件失败', res);
    //     }
    //   });
    //   setTimeout(() => {
    //     this.setData({
    //       downloadLoadin: false
    //     });
    //   }, 2000);
    // },
    downloadData(event) {
      this.setData({
        downloadLoadin: true
      })
      console.log(111);
      const item = event.currentTarget.dataset.item;
      // console.log(item.datas.freeFile.Value);
      const URL = app.config.requestCtx + '/file/api/ApiDownload?md5=' + item.datas.freeFile.Value
      item.determine = false
      console.log(URL, 'URL');
      setTimeout(() => {
        if (URL) {
          item.determine = true
        }
      }, 600)
      wx.downloadFile({
        url: URL,
        success: function (res) {
          const filePath = res.tempFilePath;
          wx.openDocument({
            filePath: filePath,
            success: function (res) {
              console.log('打开文档成功');
            },
            fail: function (res) {
              console.log('打开文档失败', res);
            }
      const item = event.currentTarget.dataset.item
      console.log(item);
      wx.navigateTo({
        url: "/packageBookService/pages/components/webView/index?md5=" +
          item.freeFile +
          "&fileName=" +
          item.name +
          "&fileType=" +
          item.fileType + "&bookBuy=true"
        // "&freePage=" +
        // this.data.fileInfo.freePage +
        // +
        // "&bookId=" +
        // this.data.bookDetail.id,
          });
        },
        fail: function (res) {
          console.log('下载文件失败', res);
        }
      });
      setTimeout(() => {
        this.setData({
          downloadLoadin: false
        });
      }, 2000);
    },
    onSearchSubmit: function (e) {
      const keyword = e.detail.value;