<template>
	<view class="top">
		<text class="iconfont icon-youjiantou zuojiantou" @click="goBack()"></text>
		<text>公告详情</text>
	</view>
	<view class="announcement_detail_wrapper container">
		<view class="content">
			<view class="title">
				<view v-html="announcementInfo.title"></view>
			</view>
			<view class="date">
				发布时间：{{announcementInfo.announcementAt}}
			</view>
			<view v-html="announcementInfo.content"></view>
			<!-- <rich-text :nodes="announcementInfo.content"></rich-text> -->
		</view>
	</view>
</template>

<script>
	import api from "../../api/api";
	import common from '../../common/common';
	import {hshare} from '@/util/fiveshare';
	import {shareURL} from "@/environments/environment";
	export default{
		data(){
			return{
				announcementInfo:{
					announcementAt:null,
					title:null,
					content:null
				},
				id:null
			}
		},
		name:'announcement_detail',
		components:{
		},
		onLoad(options){
			this.id = options.id;
			this.getAnnouncementDetail();
		},
		methods:{
			getAnnouncementDetail(){
				api.announcementQuery({id:this.id}).then((res)=>{
					if(res['success']){
						this.announcementInfo = res['data']['announcementInfoList'][0];
						
					}
				})
			},
			matchReg(str){
			    let reg=/<\/?.+?\/?>/g;
			    return str.replace(reg,'');
			},
			goBack(){
				uni.navigateTo({
					url:'../announcement/announcement'
				})
			},
			getshareData2(shareCode,jumptime,type=1) {
				let newLink = shareURL + "/pages/announcement/announcement_detail?id=" + this.id
						console.log('this.courseInfo',this.courseInfo);
				let data = {
					title: this.announcementInfo.title,
					// desc: '加入我们开启学习之旅',
					// desc:this.courseInfo.fileSynopsis,
					link: newLink, //分享链接
					imgUrl: this.courseInfo.displayImage, //图片
				}
				//安卓机型获取当前页面路径
				let url = window.location.href.split('#')[0];
				
				//ios机型获取当前页面路径
				let ua = navigator.userAgent.toLowerCase();
				let isWeixin = ua.indexOf('micromessenger') !== -1;
				if (isWeixin) {
					let isiOS = /(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent); //ios终端
				    if (isiOS && window.sessionStorage.getItem('firstEntryUrl')) {
				        url = window.sessionStorage.getItem('firstEntryUrl').split('#')[0];
				    }
				}
				// let url = window.location.href.split('#')[0]
				
				hshare(data, url)
				
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.top{
		display: flex;
		height: 80rpx;
		justify-content: space-between;
		align-items: center;
		position: relative;
		width: 100%;
		margin: 0 auto;
		.zuojiantou{
			display: inline-block;
			transform: rotate(180deg);
			font-size: 30rpx;
			z-index: 1;
			position: absolute;
		}
		text:nth-child(2){
			width: 100%;
			text-align: center;
			position: absolute;
		}
	}
	.announcement_detail_wrapper{
		padding: 20rpx 16rpx;
		.title{
			font-size: 48rpx;
		}
		.date{
			color: #8d9599;
			margin: 20rpx 0;
			border-bottom: 2rpx #F8F8F8 solid;
			padding-bottom: 20rpx;
		}
		.content{
			padding: 20rpx;
			background: #fff;
			word-break: break-word;
		}
	}
</style>