import {FC, useEffect, useState} from "react";
import {View} from "@tarojs/components";
import Taro, {useRouter} from "@tarojs/taro";
import {ArticleRecord, brandApi} from "@/api";


const article:FC = () => {
  const {id} = useRouter().params as unknown as { id: number}
  const [articleInfo,setArticleInfo] = useState<ArticleRecord>()
  useEffect(() => {
    getData()
  }, [id])

  const getData = async () => {
    try {
      const data = await brandApi.articleInfo(id)
      Taro.setNavigationBarTitle({title:data.title})
      setArticleInfo(data)
    } catch (e) {
    }
  }
  function helloWorld() {
    const html = articleInfo?.content;
    return <View dangerouslySetInnerHTML={{ __html: html! }}></View>
  }
  return helloWorld()
}
export default article
