<template>
	<view class="home">
		<view class="header">
			<view class="logo">
				<image src="@/static/logo2.png"></image>
			</view>
			<view class="info">
				<view class="a">弹射者|{{saiName}}</view>
				<view class="b">{{subName}}
					<view class="fs"><text>参赛名单</text>{{mr}}</view>
				</view>
			</view>
		</view>
		<view class="body">
			<view class="a">
				<view class="c">
					<view class="d">
						<view class="xh"><text>{{type==1?'道次':'序号'}}</text></view>
						<view class="xm"><text>号码</text></view>
						<view class="jls"><text>姓名</text></view>
						<view class="dyc"><text>单位</text></view>
						<view class="dsc"><text>备注</text></view>
					</view>
					<view class="e"></view>
				</view>
			</view>
			<view class="b">
				<view class="c">
					<view class="d">
						<template v-for="(a,i) in slist">
							<view class="item" :class="a.id == declareInfo.id?'item-on':''" :key="i">
								<view class="xh"><text>{{a.passage}}</text></view>
								<view class="xm"><text>{{a.athlete_number}}</text></view>
								<view class="jls">{{a.athlete_name}}</view>
								<view class="dyc">{{a.club_name}}</view>
								<view class="dec">{{a.remake}}</view>
							</view>
						</template>
					</view>
					<view class="e">
						<image mode="widthFix" v-if="declareInfo.img_ur" :src="declareInfo.img_ur"></image>
					</view>
				</view>
				<view class="items">	
					<image src="@/static/bottom.png"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				slist: [],
				saiName: "",
				subName: "",
				mr: "",
				type: 1,
				declareInfo: {}
			}
		},
		onLoad() {
			this.saiName = uni.getStorageSync("saiName");
			var obj = uni.getStorageSync("slist")?uni.getStorageSync("slist"):{};
			this.slist = obj.list
			this.subName = obj.name+obj.group_name;
			this.mr = obj.mr;
			this.type = obj.type;
			
			if(app.globalData.socketWBObj){
				app.globalData.socketWBObj.closeSocket();
			}
			app.globalData.socketWBObj = new this.$websocketUtils(1);
			//监听获取消息
			 uni.$on('socketMessage', res=>{
				 if(res){
					var { cmd, data } = res.data !='链接成功'?JSON.parse(res.data):{};
					//成绩
					if(cmd == 'score'){
						uni.setStorageSync("slist",data)
						uni.navigateTo({
							url: '/pages/score/index'
						})
					}else if(cmd == 'declare') {//宣告
						var obj = data;
						this.slist = obj.list
						this.subName = obj.name+obj.group_name;
						this.mr = obj.mr;
						this.type = obj.type;
					}else if(cmd == 'schedule') {//日程
						uni.setStorageSync("slist",data)
						uni.navigateTo({
							url: '/pages/schedule/index'
						})
					}else if(cmd == 'check_in') {//检录
						uni.setStorageSync("slist",data)
						uni.navigateTo({
							url: '/pages/check/index'
						})
					}else if(cmd == 'award') {//颁奖
						uni.setStorageSync("slist",data)
						uni.navigateTo({
							url: '/pages/check/index'
						})
					}else if(cmd == 'clear') {//清屏
						uni.navigateTo({
							url: '/pages/clear/index'
						})
					}else if(cmd == 'declareInfo') {
						console.log(1111111111111,data)
						this.declareInfo = data
						this.$forceUpdate();
					}
				 }
			 })
		},
		methods: {
			arrayUnique(arr, name) {
			    var hash = {};
			    return arr.reduce(function (item, next) {
			        hash[next[name]]
			            ? ""
			            : (hash[next[name]] = true && item.push(next));
			        return item;
			    }, []);
			},
		}
	}
</script>

<style lang="scss" scoped>
.body{
	width: 100%;
	min-height: calc(100vh - 184px);
	background: url(@/static/bg3.png) center center no-repeat;
	background-size: cover;
	.xh{
		width: 10%;
	}
	.xm{
		width: 15%;
		text-align: left;
	}
	.jls{
		width: 20%;
		text-align: left;
	}
	.dyc{
		width: 20%;
		text-align: left;
	}
	.dec{
		width: 20%;
		text-align: left;
	}
	.dsc{
		width: 15%;
		text-align: left;
	}
	.a{
		width: 100%;
		background-color: #FFFFFF;
		font-weight: 400;
		font-size: 50px;
		color: #DD1D2B;	
		text-align: center;
		.d{
			display: flex;
			height: 66px;
			align-items: center;
			justify-content: space-between;
		}
	}
	.c{
		width: 100%;
		display: flex;
		align-items: center;
		.d{
			flex: 1;
			
		}
		.e{
			width: 420px;
			padding: 0 10px;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			image{
				width: 100%;
				height: 100%;
			}
		}
	}
	.b{
		.c{
			align-items: inherit;
			height: calc(100vh - 184px - 176px);
		}
		.d{
			border-right: 1px solid #6286d7;
		}
		.items{
			height: 88px;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			border-top: 1px solid #6286d7;
			image{
				width: 415px;
				height: 45px;
				margin-right: 45rpx;
			}
			.timer{
				font-weight: 500;
				font-size: 36px;
				color: #FFFFFF;
				margin-left: 24px;
			}
		}
		.item{
			height: 82px;
			display: flex;
			align-items: center;
			justify-content: space-between;
			font-size: 40px;
			color: #FFFFFF;
			text-align: center;
			border-top: 1px solid #6286d7;
			&-on{
				background-color: #6286d7;
			}
			.xh{
				display: flex;
				align-items: center;
				justify-content: center;
				text{
					display: block;
					width: 94px;
					line-height: 60px;
					background: #DD1D2B;
					border-radius: 5px;
				}
			}
			.xm{
				
					display: flex;
					align-items: center;
					text-align: center;
					justify-content: center;
				text{
					display: block;
					width: 140px;
					line-height: 60px;
					background: #f36337;
					border-radius: 10px;
				}
			}
		}
	}
}
@media screen and (min-width: 1200px) and (max-width: 1359px) {
	.body{
		.a{
			font-size: 36px;
		}
		.b{
			.item{
				font-size: 26px;
				.xh{
					text{
						width: 60px;
					}
				}
			}
			
		}
		.c .e{
			width: 300px;
		}
		.dyc{
			white-space: nowrap;
		}
	}
}
@media screen and (min-width: 1360px) and (max-width: 1500px) {
	.body{
		.a{
			font-size: 36px;
		}
		.b{
			.item{
				font-size: 36px;
				.xh{
					text{
						width: 60px;
					}
				}
			}
			
		}
		.c .e{
			width: 360px;
		}
		.dyc{
			white-space: nowrap;
		}
	}
}
</style>
