<!-- 文章展示 -->
<template>
  <s-layout class="set-wrap" :title="state.title" :bgStyle="{ color: '#FFF' }" v-if="state.title && !type">
    <view class="ss-p-30">
      <mp-html class="richtext" :content="state.content" />
    </view>
  </s-layout>
  
  <mp-html class="richtext" :content="state.content" v-else/>

</template>

<script setup>
  import { onLoad } from '@dcloudio/uni-app';
  import { reactive,defineProps } from 'vue';
  import ArticleApi from '@/sheep/api/promotion/article';

  const state = reactive({
    title: '',
    content: '',
  });

  async function getRichTextContent(id, title) {
	  console.log(id,title)
    const { code, data } = await ArticleApi.getArticle(id, title);
    if (code !== 0) {
      return;
    }
    state.content = data.content;
    // 标题不一致时，修改标题
    if (state.title !== data.title) {
      state.title = data.title;
      uni.setNavigationBarTitle({
        title: state.title,
      });
    }
  }
const props = defineProps({
	title:{
		defautls:'',
		type:String
	},
	type:{
		defautls:'',
		type:String
	}
})
  onLoad((options) => {
    if (options.title || props.title) {
      state.title = options.title  || props.title;
      uni.setNavigationBarTitle({
        title: state.title  || props.title,
      });
    }
    getRichTextContent(options.id, options.title||props.title);
  });

</script>

<style lang="scss" scoped>
  .set-title {
    margin: 0 30rpx;
  }

  .richtext {
  }
</style>
