<template>
  <page-layout>
    <nav-bar title="展台活动" @init="onInitNavbar"></nav-bar>
    <u-scroll-view>
      <view class="main-container">
        <view class="title">
          {{ info.title }}
        </view>
        <view class="info_item">
          <text class="label">
            活动时间：
          </text>
          <text>
            {{ info.time }}
          </text>
        </view>
        <view class="info_item">
          <text class="label">
            活动地点：
          </text>
          <text>
            {{ info.address }}
          </text>
        </view>
        <view class="content">
          <u-content :content="info.content"></u-content>
        </view>
        <exhibitor-card :exhibit="exhibitorsInfo"></exhibitor-card>
        <disclaimer-text></disclaimer-text>
      </view>
    </u-scroll-view>
  </page-layout>
</template>

<script>
import exhibitorCard from "@/pages/exhibitor/components/exhibitor-card";
import {exhibitorsBoothActivityInfo, exhibitorsInfo} from "@/api/exhibitor";
import NavBar from '@/components/layout/nav-bar'
import UScrollView from '@/components/common/u-scroll-view'
import UContent from '@/components/common/u-content'
import DisclaimerText from '@/components/disclaimer-text/index.vue'

import {returnTimeFormat} from "@/utils";
import PageLayout from "@/components/layout/page-layout";

export default {
  components: {
    PageLayout,
    exhibitorCard,
    NavBar,
    UScrollView,
    UContent,
    DisclaimerText
  },
  onLoad(options) {
    this.id = options.id
    this.getInfoEvent()
  },
  data() {
    return {
      id: 0,
      info: {},
      exhibitorsInfo: {
        exhibitors_logo: '',
        exhibitors_name_zh_cn: '',
        exhibitors_name_en_us: '',
        exhibitors_hall: '',
        exhibitors_booth_no: '',
        exhibitors_id: ''
      },
      shareInfo: {}
    };
  },
  created() {

  },
  methods: {
    onShareAppMessage() {
      return this.shareInfo
    },
    onShareTimeline() {
      return this.shareInfo
    },
    getInfoEvent() {
      exhibitorsBoothActivityInfo({id: this.id}).then(res => {
        this.info = res.data
        this.info.time = returnTimeFormat(this.info.start_time, this.info.end_time)
        this.getExhibitorsInfo(this.info.exhibitors_id)
        this.shareInfo = {
          title: this.info.title,
          path: `/pages/exhibitor/exhibitor-activity?id=` + this.id,
          imageUrl: 'https://oss.productronicachina.com.cn/resources/common/up/0000001002/20250221/67b829f60c212.png'
        }
      })
    },
    getExhibitorsInfo(id) {
      exhibitorsInfo({id: id}).then(res => {
        this.exhibitorsInfo.exhibitors_logo = res.data.logo ? res.data.logo : 'https://onlinecatelogue.productronicachina.com.cn/assets/image/normal-logo.jpg'
        this.exhibitorsInfo.exhibitors_name_zh_cn = res.data.name_zh_cn
        this.exhibitorsInfo.exhibitors_name_en_us = res.data.name_en_us
        this.exhibitorsInfo.exhibitors_hall = res.data.hall
        this.exhibitorsInfo.exhibitors_booth_no = res.data.booth_no
        this.exhibitorsInfo.exhibitors_id = res.data.id

      })
    }
  }
}
</script>

<style lang="scss">
.main-container {
  .title {
    font-size: $fontSize7;
    font-weight: bold;
    margin-bottom: 39rpx;
  }

  .content {
    margin-top: 25rpx;
  }

  .info_item {
    margin-top: 15rpx;
    font-weight: bold;
    font-size: $fontSize2;

    .label {
      font-weight: 400;
    }
  }
}
</style>
