<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">通知详情</block>
		</cu-custom>
		<scroll-view scroll-y>
			<view class="message-warp">
				<view class="title">
					{{pd.SYNOPSIS}}
				</view>
				<view class="info">
<!--					<text>双控平台</text>-->
					<text>{{pd.CREATTIME}}</text>
				</view>
				<view class="content">
					<rich-text :nodes="content"></rich-text>
				</view>
				<view class="message-warp" v-if="pd.FILEPATH">
					<view class="cu-item" @click="$noMultipleClicks(goStuToOpen,pd.FILEPATH)">
						<view class="content">
							<text class="cuIcon-read text-blue"></text>
							<text class="text-grey">附件</text>
						</view>
					</view>
				</view>
			</view>
			<view class="cu-tabbar-height"></view>
		</scroll-view>
	</view>
</template>

<script>
	import {
		basePath,loginUserId,corpinfoId,loginUser,baseImgPath
	} from '@/common/tool.js';
	import HTMLParser  from "@/components/html-parser.js"
	export default {
		data() {
			return {
				id:'',
				content:'',
				pd:[],
				type:'',
				noClick:true,
			}
		},
		onLoad(e){
			this.type =e.type;
			this.id=e.id;
			this.getData();
		},
		methods: {
			getData() {
				var _this = this;
				uni.showLoading({
					title: '请稍候'
				})
				var url = basePath + '/app/notice/goEdit'
				if("1"==_this.type){
					url =  basePath + '/app/notice/goEditForPc'
				}
				uni.request({
					url:url,
					method: 'POST',
					dataType: 'json',
					header: {
						'Content-type':'application/x-www-form-urlencoded'
					},
					data: {
						NOTICE_ID:_this.id,
						loginUserId:loginUserId,
						corpinfoId:corpinfoId,
						ISMAIN:loginUser.ISMAIN,
					},
					success: (res) => {
						if("success" == res.data.result){
							uni.hideLoading();
							_this.pd = res.data.pd;
							_this.content= new HTMLParser(res.data.pd.CONTENT.trim());
							var pages = getCurrentPages();	// 获取当前页面栈
							var prePage = pages[pages.length - 2];	// 上一个页面
							prePage.$vm.initflag = true;    // A 页面 init方法 为true
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 2000
							});
						}
					}
				});
			},
			goStuToOpen(e) {
				var url=baseImgPath + e ;
				var url2 = encodeURI(url); 
				plus.runtime.openURL(url2, function(res) {
				});
			},
		}
	}
</script>

<style>
	.message-warp{
		background-color: #fff;
		padding: 30upx;
	}
	.message-warp .title {
		font-size: 34upx;
		margin-bottom: 20upx;
	}

	.info {
		display: flex;
		justify-content: space-between;
		color: #888;
		font-size: 24upx;
		margin-bottom: 20upx;
	}

	.content {
		padding: 0upx;
		line-height: 1.6;
	}
	.content img{
		width: 100%;
		height: auto;
	}
</style>
