brandlist.js 2.6 KB
// pages/homeblock/brandlist/brandlist.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbar: ['在售','预售','停产在售','停售'],
    currentTab: 0,
    url:"",
    status:1,
    brandid:'',
    page:1,
    info:'',
    brandlist:[]

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.setData({
      url: app.globalData.url,
      brandid:options.id
    })

    this.getbrandlist()
  },
  navbarTap: function (e) {
    this.setData({
      currentTab: e.currentTarget.dataset.idx,
      
      status:e.currentTarget.dataset.idx+1

    })
    this.getbrandlist()
    
  },

  //获取品牌主主页
  getbrandlist(){
    let that = this;
    let url = 'index/Brand/index', params = {
      status: that.data.status,
      id: that.data.brandid,
      page:that.data.page


    }
    app.post(url, params).then((res) => {
      console.log(res);
      that.setData({
        info: res.info,
        brandlist:res.list
      })



    }).catch((err) => {

    })

  },
  //收藏品牌
  collectbrand(e){
    let that = this;
    let id=e.currentTarget.dataset.id

    let url = 'index/Common/favorite', params = {
      sort: 2,
      id:id
    }
    app.post(url, params).then((res) => {
      console.log(res);
      wx.showToast({
        title: res,
        icon:'none'
      })
      that.getbrandlist()


    }).catch((err) => {

    })
  },
//收藏酒品
  collectwine(e){
    
    let that = this;
    let id = e.currentTarget.dataset.id;
    let url = 'index/Common/favorite', params = {
      sort:1,
      id:id

    }
    app.post(url, params).then((res) => {
      console.log(res);
      wx.showToast({
        title: res,
        icon:'none'
      })
      that.getbrandlist()


    }).catch((err) => {

      })


  },
  //品牌详情页
  brandinfo(e){
    let id=e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/homeblock/brandpage/brandpage?id='+id,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

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

  }
})