yiming
2024-04-15 f86bd75868eb9b0e81d5cb43d6e76c08a0da3083
pages/retrievalPage/index.js
@@ -1,7 +1,9 @@
// pages/retrievalPage/index.js
import request from '../../assets/request/index'
import { handleQueryResourceListData } from '../../assets/js/middleGround/tool'
import {
  handleQueryResourceListData
} from '../../assets/js/middleGround/tool'
const app = getApp()
Page({
@@ -9,22 +11,29 @@
   * 页面的初始数据
   */
  data: {
    loading: true,
    hidden: true,
    input: '',
    dialogKey: '',
    showWithInput: false,
    showTextAndTitleWithInput: false,
    downloadLoadin: false,
    isMore: null,
    tabPanelstyle: 'display:flex;justify-content:center;align-items:center;',
    navBarHeight: '',
    barHeight: '',
    searchVal: '',
    bookData: [],   //图书
    bookData: [], //图书
    bookTotal: 0,
    courseData: [],  //课程
    courseData: [], //课程
    courseTotal: 0,
    digitalTextbooksData: [],  //数字教材
    digitalTextbooksData: [], //数字教材
    digitalTextbooksTotal: 0,
    seminarData: [], //专题研讨
    seminarTotal: 0,
    biblioClassificationData: [],//书展
    biblioClassificationData: [], //书展
    biblioClassificationTotal: 0,
    bookFairData: [],//书目
    bookFairData: [], //书目
    bookFairTotal: 0,
    pageCount: {
      page: 1,
@@ -37,6 +46,8 @@
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(app.config.appId);
    const systInfo = wx.getSystemInfoSync();
    const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
    const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
@@ -56,6 +67,8 @@
      }
    }
    this.onTabsChange(event)
  },
  /**
@@ -122,11 +135,14 @@
  //标签的切换
  onTabsChange(event) {
    const value = event.detail.value
    console.log(value);
    if (value === '0') {
      this.setData({
        tabValue: value,
        isMore: false
      })
    } else if (value === '1') {
      console.log(value, 'tab');
      this.setData({
@@ -189,7 +205,7 @@
    let queryBook = {
      AccessControl: {
        Path: '*',
        StoreRefCode: 'defaultGoodsStore27',
        StoreRefCode: `defaultGoodsStore${app.config.appId}`,
        Type: '*',
        LinkType: ''
      },
@@ -197,11 +213,9 @@
        Start: 0,
        Size: this.data.pageCount.page * 9,
      },
      SortQuery: [
        {
          LinkOrder: 'Desc'
        }
      ],
      SortQuery: [{
        LinkOrder: 'Desc'
      }],
      CreateDate: [],
      Description: [],
      Name: [],
@@ -242,11 +256,9 @@
        Start: 0,
        Size: this.data.pageCount.page * 4
      },
      SortQuery: [
        {
          LinkOrder: 'Desc'
        }
      ],
      SortQuery: [{
        LinkOrder: 'Desc'
      }],
      CreateDate: [],
      Description: [],
      Name: [],
@@ -286,11 +298,9 @@
        Start: 0,
        Size: this.data.pageCount.page * 9,
      },
      SortQuery: [
        {
          LinkOrder: 'Desc'
        }
      ],
      SortQuery: [{
        LinkOrder: 'Desc'
      }],
      CreateDate: [],
      Description: [],
      Name: [],
@@ -331,11 +341,9 @@
        Start: 0,
        Size: this.data.pageCount.page * 6,
      },
      SortQuery: [
        {
          LinkOrder: 'Desc'
        }
      ],
      SortQuery: [{
        LinkOrder: 'Desc'
      }],
      CreateDate: [],
      Description: [],
      Name: [],
@@ -375,11 +383,9 @@
        Start: 0,
        Size: this.data.pageCount.page * 10
      },
      SortQuery: [
        {
          LinkOrder: 'Desc'
        }
      ],
      SortQuery: [{
        LinkOrder: 'Desc'
      }],
      CreateDate: [],
      Description: [],
      Name: [],
@@ -418,7 +424,7 @@
      method: 'post',
      data: body
    }).then((resp) => {
      // console.log(resp);
      console.log(resp, 'resp');
      //图书       0
      const data1 = resp[0]
@@ -487,11 +493,17 @@
        biblioClassificationTotal: data5.totalCount
      })
      this.setData({
        loading: false,
        hidden: false,
      })
    })
    wx.stopPullDownRefresh()
  },
  bibliographyGet() {
    let bibliographyObj = {}
@@ -591,8 +603,8 @@
    console.log("下拉刷新...");
  },
  /**
     * 页面上拉触底事件的处理函数
     */
   * 页面上拉触底事件的处理函数
   */
  onReachBottom(e) {
    if (this.data.tabValue == 0) {
      console.log(0);
@@ -706,17 +718,13 @@
            isMore: false
          })
        }, 100)
      }
    }
  },
  // 下拉函数
  onPullDownRefresh() {
    console.log(456);
    if (this.data.tabValue == 4) {
      this.setData({
        "pageCount.page": 1
@@ -728,8 +736,190 @@
      })
      this.retrievalPageGet()
    }
  },
  underConstruction() {
    wx.showToast({
      title: "建设中",
      icon: 'none',
      duration: 1000
    })
  },
  // 邮箱点击
  mailbox(e) {
    console.log(e);
    const key = e.currentTarget.dataset.key;
    const item = e.currentTarget.dataset.item;
    this.setData({
      [key]: true,
      dialogKey: key,
      input: '',
      Md5: item.datas.freeFile.FileList[0].Md5
    });
  },
  //邮箱的校验
  onEmailInput(e) {
    const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(e.detail.value);
    this.setData({
      emailError: !isEmailValid,
      "input": e.detail.value,
    });
  },
  //弹窗确认
  onConfirm() {
    if (!this.data.emailError && this.data.input) {
      const {
        dialogKey
      } = this.data;
      this.setData({
        [dialogKey]: false
      });
      console.log(this.data.input);
      console.log(this.data.Md5);
      if (this.data.input) {
        let query = {
          eMail: this.data.input,
          md5s: [this.data.Md5]
        }
        app.MG.file.sendFileWithEmail(query).then(res => {
          console.log(res);
        })
      }
    } else {
      // 校验不通过,给出错误提示
      wx.showToast({
        title: '邮箱格式不正确',
        icon: 'none',
      });
    }
  },
  // 弹窗取消
  closeDialog() {
    const {
      dialogKey
    } = this.data;
    this.setData({
      [dialogKey]: false
    });
    console.log(111);
  },
  onScrollToLower() {
    if (this.data.tabValue == 0) {
      console.log(0);
      if (this.data.bookData.length < this.data.bookTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
    } else if (this.data.tabValue == 1) {
      if (this.data.courseData.length < this.data.courseTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(2);
    } else if (this.data.tabValue == 2) {
      if (this.data.digitalTextbooksData.length < this.data.digitalTextbooksTotal && this.data.digitalTextbooksData.length > 9) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(2);
    } else if (this.data.tabValue == 3) {
      if (this.data.seminarData.length < this.data.seminarTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(3);
    } else if (this.data.tabValue == 4) {
      if (this.data.bookFairData.length < this.data.bookFairTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.bibliographyGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
      console.log(4);
    } else if (this.data.tabValue == 5) {
      if (this.data.biblioClassificationData.length < this.data.biblioClassificationTotal) {
        this.setData({
          isMore: true,
          "pageCount.page": this.data.pageCount.page + 1
        })
        this.retrievalPageGet()
      } else {
        this.setData({
          isMore: true,
        })
        setTimeout(() => {
          this.setData({
            isMore: false
          })
        }, 100)
      }
    }
  },
  onTabsClick(event) {
    console.log(`Click tab, tab-panel value is ${event.detail.value}.`);
  },
})