liukangdong
2024-07-23 7f899b5f769d1646fa85d191263a9df563fa005c
wechat_staff/pages/userinfo/collect.js
@@ -1,24 +1,77 @@
// pages/userinfo/collect.js
import {
  collectLikePage
} from '../../api/index'
Page({
  /**
   * 页面的初始数据
   */
  data: {
    activeTabs: '0'
  },
    activeTabs: 'product_intro',
  tabsChange(e) {
    const activeTabs = e.currentTarget.dataset.val
    this.setData({ activeTabs })
  },
  handleDetail(e) {
    wx.navigateTo({
      url: '/pages/detailDis/product',
    })
    dataList: [],
    total: 0,
    pageNum: 1,
    pageSize: 10,
  },
  onLoad(options) {
    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,
      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: `${url}?id=${id}`,
    })
  },
  getList() {
    const {
      pageSize,
      pageNum,
      activeTabs
    } = this.data
    collectLikePage({
      businessCategory: 'collect',
      businessType: activeTabs,
      pageSize,
      pageNum
    }).then(res => {
      if (res.data) {
        this.setData({
          dataList: [...this.data.dataList, ...res.data.records || []],
          total: res.data.total
        })
      }
    })
  },
  /**
@@ -59,9 +112,6 @@
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
  },
  /**
   * 用户点击右上角分享