enterprise.js 3.0 KB
let t = 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();
  },
  getzixun() {
    let url = '/api/interact/getQuestionList', d = this, params = {
      header: true,
      page: d.data.page
    };
    t.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
    };
    t.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
    };
    t.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,
    }), 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 () {

  }
})