<template>
	<view class="page">
		<u-navbar :is-back='false' 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 class="bottom">
			<view class="btn" @click="quit()">
				不同意
			</view>
			<view class="btn1" @click="ok()">
				同意
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				bgc: {
					backgroundColor: "#fff",
				},
				info: {},
				userinfo: {},
				areaInfo: {}
			}
		},
		onLoad(e) {
			console.log(e, 'eee');
			if (e.needback) {
				this.showbot = true
			}
		},
		onShow() {
			this.getagree()
		},
		methods: {
			ok() {
					this.$store.commit('SET_SHOWAGRE',false);
					console.log( this.$store.getters.showagre);
					uni.redirectTo({
						url:'/pages/index/index'
					})
			},
			quit() {
				uni.exitMiniProgram({
					success: function() {
						console.log('退出小程序成功');
					},
					fail: function(err) {
						console.log('退出小程序失败', err);
					}
				})
			},

			getagree() {
				let id = 15
				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;

		.bottom {
			position: fixed;
			background: #fff;
			bottom: 0;
			width: 750rpx;
			height: 200rpx;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			justify-content: space-around;
			// box-shadow: 12rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1);
			.btn {
				width: 250rpx;
				height: 80rpx;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: center;
				// border: 2rpx solid #000;
				border-radius: 40rpx;
				background: #ccc;
				color: #fff;
				font-size: 28rpx;
				font-weight: 600;
			}
			.btn1{
				width: 250rpx;
				height: 80rpx;
				display: flex;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: center;
				// border: 2rpx solid #000;
				border-radius: 40rpx;
				background: #4C97E7;
				color: #fff;
				font-size: 28rpx;
				font-weight: 600;
			}
		}

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

		}
	}
</style>