<template>
	<view>
		<RefreshView ref="mescrollRef" @refresh="refresh" :hasBack="true" text="首页" :useDownScroll="true"
			:useUpScroll="false" pageBg="#F1F2F5">

			<view style="display: flex;flex-direction: column;align-items: center;width: 100vw;">

				<view
					style="display: flex;flex-direction: column;align-items: center;background-color: #2fa1f0;padding-top: 80rpx;">

					<view style="width: 100vw;text-align: center;font-size: 60rpx;font-weight: 700;color: aliceblue;">
						体育活动</view>
					<view
						style="width: 100vw;text-align: center;font-size: 35rpx;font-weight: 300;color: beige;margin-top: 10rpx;">
						组织报名工具</view>

					<view @click="jump(1)" style="width: 80%;background-color: #FFFFFF;display: flex;flex-direction: row;align-items: center;justify-content: center;
					border-radius:100rpx;margin-top: 80rpx;margin-bottom: 20rpx;height: 80rpx;">
						<image src="../../static/custom-icon/click.png" style="width: 60rpx;height: 60rpx;"></image>
						<text>一分钟创建 轻松组织活动</text>
					</view>

					<view style="width: 85%;display: flex;flex-direction: row;align-items: center;
					margin-top: 10rpx;margin-bottom: 20rpx;height: 80rpx;">
						<image src="../../static/custom-icon/notice.png"
							style="width: 40rpx;height: 40rpx;flex-shrink: 0;margin-right: 20rpx;"></image>
						<text
							style="font-size: 26rpx;font-weight: 200;">您注册的账号可以在宇运动旗下的子平台一号通行，同时您发布的活动将会按类别同步到各子平台</text>
					</view>
				</view>

				<view class="nav-bar" @click="jump(3)">
					<view>
						<text class="bar-text">最新活动</text>
						<image src="../../static/custom-icon/new2.png"
							style="width: 40rpx;height: 40rpx;flex-shrink: 0;margin-left: 10rpx;"></image>
					</view>
					<image class="bar-img" src="../../static/home-icon/more_text.png" mode="aspectFit" @tap="newGame">
					</image>
				</view>

				<view v-for="(item,index) in list " :key="index" style="width: 100%;">
					<view
						style="display: flex;flex-direction: column;margin-bottom: 30rpx; padding: 30rpx;background: #FFFFFF;"
						@click="clickItem(index)">
						<view style="display: flex;flex-direction: column;">
							<view style="display: flex; flex-direction: row;">
								<text style="color: #101010; font-size: 32rpx; display:-webkit-box;-webkit-line-clamp:1;
								overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical;
								word-break:break-all;flex: 1;">{{item.name}}</text>
								<text
									style="color: #fff; font-size: 24rpx; background-color: #F2BF5C; padding: 5rpx 10rpx;">{{item.sportCategoryName}}</text>
							</view>
							<text
								style="color: #898989 ; font-size: 28rpx; margin-top: 10rpx;">报名截止：{{item.enrollEndTime}}</text>
						</view>
						<view style="width: 100%;height: 300rpx; margin-top: 20rpx;margin-bottom: 20rpx;">
							<image style="width: 100%;height: 100%; border-radius: 30rpx;" mode="aspectFill"
								:src="item.firstCoverImage"></image>

							<view style="display: flex; height: 50rpx;width: 100%; margin-top: -80rpx; ">
								<view style=" display: flex;align-items: center;width: 100%;">
									<image style="width: 28px;height: 48rpx;margin-left: 30rpx;"
										src="../../static/renqi.png"></image>
									<text style="color: #fff; margin-left: 15rpx;flex: 1;">{{item.popularity}}</text>
									<text
										:class="{'btn1':item.enrollState ==1||item.enrollState ==3,'btn2':item.enrollState==2}"
										style="display: flex;text-align: center; padding: 8rpx 15rpx;
										 color: #FFFFFF; font-size: 28rpx; margin-right:30rpx; border-radius: 10rpx;">{{item.enrollStateName}}</text>

								</view>
							</view>

						</view>

						<view style="width: 100%;" v-for="(info,pos) in item.listActivityItemsArea " :key="pos">
							<view style="display: flex;flex-direction: column;">

								<view
									style="display: flex;flex-direction: row; align-items: center; margin-top: 10rpx;">
									<text style="color: #101010; font-size: 28rpx; flex: 1;">{{info.name}}</text>
									<view style=" align-items: center;">

										<text style="color: #ff0000 ; font-size: 24rpx;">{{info.enrollMoldName}}</text>
										<text
											style="color: #ff0000 ; font-size: 24rpx;margin-left: 10rpx;margin-right: 10rpx;">/</text>
										<text
											style="color: #ff0000 ; font-size: 24rpx;">{{info.enrollMoney==0?"免费":info.enrollMoney}}</text>
									</view>
								</view>

								<view style="display: flex;flex-direction: row;margin-top: 5rpx;">
									<view style="flex: 1; align-items: center;">

										<text style="color: #919191; font-size: 24rpx;">报名数：</text>
										<text
											style="color: #919191 ; font-size: 24rpx;">{{info.enrollNumbers==0?"暂无":info.enrollNumbersLimit+'人'}}</text>
										<text
											style="color: #919191 ; font-size: 24rpx;margin-left: 10rpx;margin-right: 10rpx;">/</text>
										<text
											style="color: #919191 ; font-size: 24rpx;">{{info.enrollNumbersLimit==0?"不限":info.enrollNumbersLimit+'人'}}</text>
									</view>

									<text
										style="margin-top: 10rpx; color: #919191; font-size: 24rpx;">{{info.startTime}}</text>

								</view>

								<view v-if="item.listActivityItemsArea.length>pos+1"
									style="width: 100%; height: 2rpx;background-color: #101010; margin-top: 10rpx;">
								</view>
							</view>
						</view>


					</view>
				</view>
			</view>
		</RefreshView>
	</view>
