<template>
  <view>
    <home v-show="tabbarActive === 'home'" @switch-tab="switchTab" />
    <exhibitor v-if="tabbarActive === 'exhibitor'"  @share="onShare" />
    <activity v-if="tabbarActive === 'activity'" />
    <user v-if="tabbarActive === 'user'" />
    <product v-if="tabbarActive === 'product'"></product>
    <van-dialog id="van-dialog" />
    <tab-bar :active.sync="tabbarActive"></tab-bar>
    <u-share-action-sheet :show.sync="showShare" :show-info="shareInfo" />
  </view>
</template>

<script>
import TabBar from '@/components/layout/tab-bar.vue'
import UShareActionSheet from '@/components/common/u-share-action-sheet'
import Home from '@/pages/index/home.vue'
import Exhibitor from '@/pages/exhibitor/index.vue'
import Activity from '@/pages/activity/index.vue'
import User from '@/pages/user/index.vue'
import PageLayout from "@/components/layout/page-layout";
import Product from "@/pages/exhibitor/exhibit"
export default {
  options: {
    styleIsolation: 'shared'
  },
  components: {
    PageLayout,
    TabBar,
    Home,
    Exhibitor,
    Activity,
    User,
    UShareActionSheet,
    Product
  },
  watch: {
    '$store.getters.page': {
      handler(val) {
        this.tabbarActive = val[val.length-1]

      }
    }
  },
  data() {
    return {
      tabbarActive: 'home',
      showShare: false,
      shareInfo: null
    }
  },
  onLoad(options) {
    if (options.tab) {
      this.tabbarActive = options.tab
    }
  },
  created() {

  },
  methods: {
    switchTab(active) {
      this.tabbarActive = active
    },
    onShare(e) {
      this.shareInfo = e.detail
      this.showShare = true
    },
    onShareAppMessage: function (res) {
      if (res.from === 'button') {
        if (this.shareInfo) {
          return this.shareInfo
        }
      }
      this.shareInfo = null
      this.showShare = false
      return {
        title: '慕尼黑上海电子生产设备展',
        path: '/pages/index/index',
        imageUrl: 'https://oss.productronicachina.com.cn/resources/common/up/0000001002/20250221/67b829f60c212.png?x-oss-process=image/resize,w_600,h_600,limit_0,m_pad'
      }
    },
    onClickSearch() {

    }
  }
}
</script>

<style lang="scss">
</style>
