import request from '@/helpers/request'
import { state } from '@/state'
import { NavBar } from 'vant'
import { defineComponent, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import styles from '../information-detail.module.less'

export default defineComponent({
  name: 'notice-detail',
  setup() {
    const route = useRoute()
    const router = useRouter()
    const detail = ref<any>({})

    const getDetails = async () => {
      try {
        const { data } = await request.get(
          state.platformApi + '/helpCenterContent/detail/' + route.query.id
        )
        detail.value = data
      } catch {
        //
      }
    }

    onMounted(() => {
      getDetails()
    })
    return () => (
      <>
        {route.query.source == 'music' ? <NavBar leftArrow leftText="返回" border={false} onClickLeft={() => router.back()} /> : null}
        <div class={styles.detail}>
          <div class={styles.title}>{detail.value.title}</div>
          <div class={styles.who}>
            <span>管乐团</span>
            {detail.value.createTime}
          </div>

          <div class={styles.content} v-html={detail.value.content}></div>
        </div>
      </>
    )
  }
})
