<template>
	<view class="container">
		<view class="NoticeInfo" v-html="NoticeInfo">

		</view>
	</view>
</template>

<script>
	let gHost = "https://" + window.location.host;
	if (window.location.protocol != "https:") {
		gHost = "https://fpdev.xiaopay.net";
	}
	//获取参数
	function getQueryParams(params) {
		let href = window.location.href
		let query = href.substring(href.indexOf('?') + 1);
		let vars = query.split("&");
		for (var i = 0; i < vars.length; i++) {
			let pair = vars[i].split("=");
			if (pair[0] == params) {
				return pair[1];
			}
		}
		return (false);
	}
	export default {
		name: "NoticeInfo",
		data() {
			return {
				NoticeInfo: ""
			}
		},
		onLoad: function(options) {
			console.log(options);
			let this_ = this
			if (!options.sessionid) {
				uni.showModal({
					title: "系统提示",
					showCancel: false,
					content: "参数错误",
				})
				return
			}
			// uni.showModal({
			// 	title: "系统提示",
			// 	showCancel: false,
			// 	content: JSON.stringify(options),
			// 	success: function() {
			// 	},
			// })
			if (options.NoticeTitle) {
				uni.setNavigationBarTitle({
					title: options.NoticeTitle
				})
			}
			this_.selectContentById(options.sessionid, options.schoolid, options.operatorId,
				options.NoticeId)
		},
		methods: {
			// 小程序端查询通知公告
			async selectContentById(sessionid, schoolid, operatorId, NoticeId) {
				let this_ = this;
				try {
					await new Promise((resolve, reject) => {
						// 二维码加密内容获取token
						$.ajax({
							url: gHost +
							'/xpaynotice/notice/noticeConfig/selectContentById', //开发者服务器接口地址",
							type: "get",
							dataType: 'json',
							contentType: 'application/json; charset=UTF-8',
							cache: false,
							data: {
								schoolid: parseInt(schoolid),
								operatorId: parseInt(operatorId),
								sessionid,
								wechattype: 1,
								id: NoticeId
							},
							success: function(res) {
								if (res.code == 200) {
									this_.NoticeInfo = res.data
									resolve(res)
								} else {
									reject(res)
								}
							},
							error: function(error) {
								reject(error)
							}
						})
					})
				} catch (err) {
					//TODO handle the exception
					uni.showModal({
						title: "系统提示",
						content: err.message
					})
				}
			}
		}
	}
</script>

<style scoped>
.NoticeInfo{
	 padding: 15rpx;
}



</style>
