look-more.js 2.6 KB
// pages/searchRequest/searchRequest.js
let method = require("../../utils/reuqest.js")
Page({
  data: {
    list: [],
    keyword: '',
    bottomHint: false, //触底提示
    pageNum: 1,
    parameter: '' //路径参数
  },
  getMoreSpecial() {
    let postData = {
      page: 1,
      size: 10
    }
    method.postRequest("/goods/todaySpecial", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          list: data.data
        })
      }
    })
  },
  getMoreDiscount() {
    let postData = {
      page: this.data.pageNum,
      size: 10
    }
    method.postRequest("/goods/limitedTimeOffer", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          list: data.data
        })
      }
    })
  },
  getMoreMainly() {
    let postData = {
      page: 1,
      size: 10
    }
    method.postRequest("/goods/septemberMainPush", postData, data => {
      if (data.statusCode == 0) {
        this.setData({
          list: data.data
        })
      }
    })
  },
  //商品详情
  goGoodsDetail(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/product-detail/product-detail?id=' + id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options, 'options')
    this.setData({
      parameter: options.parameter
    });
    if (Number(options.parameter) == 1) {
      this.getMoreDiscount()
    } else if (Number(options.parameter) == 2) {
      this.getMoreSpecial()
    } else {
      this.getMoreMainly()
    }
  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onRefresh() {
    this.setData({
      pageNum: 1,
      list: []
    })
    let parameter = this.data.parameter;
    if (parameter==1) {
       this.getMoreDiscount()
    }else if(parameter==2){
      this.getMoreSpecial()
    }else{
      this.getMoreMainly()
    }
  },
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.setData({
      bottomHint: true
    })
    setTimeout(() => {
      this.setData({
        bottomHint: false
      })
    }, 2000)
  },

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

  }
})