</template>

<script>
	// 必须
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		// 使用mixin (在main.js注册全局组件) 必须
		mixins: [MescrollMixin],
		data() {
			return {
				index: 0,
				list: []
			}
		},
		methods: {
			refresh(page) {
				let _this = this
				this.HTTP({
					url: 'aos/v1/activityManagement/getActivityAreaPagerList',
					paramsType: "JSON",
					method: "POST",
					data: {
						current: page.num,
						size: 10,
						params: {
							name: "",
							userSid: getApp().globalData.memberSid,
						}
					},
					loading: true
				}).then((res) => {
					// 成功关闭刷新状态
					_this.$refs.mescrollRef.refreshFinished(res.data.records.length)
					if (page.num == 1) {
						// 第一页 先清空集合数据
						_this.list = []
					}

					// 追加数据
					_this.list = _this.list.concat(res.data.records)

				}).catch(function(err) {
					console.log("11111");
					_this.$refs.mescrollRef.refreshError()
				});
			},
			clickItem(index) {

				let raceSid = this.list[index].sid
				console.log(raceSid)
				uni.navigateTo({
					url: 'DetailActivity?raceSid=' + raceSid
				});

			},
			jump(index) {
				let _this = this
				switch (index) {
					case 1:
						// 新建活动
						uni.navigateTo({
							url: "activity?isCreate=0&sid="
						})
						break;
					case 2:
						// 草稿箱
						uni.navigateTo({
							// url: '../index/exemptionActivity?raceSid=' + res.data
						})
						break;
					case 3:
						// 活动列表
						uni.navigateTo({
							url: "activityList"
						})
						break;

				}
			}
		}
	}
</script>

<style lang="scss">
	.line {
		width: 100%;
		height: 18rpx;
		background-color: #f5f4f9;
	}

	.btn {
		display: flex;
		width: 80%;
		height: 80rpx;
		flex-direction: column;
		background-color: $uni-base-color;
		margin-left: auto;
		margin-right: auto;
		align-items: center;
		justify-content: center;
		border-radius: 10rpx;
	}

	.nav-bar {
		height: 92rpx;
		width: 100%;
		display: flex;
		justify-content: space-between;

		.bar-text {
			font-size: 32rpx;
			height: 100%;
			line-height: 92rpx;
			padding-left: 28rpx;
		}

		.bar-img {
			width: 90rpx;
			height: 92rpx;
			padding-right: 28rpx;
		}
	}

	.top {

		display: flex;
		flex-direction: row;
		height: 100rpx;
		background: #FFFFFF;
		opacity: 0.8;
		align-items: center;
		border-radius: 20rpx;
		margin-top: 20rpx;
		margin-left: 30rpx;
		margin-right: 30rpx;

		.unselected {

			text-align: center;
			font-size: 28rpx;
			font-family: Adobe Heiti Std;
			font-weight: normal;
			color: #191919;
			line-height: 40rpx;

		}

		.selected {
			text-align: center;
			font-size: 28rpx;
			font-family: Adobe Heiti Std;
			font-weight: normal;
			color: #2CAB69;
			line-height: 40rpx;
			border-bottom: 2rpx #2CAB69 solid;
			padding-bottom: 10rpx;
		}

	}

	.btn1 {
		background: #BBBBBB;
	}

	.btn2 {
		background: #0081D5;
	}
</style>
