<template>
	<view class="container">
		<navigation-bar-vue :title="title" style="width: 100%;" background-color="#ffffff"
			title-color="#000000"></navigation-bar-vue>
		<div class="body">
			<rich-text style="width: 100%" :nodes="richTextHtml" />
		</div>
	</view>
</template>

<script>
	import navigationBarVue from '@/components/navigation/navigationBar.vue';
	import {
		getSiteConfig
	} from '@/api/system/config'
	import parser from 'rich-text-parser'
	export default {
		components: {
			navigationBarVue
		},
		filters: {
			formatRichText(html) { // 控制小程序中图片大小
				// console.log(html)
				const nodes = parser.getRichTextJson(html)
				return nodes.children
			}
		},
		data() {
			return {
				title: "",
				richTextHtml: '',
			}
		},
		onLoad(options) {
			this.title = options.title
			this.getRichTextHtml(options.code)
		},
		methods: {
			async getRichTextHtml(code) {
				let that = this
				getSiteConfig({
					code: code
				}).then(res => {
					let json = JSON.parse(res.data)
					that.richTextHtml = json[0].value
				}).catch((e) => {
					uni.showToast({
						icon: 'error',
						duration: 2000,
						title: e
					});
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.container {
		padding-top: calc(90rpx + var(--status-bar-height));
		height: 100%;
		padding-left: 20rpx;
		padding-right: 20rpx;
		background: white;
		display: flex;
		flex-direction: column;

		.body {
			height: calc(100vh - var(--status-bar-height) - var(--window-bottom) - 95rpx);
			overflow-y: scroll;
			overflow: auto;
		}
	}
</style>