<template>
	<view class="page">
		<u-navbar :title="title" :border-bottom="false" :background="bgc" title-color='#000' title-size='36'
			height='45'></u-navbar>
		<view class="cont" v-html="content"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#fff",
				},
				info: {},
				userinfo: {},
				areaInfo: {},
				content: '',
				title: ''
			}
		},
		onLoad(options) {
			if (options.title && options.content) {
				// 解码 title 和 content
				const title = decodeURIComponent(options.title);
				const content = JSON.parse(decodeURIComponent(options.content));
				// 设置数据
				this.title = title
				this.content = content
				this.content = this.replaceImgWithImage(this.content);
				// this.insertPhoneNumberAndDate()
				console.log(this.content, 'this.contentthis.contentthis.contentthis.content');
			}
		},

		methods: {

			getagree() {
				let id = uni.getStorageSync('areaId');
				this.$u.get(`/app/article/list?areaId=${id}&tag=agreement`).then((res) => {
					if (res.code === 200) {
						this.info = res.rows[0];
						this.content = this.replaceImgWithImage(this.info.content);

					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				});
			},

			replaceImgWithImage(content) {
				// 替换所有的&nbsp;为 \u00A0
				content = content.replace(/&nbsp;/g, '\u00A0');

				// 替换 <img> 标签的宽度和高度样式
				content = content.replace(/<img([^>]*)>/g, (match, group1) => {
					// 查找并移除可能存在的尾部斜杠
					let cleanedGroup = group1.replace(/\s*\/$/, '');
					return `<img style="width: 85vw ; height: auto;"  ${cleanedGroup} />`;
				});

				return content;
			}
		}
	}
</script>


<style lang="scss">
	page {
		background-color: #fff;
	}

	.page {
		width: 750rpx;

		.cont {
			margin-top: 34rpx ;
			margin: 0 auto;
			width: 634rpx;

		}
	}
</style>