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

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#fff",
				},
				info: {},
				userinfo: {},
				areaInfo:{}
			}
		},
		onShow() {
			this.getagree()
		},
		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.insertPhoneNumberAndDate();
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				});
			},
			// insertPhoneNumberAndDate() {
			//   const currentDate = new Date();
			//   const formattedDate = `${currentDate.getFullYear()}年${currentDate.getMonth() + 1}月${currentDate.getDate()}日${currentDate.getHours()}时`;
			//   const simpleDate = `${currentDate.getFullYear()}年${currentDate.getMonth() + 1}月${currentDate.getDate()}日`;

			//   // 插入电话号码
			//   if (this.userinfo.phonenumber) {
			//     const phonePattern = /(<p>联系电话:)(<\/p>)/;
			//     this.info.content = this.info.content.replace(phonePattern, `$1${this.userinfo.phonenumber}$2`);
			//   }

			//   // 替换起租时间
			//   const rentTimePattern = /起租<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/u>年<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/u>月<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/u>日<u>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/u>时/;
			//   this.info.content = this.info.content.replace(rentTimePattern, `起租<u>\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${formattedDate}</u>`);

			//   // 替换底部时间
			//   const bottomDatePattern = /<p>&nbsp;年月日年月日<\/p>/g;
			//   this.info.content = this.info.content.replace(bottomDatePattern, `<p>${simpleDate}\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0${simpleDate}</p>`);

			//   // 替换所有的&nbsp;为 \u00A0
			//   this.info.content = this.info.content.replace(/&nbsp;/g, '\u00A0');
			// },
			insertPhoneNumberAndDate() {
			
				// 替换所有的&nbsp;为 \u00A0
				this.info.content = this.info.content.replace(/&nbsp;/g, '\u00A0');
			}
		}
	}
</script>


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

	.page {
		width: 750rpx;

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

		}
	}
</style>