yiming
2024-06-21 f5932f85898de7284c9f16d314b4a1c572b31c73
pages/bibliographyList/index.js
@@ -1,4 +1,5 @@
// pages/bibliographyList/index.js
import Toast from 'tdesign-miniprogram/toast/index';
const app = getApp()
const config =
  Page({
@@ -7,6 +8,10 @@
     * 页面的初始数据
     */
    data: {
      personalDataEmail: '',
      hiddenmodalput: false,
      name: "",
      phoneNum: '',
      input: '',
      dialogKey: '',
      showWithInput: false,
@@ -29,6 +34,9 @@
      emailError: false,
      loading: true, //开启骨架屏加载
      hidden: true, //是否展示内容
      height: '',
      dialogBox: false,
      inputStyle: 'border: 2rpx solid rgba(220,220,220,1);border-radius: 12rpx; padding: 0 0 0 16rpx;height:70rpx',
    },
    /**
@@ -38,7 +46,6 @@
      this.higherGet()
      this.vocationalGet()
      this.teacherGet()
      const systInfo = wx.getSystemInfoSync();
      const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息
      const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度
@@ -46,19 +53,23 @@
        navBarHeight: navBarHeight,
        barHeight: systInfo.statusBarHeight,
      })
      let event = {
        detail: {
          value: "0"
        }
      }
      this.onTabsChange(event)
      var that = this;
      // 动态获取屏幕高度
      wx.getSystemInfo({
        success: (result) => {
          that.setData({
            height: result.windowHeight
          });
        },
      })
      this.ceShi()
    },
    /**
@@ -72,7 +83,8 @@
     * 生命周期函数--监听页面显示
     */
    onShow() {
      console.log(this.data.value);
      // console.log(this.data.value);
    },
    /**
@@ -110,41 +122,26 @@
    },
    onTabsChange(event) {
      const value = event.detail.value
      if (value === '0') {
        console.log(value);
        this.setData({
          tabValue: value,
          isMore: false
        })
      } else if (value === '1') {
        console.log(value);
        this.setData({
          tabValue: value,
          isMore: false
        })
      } else if (value === '2') {
        console.log(value);
        this.setData({
          tabValue: value,
          isMore: false
        })
      this.setData({
        isMore: null,
        tabValue: value,
      })
      if (value == '0') {
        this.higherGet()
      } else if (value == '1') {
        this.vocationalGet()
      } else if (value == '2') {
        this.teacherGet()
      }
    },
    //高等教育
    higherGet(keyword) {
      console.log(keyword, 'keyword');
      let searchObj = {
        'Name*': keyword,
        '||author*': keyword,
        '||isbn*': keyword
      }
      app.MG.resource.getItem({
        path: 'jsek_biblioClassification\\jsek_bCHigherEducation',
        queryType: '*',
@@ -157,8 +154,8 @@
        },
        fields: {
          jsek_link: [],
          content: [],
          subtitle: [],
          content: [],
          fileType: [],
          jsek_resource: [],
          freeFile: [],
@@ -166,24 +163,24 @@
        },
        SysType: 'CmsItem'
      }).then(res => {
        res.datas.forEach(item => {
          item.determine = true
        })
        console.log(res, 789111);
        this.setData({
          higherList: res.datas,
          higherTotal: res.total
          higherTotal: res.total.le
        })
        console.log(this.data.higherList, '5555');
        this.setData({
          loading: false, //开启骨架屏加载
          hidden: false, //是否展示内容
        })
        if (res.datas.length < 7 && res.datas.length > 0) {
          this.setData({
            isMore: false
          })
        }
      })
      wx.stopPullDownRefresh()
    },
    //教师教育
@@ -192,7 +189,6 @@
        'Name*': keyword,
        '||author*': keyword,
        '||isbn*': keyword
      }
      app.MG.resource.getItem({
        path: 'jsek_biblioClassification\\jsek_bCVocationalEducation',
@@ -215,6 +211,7 @@
        },
        SysType: 'CmsItem'
      }).then(res => {
        console.log(res);
        res.datas.forEach(item => {
          item.determine = true
        })
@@ -222,7 +219,11 @@
          vocationalList: res.datas,
          vocationalTotal: res.total
        })
        if (res.datas.length < 7 && this.datas.length > 0) {
          this.setData({
            isMore: false
          })
        }
      })
      wx.stopPullDownRefresh()
    },
@@ -232,7 +233,6 @@
        'Name*': keyword,
        '||author*': keyword,
        '||isbn*': keyword
      }
      app.MG.resource.getItem({
        path: 'jsek_biblioClassification\\jsek_bCTeacherEducation',
@@ -264,6 +264,11 @@
          teacherList: res.datas,
          teacherTotal: res.total
        })
        if (res.datas.length < 7 && this.datas.length > 0) {
          this.setData({
            isMore: false
          })
        }
      })
      wx.stopPullDownRefresh()
    },
@@ -307,25 +312,31 @@
    //   }, 2000);
    // },
    downloadData(event) {
      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 +
      if (item.fileType == "pdf") {
        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,
      });
            +
            "&bookId=" +
            item.id,
        });
      } else {
        Toast({
          context: this,
          selector: '#t-toast',
          message: '此书不能查看',
          theme: 'warning',
          direction: 'column',
        });
      }
    },
    onSearchSubmit: function (e) {
      const keyword = e.detail.value;
@@ -335,14 +346,11 @@
      this.vocationalGet(keyword)
      this.teacherGet(keyword)
    },
    goBack() {
      wx.navigateBack();
    },
    onReachBottom(e) {
      if (this.data.tabValue == 0) {
        console.log(0);
        if (this.data.higherList.length < this.data.higherTotal) {
          this.setData({
            isMore: true,
@@ -358,11 +366,8 @@
              isMore: false
            })
          }, 100)
        }
      } else if (this.data.tabValue == 1) {
      } else if (this.data.tabValue == 2) {
        if (this.data.teacherList.length < this.data.teacherTotal) {
          this.setData({
            isMore: true,
@@ -378,12 +383,11 @@
              isMore: false
            })
          }, 100)
        }
        console.log(2);
      } else if (this.data.tabValue == 2) {
        if (this.data.vocationalList.length < this.data.vocationalTotal && this.data.vocationalList.length > 9) {
      } else if (this.data.tabValue == 1) {
        console.log(this.data.vocationalList.length);
        console.log(this.data.vocationalTotal);
        if (this.data.vocationalList.length < this.data.vocationalTotal) {
          this.setData({
            isMore: true,
            start: this.data.start + 1
@@ -398,13 +402,8 @@
              isMore: false
            })
          }, 100)
        }
        console.log(2);
      }
    },
    onPullDownRefresh() {
@@ -420,49 +419,46 @@
    mailbox(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
      });
        Md5: item.datas.freeFile.FileList[0].Md5,
        dialogBox: true
      })
      // wx.scanCode({
      //   success: res => {
      //     console.log(res);
      //   }
      // })
    },
    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);
    // 弹窗取消
    closeDialog() {
      this.setData({
        emailError: !isEmailValid,
        "input": e.detail.value,
      });
        dialogBox: false,
        // input: ''
      })
    },
    //弹窗确认
    onConfirm() {
      if (!this.data.emailError && this.data.input) {
        const {
          dialogKey
        } = this.data;
    //提交
    confirmM(e) {
      wx.showLoading({
        title: '发送中...',
      })
      const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(this.data.input);
      if (isEmailValid && this.data.input) {
        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);
          })
          dialogBox: false
        })
        let query = {
          eMail: this.data.input,
          md5s: [this.data.Md5]
        }
        app.MG.file.sendFileWithEmail(query).then(res => {
          wx.hideLoading()
          if (res) {
            wx.showToast({
              icon: 'success',
              title: '邮件已发送',
            })
          }
        })
      } else {
        // 校验不通过,给出错误提示
        wx.showToast({
@@ -470,19 +466,31 @@
          icon: 'none',
        });
      }
    },
    // 弹窗取消
    closeDialog() {
      const {
        dialogKey
      } = this.data;
    inputChange(e) {
      this.setData({
        [dialogKey]: false
      });
      console.log(111);
        input: e.detail.value
      })
    },
    ceShi() {
      let that = this;
      // 获取Storage中的数据
      wx.getStorage({
        key: 'website-front-userInfo',
        success(res) {
          let datas = JSON.parse(res.data)
          console.log(datas.Email);
          let personalData = JSON.parse(datas.data)
          that.setData({
            input: datas.Email
          })
          console.log(that.data.value);
        },
        fail(err) {
          console.error(err);
        }
      });
    }
  })