<template>
	<view class="home">
		<view class="title">
			{{info.noticeTitle}}
		</view>
		<text class="time">创建时间：{{info.createTime}}</text>
		<rich-text :nodes="info.noticeContent" style="text-indent: 2em;" class="content"></rich-text>
	</view>
</template>

<script>
	import { studyDetail } from '@/api/visitor.js'
	import baseUrl from '@/utils/baseurl.js'
	export default {
		data() {
			return {
				info:{},
				id:null
			};
		},
		onLoad:function(option){
			this.id = option.id
			console.log(this.id)
			this.init()
		},
		methods:{
			init(){
				const arr = baseUrl.split("/")
				let url = ''
				for(let i = 0; i < arr.length - 1; i++) {
					if (i != arr.length - 2) {
						url += arr[i] + "/"
						continue
					}
					url += arr[i]
				}
				studyDetail(this.id).then(res=>{
					res.noticeContent = res.noticeContent.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, (match, p1) => {
							console.log(match)
					    return `<img style="width: 90%;text-align: center;" src='${p1.indexOf('http') > -1 ? p1 : url + p1}' />`
					})
					this.info = res
				})
			}
		}
	}
</script>

<style lang="scss">
.home{
	padding:0 30rpx 30rpx;
	.title{
		color: #252525;
		font-size: $uni-title-font-size;
		line-height: 300%;
		text-align: center;
	}
	.time{
		color: rgba(80, 80, 80, 1);
		font-size: 28rpx;
		line-height: 200%;
		text-align: left;
	}
	.content{
		color: #252525;
		font-size: $uni-font-size;
		line-height: $uni-line-height;
		text-align: left;
		text-indent: 2em;
	}
}
</style>
