zhuanqu.js 3.2 KB
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page:1,
    zhuanqulist:[],
    activeid: '',
    activelist:[],
    c_index:0,
    price:false,
    sale:false,
    order:'',
    showpull:true
  },

  // 排序
  reorder(e) {
    let that = this
    that.setData({
      activelist:[],
      page:1
    })
    let index = Number(e.currentTarget.dataset.index)
    if(index==0){
      this.setData({
        order:''
      })
    }
    if (index == 1) {
      that.setData({
        price:!that.data.price
      })
      if(that.data.price==true){
        that.setData({
          order:1
        })
      }else{
        that.setData({
          order:2
        })
      }
     
    } else if (index == 2) {
      that.setData({
        sale:!that.data.sale
      })
      if(that.data.sale==true){
        that.setData({
          order:3
        })
      }else{
        that.setData({
          order:4
        })
      }
    }
    this.setData({
      c_index: e.currentTarget.dataset.index,
      page: 1,
      page_type: false
    })

    that.getmorelist()
    //调用排序接口
    // this.good_list(this.data.cid, e.currentTarget.dataset.index)
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      activeid:options.id
    })
    this.getmorelist()

  },

  //轮播图
  look_more(e) {
    let id = e.currentTarget.dataset.id;
    console.log(id)
    let type=e.currentTarget.dataset.type;
    if(type==1){
      wx.navigateTo({
        url: '/pages/shop_detail/shop_detail?id=' + id
      })
    }else{
      wx.navigateTo({
        url: '/pages/taocandetail/taocandetail?id=' + id
      })
    }
   
    
  },
  getmorelist(){
    let that = this
    let url = '/activity/get_detail';
    let data = {
      activity_id:that.data.activeid,
      page: that.data.page,
      pageNum: 10,
      order:that.data.order,

    }
    app.postk(url, data, "POST").then((r) => {
      console.log(r)
      that.setData({
        activelist: that.data.activelist.concat(r.data)
        
      })
      if(that.data.page>1){
        if(r.data.length==0){
          wx.showToast({
            title: '没有更多了~',
            icon:"none"
          })
          that.setData({
            showpull:false
          })
        }
      }

      console.log(that.data.activelist)

    }).catch((err) => { })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let newpage=this.data.page;
    newpage++;
   this.setData({
     page:newpage
   })

   if(this.data.showpull==true){
    this.getmorelist()
   }
 
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})