<template>
	<view class="content flex_col flex_start">
		
<!-- 		<view class="load-none flex_col">
			<image src="../../static/images/event/enent_none.png" mode="aspectFill"></image>
			<text>还没有任何赛事~</text>
		</view> -->
		
		<!-- item -->
		<view class="item flex_col flex_start_y bg-white padding " v-for="(i,k) in pageList" :key="k" @click="jumpDetail(i)">
			
			<view class="time flex_row">
				<image src="../../static/images/event/event_lock.png" mode=""></image>
				<text>{{i.match_sign_before}}</text>
				<text>前报名</text>
			</view>
			<view class="box flex_row flex_start_y">
				<text class="img_tag" :class="i.match_status_text=='已结束'?'img_tag_white':''"  >{{i.match_status_text}}</text>
				<image class="img" :src="i.match_cover" mode=""></image>
				
				<view class="info flex_col flex_start flex_start_y">
					<view class="event_title flex_row flex_start flex_start_y">
						<!-- <text class="tag tag_green" >团队</text>
						<text class="tag tag_blue" >个人</text> -->
						<text class="tag tag_blue" :class="i.match_type=='personal'?'tag_blue':'tag_green'" >{{i.match_type_text}}</text>
						<text class="match_name" >{{i.match_name|autoAddPoints}}</text>
					</view>
					<view class="location flex_row">
						<image  src="../../static/images/event/event_location.png" mode=""></image>
						<!-- <text class="text-maxline-one">{{i.match_addr}}</text> -->
						<text class="">{{i.match_addr}}</text>
					</view>
				</view>
				
			</view>
			
		</view>
		
		<view class="load-finish" v-if="listLoadFinished">我是有底线的～</view>
		
		<no-data :txt="no_data_txt" v-if="pageList.length==0"></no-data>
		
	</view>
</template>
<script>
	import {matchList} from "../../nxTemp/apis/userAPI.js"
	export default {
		data() {
			return {
				postData:{
					page:1,
					page_size:10
				},
				listLoadFinished:false,
				listTotal:0,
				pageList:[],
				no_data_txt:"还没有任何赛事~"
			};
		},
		onLoad(opt) {
			this.updatePage()
		},
		onUnload() {
			this.resetPostData()
		},
		onPullDownRefresh(){
			console.log("onPullDownRefresh");
		},
		onReachBottom(){
			console.log("onReachBottom");
			this.updatePage()
		},
		methods: {
			jumpDetail(i){
				let {match_id,brand_id,is_show_match_assistant_score_nav_bar:showHeader} = i
				this.$Router.push({
					name:"eventGrade",
					params:{
						match_id,brand_id,showHeader
					}
				})
			},
			jumpPage(name){
				this.$Router.push({name})
			},
			//更新页面列表
			updatePage() {
				if(this.listLoadFinished)return this.$tools.showNone("已加载完毕")
				matchList(this.postData).then(res => {
					// this.$tools.showNone("已更新");
					this.pageList.push(...res.list)
					checkListLoadFinished(res,this);
				}).catch(e=>{
					this.$tools.showNone(e.errMsg)
				})
				function checkListLoadFinished(res,that){
					if(that.pageList.length == res.total)that.listLoadFinished = true
					else that.postData.page++
				}
			},
			//预留
			getFilteredItem(item){
				return Promise.resolve({}=item)
			},
			//重置请求参数
			resetPostData(){
				this.postData = {
					page:1,
					page_size:10
				}
			},
			
			
		}
	}
</script>

<style lang="less" scoped>
page{
	background: #F2F2F7;
	// height: 100vh;
}
.content{
	
	.item{
		color: #333333;
		position: relative;
		margin-top: 24rpx;
		border-radius: 10rpx;
		width: 702rpx;
		height: 368rpx;
		.box{
			font-size: 32rpx;
			color: #1A1A1A;	
			margin-bottom: 10rpx;
			font-weight: 700;
			.img{
				width: 300rpx;
				height: 224rpx;
				background-color: lightgray;
			}
			.img_tag{
				position: absolute;
				left: 40rpx;
				top: 120rpx;
				z-index: 99;
				width: 100rpx;
				height: 40rpx;
				background: #009874;
				border-radius: 6rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				font-weight: border;
				text-align: center;
				line-height: 40rpx;
			}
			.img_tag_white{
				background: #FFFFFF;
				color: #9A9A9D;
			}
			.info{
				width: 350rpx;
				font-size: 36rpx;
				color: #333333;
				margin-left: 10rpx;
				.location{
					// width: 330rpx;
					margin-left: 10rpx;
					margin-top: 14rpx;
					font-size: 24rpx;
					color: #9A9A9D;
					// display: inline;
					text-align: left;
					>image{
						width: 28rpx;
						height: 28rpx;
					}
					>text{
						margin-left: 5rpx;
						width: 320rpx;
					}
				}
				.event_title{
					text-align: left;
					display: inline;
					> text{
						margin-left: 10rpx;
						// margin-bottom: 10rpx;
					}
				}
				.tag{
					// margin-right: 10rpx;
					font-size: 24rpx;
					width: 64rpx;
					height: 36rpx;
					border-radius: 6rpx;
					text-align: center;
					line-height: 36rpx;
					padding: 5rpx 5rpx;
			
				}
				.match_name{
					// padding-top: 50rpx;
				}
				.tag_blue{
					color: #32C5FF;
					background: #E0F6FF;
				}
				.tag_green{
					color: #36C990;
					background: #DBF5EB;
				}
			}
		}
		.time{
			font-size: 28rpx;
			color: #9A9A9D;
			margin-bottom: 32rpx;
			>image{
				width: 32rpx;
				height: 32rpx;
			}
			>text{
				margin: 0 30rpx 0 10rpx;
			}

			
		}
		.bandage{
			width: 16rpx;
			height: 16rpx;
			// position: absolute;
			// right: 60rpx;
			background: #EA5061;
			border-radius: 50%;
			font-size: 24rpx;
			color: white;
			text-align: center;
			line-height: 34rpx;
			margin-top: -16rpx;
			margin-left: 10rpx;
		}
	}
	
	.load-finish{
		padding: 40rpx;
		font-size: 28rpx;
		color: #9A9A9D;
	}
}

.text-maxline-two {
	text-overflow: ellipsis;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	word-break: break-all;
	overflow: hidden;
	display: -webkit-box;
}
.load-none{
	> image{
		margin-top: 33vh;
		width: 368rpx;
		height: 316rpx;
	}
	> text{
		padding: 40rpx;
		font-size: 28rpx;
		color: #9A9A9D;
	}
}
</style>
