<template>
	<view style="background: #F1F2F5;">
		<RefreshView ref="mescrollRef" :pageBg="F1F2F5" @refresh="refresh" :hasBack="true" text="活动列表"
			:useDownScroll="true" :useUpScroll="true">
			<view>
				<view v-for="(item,index) in list " :key="index">
					<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 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: #efefef; 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
				});

			},

		}
	}
</script>

<style lang="scss">
	.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>
