Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectMenuId: 0, //默认是企业信息0  视频1 活动2 项目筹集3
    company_id: '', //企业Id,
    info: '', //企业信息
    loaded: false
  },
  onLoad(e) {
    var that = this
    that.company()
  },
  onUnload: function () {
    wx.removeStorageSync('company_id')
  },
  /**
   * 点击按钮触发事件
   */
  menuSelect: function (e) {
    console.log(e.currentTarget.dataset.id);
    if (this.data.selectMenuId != e.currentTarget.dataset.id) {
      this.setData({
        selectMenuId: e.currentTarget.dataset.id
      })
      if (e.currentTarget.dataset.id == 3) {
        this.selectComponent('#categoryTypeList').crowdfundcategory(this.data.company_id);
      } else if (e.currentTarget.dataset.id == 2) {
        this.selectComponent('#activeList').actives();
      } else if (e.currentTarget.dataset.id == 4) {
        this.selectComponent('#noticeList').actives();
      }
    }
  },
  /**
   * 上拉触底事件
   */
  onReachBottom() {
    if (this.data.selectMenuId == 3) {
      console.log('项目筹集触底')
      this.selectComponent('#categoryTypeList').crowdfunds();
    }
    if (this.data.selectMenuId == 2) {
      console.log('活动触底')
      this.selectComponent('#activeList').actives();
    }
    if (this.data.selectMenuId == 4) {
      console.log('动态触底')
      this.selectComponent('#noticeList').actives();
    }
  },

  /**
   * 请求项目筹集分类接口
   */
  company(id) {
    wx.showLoading({
      title: 'title',
      mask: 'true'
    })
    wx.$api.companyModule.company(wx.getStorageSync('company_id'), this.data.page).then(res => {
      this.setData({
        info: res,
        loaded: true,
      })
      wx.hideLoading({})
    }).catch(res => {
      if (res.status_code == '404') {
        // this.company(wx.getStorageSync('company_id'))
      }
    })
  },

  /**
   * 拨打电话
   */
  call() {
    wx.makePhoneCall({
      phoneNumber: this.data.info.certification.phone,
    })
  },
  /**
   * 进入商城
   */
  goMall(e) {
    console.log('1111')
    wx.navigateTo({
      url: '/pages/mall/index',
    })
  }
})