<template>
	<page-meta :root-font-size="fontsize+'px'" style="display: block;">
	<view>
		<Headers></Headers>
		<view class="project">
			<view style="width: 12rem;margin: auto;">职业技能在线考试系统</view>
		</view>
		
		<view class="project-content ddflex">
			<!-- 成绩区域 -->
			<view class="test-box">
				<view class="test-title">{{content.title}}</view>
				<view class="test-time">
					<text style="color: #999999;margin-right: 0.1rem;">发布日期</text>
					<text>{{content.time}}</text>
				</view>
				<view style="font-size: 0.16rem;">
					<mp-html :content="content.text" :lazy-load="true" @imgtap="choose"></mp-html>
				</view>
			</view>
			<!-- 答题卡区域 -->
			<view class="test-info ddflex">
				<view class="note-box">
					<view class="note-title ddflex">
						<image class="note-title-icon" src="/static/images/ksgg.png"></image>
						<view>考试公告</view>
					</view>
					<view>
						<view class="note-item ddflex" v-for="item,index in otherInfo" :key="index" @click="jumpUrl('/pages/contentDetail/contentDetail?id='+item.id)">
							<view class="note-item-content">{{item.title}}</view>
						</view>
					</view>
				</view>
				<!-- 注意事项 -->
				<view class="note-box">
					<view class="note-title ddflex">
						<image class="note-title-icon" src="/static/images/zysx.png"></image>
						<view>注意事项</view>
					</view>
					<view>
						<view class="note-item ddflex" v-for="item,index in noteInfo" :key="index+'zy'" @click="jumpUrl('/pages/contentDetail/contentDetail?id='+item.id)">
							<view class="note-item-content">{{item.title}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<Foot></Foot>
	</view>
	</page-meta>
</template>

<script>
	const app = getApp();
	const req = require('../../utils/request.js');
	import mpHtml from "../../components/mp-html/mp-html.vue";
	export default {
		data() {
			return {
				id:null,
				content:'',
				otherInfo:[],
				noteInfo:[],
				fontsize:'100px'
			}
		},
		onReady() {},
		onLoad(options) {
			let srceenNunber = 19.2; //因设计图是1920所有把设计图分为19.2份，所以html字体大小为100px
			    let that = this;
			
			    //窗体改变大小触发事件
			    uni.onWindowResize((res) => {
			        console.log('变化后的窗口宽度=', res.size.windowWidth);
			        that.fontsize = parseFloat(res.size.windowWidth) / srceenNunber;
			    })
			
			    //打开获取屏幕大小
			    uni.getSystemInfo({
			        success(res) {
			            console.log('设备信息：', res);
			            that.fontsize = res.screenWidth / srceenNunber;
			            console.log('字体大小：', that.fontsize);
			        }
			    })
			
			this.id = options.id
			this.getDetail()
			this.getTextOtherInfo()
			this.getTextNoteInfo()
		},
		methods: {
			jumpUrl(url){
				uni.navigateTo({
					url:url
				})
			},
			getDetail(){
				req.getRequest('/api/content/detail',{id:this.id},res=>{
					this.content = res
				})
			},
			// 考试公告
			getTextOtherInfo(){
				let form={
					code:req.public.ksggCode,
					page:1,
					limit:3
				}
				req.getRequest('/api/content/list',form,res=>{
					this.otherInfo = res
				})
			},
			// 注意事项
			getTextNoteInfo(){
				let form={
					code:req.public.zysxCode,
					page:1,
					limit:3
				}
				req.getRequest('/api/content/list',form,res=>{
					this.noteInfo = res
				})
			},
		}
	}

</script>

<style>
	@import url('./contentDetail.css');
</style>