history.js 2.9 KB
// pages/myblock/pinglun/pinglun.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    page: 1,
    list: [],
    noData: true,
    noMore: !1,
    edit: !1,
    delId: [],
    tabList: [{
      name: '品牌',
      url: 'history_brand'
    }, {
      name: '酒品',
      url: 'history_wine'
    }, {
      name: '酒企',
      url: 'history_company'
    }, {
      name: '酒单',
      url: 'history_rec'
    }, {
      name: '专家品酒',
      url: 'history_expert'
    }, {
      name: '酿酒师',
      url: 'history_master'
    }, {
      name: '其他文章',
      url: 'history_article'
    }],
    selectindex:0,
    current:'history_brand'
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getList();
    let that = this;
    wx.getSystemInfo({
      success: function (t) {
        that.setData({
          scrollHeight: t.windowHeight - 50,
          windowWidth: t.windowWidth
        });
      }
    });
  },
  shareAction(e){
    let index = e.currentTarget.id;
    index!=this.data.tempIndex?this.closeShareAction():'';
    this.data.list[index].show = !this.data.list[index].show;
    this.setData({
      list: this.data.list,
      tempIndex: index
    })
  },
  closeShareAction(){
    if(this.data.tempIndex){
      let show = this.data.list[this.data.tempIndex].show;
      if (show) {
        this.data.list[this.data.tempIndex].show = false;
        this.setData({
          list: this.data.list
        })
      }
    }

  },
  tabCharge(e) {
    let s = this, singleWidth = s.data.windowWidth / 6, cur = e.currentTarget.dataset.index + 1, current = e.currentTarget.dataset.current;
    s.setData({
      selectindex: e.currentTarget.dataset.index,
      page: 1,
      current: current,
      navScrollLeft: (cur - 2) * singleWidth
    })
    this.getList();
  },

  getList() {
    let url = 'user/Center/'+this.data.current, params = {
      page: this.data.page
    };
    app.post(url, params).then(r => {
      var list = this.data.page == 1 ? r.list : this.data.list.concat(r.list);
      this.setData({
        list: list,
        totalPage: r.total_page,
        noData: list.length > 0 ? true : false,
        noMore: r.totalPage == r.page ? !0 : !1
      })
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})