<template>
  <view>
    <view class="activities_header">
      <view>
        <view class="name"> {{ useModel?.showData?.value?.title }} </view>
        <view class="time">
          活动时间：{{ showDay(useModel?.showData?.value?.start_time) }} 至
          {{ showDay(useModel?.showData?.value?.end_time) }}
        </view>
      </view>
      <view :class="`status event_status_${useModel?.showData?.value?.status}`">
        <hs-enum-tag
          :value="useModel?.showData?.value?.status"
          :Enums="HouseChargeTasksStatusEnum"
        />
      </view>
    </view>
    <view class="activities_content">
      <up-parse :content="useModel?.showData?.value?.content"></up-parse>
    </view>
    <view class="footer">
      <view class="btn">
        <hs-button
          size="md"
          type="display"
          :disabled="
            !getIsInRangeInclusive(
              useModel?.showData?.value?.start_time,
              useModel?.showData?.value?.end_time
            )
          "
          label="取消报名"
          @click="method?.handleCancelSignUp"
        />
      </view>
      <view class="btn">
        <hs-button size="md" type="primary" label="分享活动" openType="share" />
      </view>
    </view>
  </view>
</template>

<script setup lang="ts">
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
import method from './method'
import useModel from './model'
import { showDay } from '@/common/libraries/day'
import { HouseChargeTasksStatusEnum } from '@/gen/Enums'
import { getIsInRangeInclusive } from '@/common/libraries/day'
onLoad((e: any) => {
  method?.getShow(e?.id)
})

onShareAppMessage(() => {
  return {
    title: `您的好友邀请你报名${useModel?.showData?.value?.title}`,
    path: `/INDEX/activities_show/index?id=${useModel?.showData?.value?.id}`,
    imageUrl: useModel?.showData?.value?.cover_image[0]?.url
  }
})
onShareTimeline(() => {
  return {
    title: `您的好友邀请你报名${useModel?.showData?.value?.title}`,
    path: `/INDEX/activities_show/index?id=${useModel?.showData?.value?.id}`,
    imageUrl: useModel?.showData?.value?.cover_image[0]?.url
  }
})
</script>

<style lang="scss">
@import './style.scss';
</style>
