import OHeader from '@/components/m-header';
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(
          '/edu-app/open/helpCenterContent/detail/' + route.query.id
        );
        detail.value = data;
      } catch {
        //
      }
    };

    onMounted(() => {
      getDetails();
    });
    return () => (
      <>
        {route.query.source == 'music' ? (
          <NavBar
            leftArrow
            leftText="返回"
            border={false}
            onClickLeft={() => router.back()}
          />
        ) : (
          <OHeader />
        )}
        <div class={[styles.detail]}>
          <div class={styles.detailContent}>
            <div class={styles.title}>{detail.value.title}</div>
            <div class={styles.who}>
              <span>课堂乐器</span>
              {detail.value.updateTime}
            </div>

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