ll
liukangdong
2024-08-27 2c08a98f7e85ec7c9376f27a7933e75e44d672f7
wechat_staff/pages/userinfo/collect.js
@@ -1,24 +1,101 @@
// pages/userinfo/collect.js
import {
  collectLikePage
} from '../../api/index'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    activeTabs: '0'
  },
    activeTabs: 'product_intro',
    dataList: [],
    total: 0,
    pageNum: 1,
    pageSize: 10,
  },
  onLoad(options) { },
  onPullDownRefresh: function () {
    console.log('下拉刷新')
    this.setData({
      dataList: [],
      pageNum: 1,
      total: 0
    })
    wx.stopPullDownRefresh()
    this.getList()
  },
  onReachBottom() {
    console.log('触底事件')
    const {
      total,
      dataList,
      pageNum
    } = this.data
    if (total > dataList.length) {
      this.setData({
        pageNum: pageNum + 1
      })
      this.getList()
    } else {
      wx.showToast({
        title: '暂无更多数据',
        icon: 'none'
      })
    }
  },
  tabsChange(e) {
    const activeTabs = e.currentTarget.dataset.val
    this.setData({ activeTabs })
    this.setData({
      activeTabs,
      dataList: [],
      total: 0,
      pageNum: 1
    })
    this.getList()
  },
  handleDetail(e) {
    const id = e.currentTarget.dataset.id
    const {
      activeTabs
    } = this.data
    let url = ''
    if (activeTabs == 'product_intro') {
      url = '/pages/detailDis/product'
    } else if (activeTabs == 'whole_case') {
      url = '/pages/detailDis/case'
    } else {
      url = '/pages/detailDis/realpic'
    }
    wx.navigateTo({
      url: '/pages/detailDis/product',
      url: `${url}?id=${id}`,
    })
  },
  onLoad(options) {
  getList() {
    const {
      pageSize,
      pageNum,
      activeTabs
    } = this.data
    collectLikePage({
      businessCategory: 'collect',
      businessType: activeTabs,
      pageSize,
      pageNum
    }).then(res => {
      if (res.data) {
        // res.data.pageNum =  res.data.pageNum <=0?1: res.data.pageNum
        // if(pageNum == res.data.pageNum){
        //   if(pageNum == 1){
        //     this.setData({dataList:[],total:0})
        //   }
        this.setData({
          dataList: [...this.data.dataList, ...res.data.records || []],
          total: res.data.total
        })
        // }
      }
    })
  },
  /**
@@ -32,7 +109,11 @@
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.setData({
      pageNum: 1,
      dataList: []
    })
    this.getList()
  },
  /**
@@ -59,9 +140,6 @@
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享