yiming
2024-02-29 9f1e740e07085a7fc74defe5d63bcc4818aab69e
pages/bibliographyList/index.js
@@ -1,5 +1,6 @@
// pages/bibliographyList/index.js
const app = getApp()
const config =
Page({
  /**
@@ -11,7 +12,10 @@
    teacherList: [],
    higherTotal: null,
    vocationalTotal: null,
    teacherTotal: null
      teacherTotal: null,
      value: '',
      BarHeight: '',
      navBarHeight: ''
  },
  /**
@@ -21,6 +25,21 @@
    this.higherGet()
    this.vocationalGet()
    this.teacherGet()
      //获取系统信息,状态栏高度为sysInfo['statusBarHeight'];
      let sysInfo = wx.getSystemInfoSync();
      let menu = wx.getMenuButtonBoundingClientRect(); //胶囊信息
      let navBarHeight = (menu.top - sysInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
      this.setData({
        BarHeight: sysInfo.statusBarHeight, navBarHeight: navBarHeight
      })
  },
  /**
@@ -34,7 +53,7 @@
   * 生命周期函数--监听页面显示
   */
  onShow() {
      console.log(this.data.value);
  },
  /**
@@ -79,7 +98,14 @@
    console.log(`Click tab, tab-panel value is ${event.detail.value}.`);
  },
  //高等教育
  higherGet() {
    higherGet(keyword) {
      let searchObj = {
        'Name*': keyword,
        '||author*': keyword,
        '||isbn*': keyword
      }
    app.MG.resource.getItem({
      path: 'jsek_biblioClassification\\jsek_bCHigherEducation',
      queryType: '*',
@@ -96,11 +122,16 @@
        subtitle: [],
        fileType: [],
        jsek_resource: [],
        freeFile: []
          freeFile: [],
          ...searchObj,
      },
      SysType: 'CmsItem'
    }).then(res => {
      console.log(res.total);
        res.datas.forEach(item => {
          item.determine = true
        })
        console.log(res, 789111);
      this.setData({
        higherList: res.datas,
        higherTotal: res.total
@@ -112,7 +143,13 @@
  },
  //教师教育
  vocationalGet() {
    vocationalGet(keyword) {
      let searchObj = {
        'Name*': keyword,
        '||author*': keyword,
        '||isbn*': keyword
      }
    app.MG.resource.getItem({
      path: 'jsek_biblioClassification\\jsek_bCVocationalEducation',
      queryType: '*',
@@ -129,10 +166,14 @@
        subtitle: [],
        fileType: [],
        jsek_resource: [],
        freeFile: []
          freeFile: [],
          ...searchObj
      },
      SysType: 'CmsItem'
    }).then(res => {
        res.datas.forEach(item => {
          item.determine = true
        })
      this.setData({
        vocationalList: res.datas,
        vocationalTotal: res.total
@@ -141,7 +182,13 @@
    })
  },
  // 职业教育
  teacherGet() {
    teacherGet(keyword) {
      let searchObj = {
        'Name*': keyword,
        '||author*': keyword,
        '||isbn*': keyword
      }
    app.MG.resource.getItem({
      path: 'jsek_biblioClassification\\jsek_bCTeacherEducation',
      queryType: '*',
@@ -158,10 +205,14 @@
        subtitle: [],
        fileType: [],
        jsek_resource: [],
        freeFile: []
          freeFile: [],
          ...searchObj
      },
      SysType: 'CmsItem'
    }).then(res => {
        res.datas.forEach(item => {
          item.determine = true
        })
      this.setData({
        teacherList: res.datas,
        teacherTotal: res.total
@@ -170,5 +221,47 @@
    })
    },
    downloadData(event) {
      const item = event.currentTarget.dataset.item;
      // console.log(item.datas.freeFile.Value);
      const URL = 'http://182.92.203.7:3001/file/api/ApiDownload?md5=' + item.datas.freeFile.Value
      item.determine = false
      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);
        }
      });
    },
    onSearchSubmit: function (e) {
      const keyword = e.detail.value;
      // 处理搜索逻辑,例如发送搜索请求等
      console.log('搜索关键词:', keyword);
      this.higherGet(keyword)
      this.vocationalGet(keyword)
      this.teacherGet(keyword)
    },
})