<template>
	<view class="container uni-container">
		<view class="padding-bottom flex direction-column align-center justify-center ">
			<uni-row class="padding-tb">
				<uni-col :span="24">
					<u--image :src="meetingEnd == '1' ? SignINExpired : siginIn != '1' ? signOne : signIned"
						width="234rpx" height="128px" @click="signInClick">
						<template v-slot:loading>
							<u-loading-icon color="red"></u-loading-icon>
						</template>
						<view slot="error" style="font-size: 24rpx;">加载失败</view>
					</u--image>
					<text v-if="meetingEnd == 1"
						style="font-weight:bold; padding-left: 51rpx;;color: #8d8d8d;font-size: 32rpx;">
						会议已结束
					</text>

					<text v-else-if="siginIn != '1'"
						style="font-weight:bold; padding-left: 51rpx;;color: #4cb2b6;font-size: 32rpx;">
						点击签到
					</text>
					<text v-else-if="siginIn == '1'"
						style="font-weight:bold; padding-left: 65rpx;;color: #f7c41e;font-size: 32rpx;">
						已签到
					</text>
				</uni-col>
			</uni-row>
			<uni-row class="padding-bottom">
				<uni-col :span="24">
					<text>{{ formData.name }}</text>
				</uni-col>
			</uni-row>
		</view>
		<view class="flex direction-column   justify-center">
			<uni-row class="demo-uni-row padding-tb-sm border-bottom border-top" :gutter="20" width="100%">
				<uni-col :span="12">
					<view class="flex direction-column border-right">
						<text class="padding-bottom">会议名称</text>
						<text style="font-weight: bold;font-size: 30upx;">{{ formData.meetingName }}</text>
					</view>
				</uni-col>
				<uni-col :span="12">
					<view class="flex direction-column align-center ">
						<text class="padding-bottom">会议主题</text>
						<text style="font-weight: bold;font-size: 30upx;">{{ formData.meetingSubject }}</text>
					</view>
				</uni-col>
			</uni-row>
			<uni-row class="demo-uni-row padding-tb-sm border-bottom" :gutter="20" width="100%">
				<uni-col :span="12">
					<view class="flex direction-column border-right">
						<text class="padding-bottom">会议时间</text>
						<text style="font-weight: bold;font-size: 30upx;">{{ formData.meetingStartTime }}</text>
						--
						<br />
						<text style="font-weight: bold;font-size: 30upx;">{{ formData.meetingEndTime }}</text>
					</view>
				</uni-col>
				<uni-col :span="12">
					<view class="flex direction-column align-center ">
						<text class="padding-bottom">会议类型</text>
						<text style="font-weight: bold;font-size: 30upx;">{{ formData.meetingType }}</text>
					</view>
				</uni-col>
			</uni-row>
		</view>
	</view>
</template>
<script>
	import {
		getMeeting, // 查询会议列表
		getMeetingSign, //会议签到
		getMeet
	} from '@/api/meeting';
	let that = null;
	import config from '@/config'
	const baseUrlImg = config.baseUrlImg
	export default {
		data() {
			return {
				formData: {},
				formData2: {
					id: '',
					siginIn: '1',
					status: 0,
					userId: this.$store.state.user.id
					// "orgId":1
				},
				siginIn: '',
				status: '',
				signOne: `${baseUrlImg}/metting/sign.png`,
				signIned: `${baseUrlImg}/metting/Signed.png`,
				SignINExpired: `${baseUrlImg}/metting/SignINExpired.png`,
				IsSign: false,
				FinalTime: 0,
				meetingEnd: '',
				pageSize: 20,
				// 当前页
				pageNo: 1
			};
		},
		onshow() {},
		//目的页面接收
		//这里用onshow()也可以

		onLoad: function(options) {
			var data = options.id;
			// this.getData(data);
			that = this;

			const eventChannel = this.getOpenerEventChannel();
			// eventChannel.emit('acceptDataFromOpenedPage', {
			// 监听acceptDataFromOpenerPage事件，获取上一页面通过eventChannel传送到当前页面的数据
			eventChannel.on('acceptDataFromOpenerPage', function(val) {
				console.log('传送到当前页面的数据 ', val);
				that.formData = val;
				that.formData2.id = val.meetingDetailDOList[0].id;
				// 签到流程判断
				var Time = new Date(that.formData.meetingEndTime);
				that.FinalTime = Time.getTime();
				var currentTime = new Date().getTime();

				// 判断结束时间是否小于当前时间   小于则判断是否已经签到
				if (that.FinalTime < currentTime) {
					// 1 表示显示过期图片
					that.meetingEnd = '1';
				} else {
					const id = that.formData2.id;
					getMeet({
						id: id
					}).then(res => {
						that.siginIn = res.data.siginIn;
					})
				}
			});

			// this.getData();/
		},
		methods: {


			signInClick() {
				var SignJson = JSON.stringify(this.formData2);

				getMeetingSign(SignJson).then(res => {
					// console.log(res);
					// this.siginIn='1'
					if (res.code == 0) {
						this.siginIn = '1'
					}
				});
			}
		}
	};
</script>
<style>
	.sign-in {
		height: 400rpx;
	}

	.border-bottom {
		border-bottom: 1px solid #cbd5e1;
	}

	.border-top {
		border-top: 1px solid #cbd5e1;
	}

	.border-right {
		border-right: 1px solid #cbd5e1;
	}
</style>