<template>
	<view class="meet">
		<view class="mtop">
			<view class="tit">{{datainfo.conferenceTitle}}</view>
			<view class="ftxt">
				<text>会议地点</text>
				<view>{{datainfo.conferenceAddress}}</view>
			</view>
			<view class="ftxt">
				<text>会议时间</text>
				<view class="co1d">{{datainfo.conferenceDate}} {{datainfo.conferenceTime}}</view>
			</view>
			<view class="ftxt">
				<text>备注信息</text>
				<view>{{datainfo.remark}}</view>
			</view>
		</view>
		<view class="mtop madr">
			<view class="tit mb24">会议签到</view>
			<!-- <view class="madra">
				<image :src="adrimg"></image>
				<view>安徽省合肥市蜀山区高薪技术产业开发区黄山路59号 时代数码港</view>
			</view> -->
			<view class="madrb" @click="getCodeFn">
				<view class="time">{{kaTime}}</view>
				<view class="mqian">扫码签到</view>
			</view>
			<view class="tips flexcc">
				<!-- <image :src="choseimg"></image> -->
				<view>会议即将开始，请尽快签到哦</view>
			</view>
			<!-- <view class="madrc">
				
				<meet-step></meet-step>
			</view> -->
				
		</view>
	</view>
</template>

<script>
	import {getMeetDetaiFn,getsignInFn} from "@/api/mine/meeting.js"
	import meetStep from "@/work/components/meeting/step.vue"
	export default{
		components:{meetStep},
		data(){
			return{
				adrimg:require("@/work/static/images/meeting/adr.png"),
				choseimg:require("@/work/static/images/meeting/chose.png"),
				recordList:[{tit:'123'}],
				datainfo:{},
				userId:this.$store.state.user.userId,
				kaTime:''
			}
		},
		onLoad(e) {
			this.id=e.id;
			this.getDataFn();
			this.gettimeFn();
		},
		methods:{
			gettimeFn() {
				var that = this;
				clearInterval(this.timefn)
				that.time();
				that.timefn = setInterval(function() {
					that.time();
				}, 1000);
			},
			time() {
				var date = new Date();
				var y = date.getFullYear();
				var m = date.getMonth() + 1;
				var d = date.getDate();
				var h = date.getHours();
				var min = date.getMinutes();
				var s = date.getSeconds();
				var week = date.getDay(); //获取当前星期X(0-6,0代表星期天)
				var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
				var yearStr = y + '/' + (m < 10 ? ('0' + m) : m) + '/' + (d < 10 ? ('0' + d) : d)
				var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? ('0' + s) : s);
				// var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min);
				this.kaTime =timeStr;
				// if(this.endTime&&this.type==0&&!this.pwdflag){
				// 	var endt=new Date(this.endTime).getTime()
				// 	var nowt=date.getTime()
				// 	if(nowt>endt){
				// 		this.type=1
				// 		this.videotype=1;
				// 	}else{
				// 		this.videotype=0;
				// 	}
				// }
			},
			getDataFn(){
				var params={
					conferenceId:this.id,
					userId:this.userId
				}
				getMeetDetaiFn(params).then(res=>{
					this.datainfo=res.data;
				})
			},
			getCodeFn(){
				var that = this;
				uni.scanCode({
					onlyFromCamera: true,
					autoZoom:false,
					scanType: ['qrCode'],
					success: function(red) {
						let result = red.result;
						if (typeof result == 'string') {
							try {
							
							} catch (e) {
								uni.navigateBack({
									delta: 1
								})
								uni.showToast({
									title: '扫码查询失败,请检查二维码是否正确',
									icon: "none"
								})
								return
							}
						}
						var id = red.result
						var params = {
							conferenceId: id,
							userId:that.userId,	
						}
						getsignInFn(params).then(res => {
							if (res.code == 200) {
								if(res.msg=='核销失败'){
									that.$toast(res.msg)
									// that.$tab.navigateTo('/pages/order/stafffail')
								}else{
									that.$toast('签到成功')
									setTimeout(function(){
										uni.$emit('refreshdetail')
										uni.$emit('refreshlist')
										uni.navigateBack({
											delta:1
										})
									},1200)
								}
								
							} else {
								uni.showToast({
									title: res.msg,
									duration: 1000,
									icon: 'none'
								});
							
							}
						})
					},
					fail: function(e) {
						if (e && e.errMsg && e.errMsg.indexOf('scanCode:fail cancel') != -1) {
							return;
						}
						uni.showToast({
							title: '扫码失败',
							icon: "none"
						})
					},
				});
			},
		}
	}
</script>

<style scoped lang="scss">
.meet{padding: 34rpx 24rpx;
	.mtop{width: 100%;background: #FFFFFF;box-shadow: 0px 0px 14rpx 0px rgba(153,152,152,0.39);
border-radius: 10rpx;padding: 48rpx 40rpx 28rpx;margin-bottom: 30rpx;
		&.madr{padding: 48rpx 34rpx 28rpx;}
		.tit{font-weight: bold;font-size: 30rpx;color: #343434;margin-bottom: 36rpx;}
		.ftxt{display: flex;align-items: flex-start;margin-bottom: 20rpx;flex:0 1 auto;min-width: 50%;
			text{font-weight: bold;font-size: 26rpx;color: #CACACA;flex: 0 0 auto;min-width: 104rpx;text-align-last: justify;}
			view{flex: 1;color: #343434;font-size: 26rpx;margin-left: 20rpx;line-height: 34rpx;}
		}
	}
	.madra{display: flex;align-items: flex-start;margin-bottom: 56rpx;
		image{width: 24rpx;height: 26rpx;margin-right: 12rpx;flex: 0 0 auto;margin-top: 4rpx;}
		view{font-weight: 400;font-size: 26rpx;color: #222327;}
	}
	.madrb{
		width: 368rpx;height: 194rpx;background: #1D64E2;box-shadow: 0px 0px 10rpx 0px #6296F2;margin: 0 auto 34rpx;
		border-radius: 98rpx;display: flex;align-items: center;flex-direction: column;justify-content: center;
		.time{font-weight: bold;font-size: 30rpx;color: #FFFFFF;margin-bottom: 10rpx;}
		.mqian{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
	}
	.tips{margin-bottom: 52rpx;
		image{width: 20rpx;height: 20rpx;margin-right: 14rpx;}
		view{font-weight: 400;font-size: 26rpx;color: #666666;}
	}
	.madrc{padding-left: 34rpx;}
	
}	
</style>