import { VueLikePage } from '../../utils/page'
import exhibitionApi from '../../apis/exhibition'
import Router from '../../utils/routes'
VueLikePage([], {
  data: {
    active: 0,
    tabs: []
  },
  methods: {
    async onLoad () {
      let tabs = await this.getCompanyHalls()
      this.selectHall = tabs[0].name
      let companyList = await this.getCompanyByHall()
      tabs[0].list = companyList.data.list
      this.setData({
        tabs
      })
    },
    getCompanyHalls () {
      return exhibitionApi.getCompanyHalls().then(res => {
        return res.data.map(item => {
          return { name: item, list: [] }
        })
      })
    },
    getCompanyByHall () {
      return exhibitionApi.getCompanyByHall(this.selectHall).then(res => {
        return res
      })
    },
    search (value) {
      console.log('click')
      Router.push('search')
    },
    async onChange (e) {
      this.selectHall = e.detail.title
      let res = await this.getCompanyByHall()
      let tabs = this.data.tabs
      tabs[e.detail.index].list = res.data.list
      this.setData({
        tabs
      })
    },
    toScene (e) {
      const { vr_link } = e.currentTarget.dataset
      Router.push({
        url: 'scene',
        query: {
          vr_link
        }
      })
    }
  }
})