litian
2024-06-26 ccda9ec2fe70d8f51ef184eafc04b78d22dfbabd
pages/home/home.js
@@ -11,6 +11,7 @@
    barHeight: '',
    navBarHeight: '',
    searchVal: '',
    scoll: false,
    isWhite: false,
    userInfo: {},
    tabList: [], //目录
@@ -36,9 +37,14 @@
    shoppingCartGetId: [],
    baseRefresh: {
      value: false
    }
    },
    loading: true
  },
  onShow() {
    this.setData({
      searchVal: "",
    });
    console.log(this.data.searchVal)
    this.loadHomePage();
    this.getBannerList()
@@ -111,11 +117,13 @@
        const item = res.datas[i]
        list.push({
          value: item.icon,
          link: item.jsek_link
          link: item.jsek_link,
        })
      }
      this.setData({
        bannerList: list
        bannerList: list,
        loading: false
      })
    })
  },
@@ -143,6 +151,7 @@
  //点击目录
  toPages(item) {
    let info = item.target.dataset.info
    console.log(info);
    if (info.url) {
      if (info.text == "图书服务") {
        wx.switchTab({
@@ -583,20 +592,40 @@
  },
  // 监听滚动条
  onScroll(e) {
    this.setData({
      isWhite: true
    })
    this.setData({
      isWhite: e.detail.scrollTop > 20 ? true : false
  // 扫一扫
  onIconScanTap() {
    wx.scanCode({
      success(res) {
        console.log(res);
        if (res.errMsg == "scanCode:ok" && res.path) {
          console.log(res.path, 2)
          wx.redirectTo({
            url: '/' + res.path,
          })
        }
      }
    })
  },
  onScrollToTop(e) {
  // 监听滚动条
  onScroll(e) {
    if (this.data.scoll) {
      if (e.detail.scrollTop < 20) {
        this.data.scoll = false
        this.isChange(false);
      }
    } else {
      if (e.detail.scrollTop > 20) {
        this.data.scoll = true
        this.isChange(true);
      }
    }
  },
  isChange(data) {
    this.setData({
      isWhite: e.detail.scrollTop > 50 ? true : false
      isWhite: data
    })
  },