<!-- 文章展示 -->
<template>
  <s-layout :bgStyle="{ color: 'transparent' }" :title="state.title" class="set-wrap">
    <view>
      <!-- #ifdef H5 -->
      <!-- <iframe src="http://42.194.163.46:9005/chatbot/Daahm2N28l24ECJx"
        style="width: 100%; height: calc(100vh - 50px);"></iframe> -->
      <!-- #endif -->

      <!-- #ifdef MP-WEIXIN -->
      <!-- <web-view src="http://42.194.163.46:9005/chatbot/Daahm2N28l24ECJx"
        style="width: 100vw; height: 100vh;"></web-view> -->
      <!-- #endif -->
    </view>
  </s-layout>
  <view>
  </view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue';
import ArticleApi from '@/sheep/api/promotion/article';
const webviewstyle = ref({
  width: "100%",
  height: "100%",
  top: "100px",
});
const state = reactive({
  title: '',
  content: '',
});

async function getRichTextContent(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,
    });
  }
}

onLoad((options) => {
  if (options.title) {
    state.title = options.title;
    uni.setNavigationBarTitle({
      title: state.title,
    });
  }
  getRichTextContent(options.id, options.title);
});

</script>

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

iframe {
  border: none;
}

.richtext {}
</style>
