<template>
  <view>
    <view class="push_content">
      <view class="push_header">
        <view class="avatar">
          <image :src="auth?.data?.user?.avatar?.[0]?.url" mode="heightFix" />
        </view>
        <view class="employee_info">
          <view class="name">
            {{ auth?.data?.user?.name || '员工名称' }}
          </view>
          <view class="des">
            {{ useModel?.showData?.value?.title }}
          </view>
        </view>
        <view :class="`status status_${useModel?.status?.value}`">
          {{ useModel?.status?.value === 'Sent' ? '已发送' : '待发送' }}
        </view>
      </view>
      <view class="image_content" v-if="useModel?.showData?.value?.content_type === 'Image'">
        <image
          v-for="(i, index) in useModel?.showData?.value?.attachments"
          :key="`img_${index}`"
          :src="i.url"
          mode="aspectFill"
        />
      </view>
      <view class="Link_content" v-if="useModel?.showData?.value?.content_type === 'Link'">
        <view class="cover">
          <image
            v-for="(i, index) in useModel?.showData?.value?.cover_image"
            :key="`img_${index}`"
            :src="i.url"
            mode="aspectFill"
          />
        </view>
        <view class="content">
          {{ useModel?.showData?.value?.content }}
        </view>
      </view>
      <view class="video_content" v-if="useModel?.showData?.value?.content_type === 'Video'">
        <video
          id="myVideo"
          :src="useModel?.showData?.value?.attachments?.[0]?.url"
          enable-danmu
          danmu-btn
          controls
        ></video>
      </view>
      <view
        class="miniProgram_content"
        v-if="useModel?.showData?.value?.content_type === 'MiniProgram'"
      >
        <view class="miniProgram_title">
          {{ useModel?.showData?.value?.content }}
        </view>
        <view class="miniProgram_cover">
          <image :src="useModel?.showData?.value?.cover_image?.[0]?.url" mode="aspectFill" />
        </view>
      </view>
    </view>

    <hs-footer
      v-if="useModel?.showData?.value?.channel === 'MomentCorp'"
      btnParimaryName="发送客户朋友圈"
      @handleParmaryClick="method?.handleMomentCorpSend"
      :parimaryDisabled="useModel?.status?.value === 'Sent'"
    />
    <hs-footer
      v-if="useModel?.showData?.value?.channel === 'CustomerDirectCorp'"
      btnParimaryName="1对1群发客户"
      @handleParmaryClick="method?.handleCustomerDirectCorpSend"
      :parimaryDisabled="useModel?.status?.value === 'Sent'"
    />
    <hs-footer
      v-if="useModel?.showData?.value?.channel === 'CustomerGroupCorp'"
      btnParimaryName="群发客户群"
      @handleParmaryClick="method?.handleCustomerGroupCorpSend"
      :parimaryDisabled="useModel?.status?.value === 'Sent'"
    />
  </view>
</template>

<script setup lang="ts">
import useModel from './model'
import method from './method'
import { onLoad, onShow } from '@dcloudio/uni-app'
import { useWeAppAuthStore } from '@/common'
import { shareToExternalMoments } from '@/common/libraries/sendWxWork'
const auth = useWeAppAuthStore()

onShow(() => {
  if (useModel?.showData?.value?.id) {
    method?.getCustomerMomentsShow(useModel?.showData?.value?.id)
  }
})

onLoad(e => {
  useModel.formData.value = {
    customer_moments_id: e?.model_id,
    company_employee_backlogs_id: e?.id
  }
  method?.getCustomerMomentsShow(e?.data_id)
})
</script>

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