import Api from '../../../apis/index'
import { fotmatDate } from '../../../utils/date'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    typeList: ['综合情况', '场景统计', '客户统计'],
    active: 1,
    date: fotmatDate(new Date(), 'yyyy-MM-dd')
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getCompanyList()
  },

  changeActive (e) {
    const { index } = e.currentTarget.dataset
    this.setData({
      active: index
    })
  },
  getCompanyList () {
    Api.getCompanyList().then(res => {
      console.log(res)
      this.companysList = res.data.list
      this.setData({
        companys: this.companysList.map(item => item.companyName),
        companyIndex: 0,
        sceneNum: this.companysList[0].sceneNum
      })
    })
  },
  bindCompanyChange (e) {
    this.setData({
      companys: this.companysList.map(item => item.companyName),
      companyIndex: e.detail.value,
      sceneNum: this.companysList[e.detail.value].sceneNum
    })
  }
})