enterprise.js 3.5 KB
let A = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navbar: [{
      name: '企业咨询'
    },
    {
      name: '企话吧'
    }
    ],
    zixunList: [],
    postList:[],
    currentTab: 1,
    page: 1,
    ifData: !1,
    noMore: !1,
    show: !0
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let c = this; wx.getSystemInfo({
      success: function (res) {
        c.setData({
          winHeight: res.windowHeight
        })
      },
    }), this.postList();
  },
  zan(e){
    let url = '/api/interact/setLike',params = {
      object_id: e.currentTarget.id,
      type:'1'
    }, index = e.currentTarget.dataset.idx,t=this,type=e.currentTarget.dataset.type;
    A.post(url,params).then((r)=>{
      t.data.postList[index].is_like = type==1?0:1
      t.data.postList[index].likes = r 
      t.setData({
        postList: t.data.postList
      })
    })
  },
  navdetail(e) {
    wx.navigateTo({
      url: '/pages/colleagues_2/colleagues_2?id='+e.currentTarget.id,
    })
  },
  getzixun() {
    let url = '/api/interact/getQuestionList', d = this, params = {
      header: true,
      page: d.data.page
    };
    A.post(url, params, false).then((r) => {
      let list = d.data.zixunList.concat(r.data);
      d.setData({
        zixunList: list
      })
      list.length == 0 ? d.setData({
        ifData: !0,
      }) : (r.data.length < r.per_page ? d.setData({
        noMore: !0
      }) : "")
      setTimeout(() => {
        d.setData({
          show: !1
        }, 1200)
      })
    })
  },
  postList() {
    let url = '/api/interact/getPostsList', d = this, params = {
      page: d.data.page
    };
    A.post(url, params, false).then((r) => {
      let list = d.data.postList.concat(r.data);
      d.setData({
        postList: list
      })
      list.length == 0 ? d.setData({
        ifData: !0,
      }) : (r.data.length < r.per_page ? d.setData({
        noMore: !0
      }) : "")

    })
  },

  askQuestion() {
    wx.navigateTo({
      url: '/pages/question/question',
    })
  },
  checkstatus() {
    let b = this, url = '/api/user/getAuthStatus', params = {
      header: true
    };
    A.post(url, params).then((r) => {
      b.setData({
        auth: r
      });
      r == 2 ? b.getzixun() : '';
    })
  },
  renzheng(e) {
    let type = e.currentTarget.dataset.type;
    type == 1 ? wx.showToast({
      title: '认证审批中请耐心等待',
      icon: 'none',
      duration: 1200
    }) : wx.navigateTo({
      url: '/pages/my/approve/approve',
    })
  },
  navbarTap: function (e) {
    let t = this, idx = e.currentTarget.dataset.idx;
    this.setData({
      currentTab: idx,
      zixunList:[],
      postList:[]
    }), idx ? t.postList() : t.getzixun();
  },
  jump() {
    wx.navigateTo({
      url: '',
    })

    wx.switchTab({
      url: '',
    })
  },

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

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.setData({
      zixunList: []
    })
    this.checkstatus()
  },

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

  },

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

  },

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

  },

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

  },

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

  }
})