<template>
	<view class="page">
		<view class="content">
			<view class="title-box"></view>
			<view class="state-bar">
				<image src="../../static/images/ic_arrow_left.png" mode="aspectFill" @click="closePage()"></image>
				<view class="tab">
					<view :class="currentIndex==1? 'tab-1':''">全部</view>
					<view :class="currentIndex==2? 'tab-1':''">我参与的</view>
				</view>
			</view>
			<view class="box">
				<image class="title-img" src="../../static/images/ic_activity_title_bg.png" mode="aspectFill"></image>
				<view class="title-text">
					<text>播撒一片绿色让世界更美</text>
					<text>爱护万千树木让你我同行</text>
				</view>
				<view class="container-box">
					<!-- 搜索框 -->
					<view class="search">
						<view class="search-content">
							<image src="../../static/images/ic_search.png" class="icon" mode="aspectFill"></image>
							<input @input="onSearchInput" placeholder="请输入关键字搜索" />
						</view>
						<view class="btn" @click="doSearch">搜索</view>
					</view>
					<!-- 地区选择 -->
					<view class="area-box">
						<view class="area-title">当前地区:</view>
						<view class="area-picker">全部地区</view>
						<view class="area-picker">地区选择</view>
					</view>
					<!-- 列表 -->
					<view class="content-scroller">
						<scroller @init="initScroller" @down="refreshData" @up="getData" :up="optUp"
							@scroll="navFloatShow(scroller)" :fixed="false">
							<!-- 列表 -->
							<view class="list-box">
								<view class="item" v-for="(item,index) in list" :key="index">
									<view class="title">{{item.title}}</view>
									<view class="item-content">
										<image src="../../static/images/ic_certify_title_bg.png" mode="aspectFill">
										</image>
										<view class="item-box">
											<view class="item-time">活动时间:{{item.startTime}}</view>
											<view class="item-person">参与人数:90/100</view>
											<view class="item-bottom">
												<view>全国</view>
												<text class="status">状态</text>
											</view>
										</view>
									</view>
								</view>
							</view>
						</scroller>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import scroller from '@/components/scroller/scroller.vue';
	export default {
		components: {
			scroller
		},
		data() {
			return {
				currentIndex: 1,
				list: [{
					title: "测试测试测试测试测试测试测试测试测试测试测试测试",
					startTime: "2022年9月10日",
					endTime: "2022年9月30日"
				}, {
					title: "测试测试测试测试测试测试测试测试测试测试测试测试",
					startTime: "2022年9月10日",
					endTime: "2022年9月30日"
				}, {
					title: "测试测试测试测试测试测试测试测试测试测试测试测试",
					startTime: "2022年9月10日",
					endTime: "2022年9月30日"
				}],
				scroller: {},
				optUp: {
					auto: true,
					onScroll: true,
					page: {
						num: 0, //当前页 默认0,回调之前会加1; 即callback(page)会从1开始
						size: 10 //每页数据条数,默认10
					},
					empty: {
						tip: '暂无数据~'
					}
				},
			}
		},
		methods: {
			tabChange(i) {
				this.currentIndex = i;
				if (i == 1) {
					this.bg = this.bg1
				} else {
					this.bg = this.bg2
				}
			},
			closePage() {
				uni.navigateBack()
			},
			onSearchInput(event) {

			},
			/*收搜*/
			doSearch() {

			},
			/*初始化滚动*/
			initScroller(scroller) {
				this.scroller = scroller;
				this.loadData();
			},

			/*刷新数据*/
			refreshData() {
				uni.showLoading({
					title: '刷新中'
				});
				this.scroller.resetUpScroll();
			},

			/*加载数据*/
			loadData() {
				this.list = [];
				this.scroller.resetUpScroll();
			},
			/*滚动时导航栏浮动*/
			navFloatShow(scroller) {

			},
			//获取列表数据
			getData() {
				this.list = [{
					title: "测试测试测试测试测试测试测试测试测试测试测试测试",
					startTime: "2022年9月10日",
					endTime: "2022年9月30日"
				}, {
					title: "测试测试测试测试测试测试测试测试测试测试测试测试",
					startTime: "2022年9月10日",
					endTime: "2022年9月30日"
				}, {
					title: "测试",
					startTime: "2022年9月10日",
					endTime: "2022年9月30日"
				}];
				this.scroller.endBySize(0, 0);
				this.scroller.endSuccess();
				uni.hideLoading()
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;

	}

	.page {
		display: flex;
		flex: 1;
		flex-direction: column;
		overflow: hidden;
		height: 100%;
	}

	.content-scroller {
		flex: 1;
		width: 100%;
		height: 100rpx;
	}

	.content {
		width: 100%;
		position: relative;
		height: 100%;
	}

	.box {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		height: 100%;
		width: 98%;
		position: absolute;
		top: 170rpx;
		left: 50%;
		transform: translate(-50%, 0);
		-webkit-transform: translate(-50%, 0);
		box-shadow: 0rpx 7rpx 33rpx 16rpx rgba(188, 226, 204, 0.15);
		border-radius: 30rpx;

		.title-img {
			width: 443rpx;
			height: 203rpx;
			align-self: center;
		}

		.title-text {
			color: white;
			text-align: center;
			align-self: center;
			display: flex;
			flex-direction: column;
			font-size: 30rpx;
			font-weight: 400;
		}
	}

	.tab-bar {
		width: 100%;
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		padding-top: 15rpx;

		.tab-active {
			text-align: center;
			font-size: 40rpx;
			font-weight: bold;
			color: #00821E;
		}

		.tab-default {
			text-align: center;
			font-size: 40rpx;
			font-weight: 200;
			color: #00821E;
		}
	}

	.title-box {
		width: 100%;
		height: 800rpx;
		background-image: url('../../static/images/ic_activity_bg.png');
		background-size: 100% 100%;
		background-repeat: no-repeat;
	}

	.state-bar {
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		margin: 45rpx 0rpx;
		height: 100rpx;
		display: flex;
		flex-direction: row;
		align-items: center;

		image {
			width: 50rpx;
			height: 50rpx;
			margin-left: 20rpx;
		}

		.tab {
			display: flex;
			flex-direction: row;
			color: white;
			justify-content: center;
			font-size: 40rpx;
			align-self: center;
			text-align: center;
			width: 100%;
			margin-left: -70rpx;

			:last-child {
				margin-left: 40rpx;
			}

			.tab-1 {
				border-bottom-width: 8rpx;
				border-bottom-style: solid;
				border-bottom-color: white;
			}
		}
	}

	.container-box {
		display: flex;
		flex-direction: column;
		background-color: white;
		justify-content: center;
		align-items: flex-start;
		margin: 20rpx;
		padding: 30rpx 0rpx;
		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
		height: 100%;

		.area-box {
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: flex-start;
			margin: 30rpx;

			.area-title {
				font-size: 30rpx;
				color: #747474;
			}

			.area-picker {
				background-color: #E8F6EE;
				margin-left: 20rpx;
				color: #b3b3b3;
				padding: 10rpx 30rpx;
			}
		}
	}

	/*搜索*/
	.search {
		padding: 10rpx 24rpx 10rpx 24rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		width: 90%;
		align-self: center;

		.search-content {
			background: #f2f2f2;
			border-radius: 15px;
			padding: 10rpx 24rpx 10rpx 24rpx;
			margin-right: 15rpx;
			flex: 1;
			display: flex;
			align-items: center;
		}

		/deep/.input {
			color: #8cc7b5;
		}

		.icon {
			width: 30rpx;
			height: 30rpx;
			margin-right: 15rpx;
		}

		.btn {
			color: #b3b3b3;
		}
	}

	.list-box {
		display: flex;
		flex-direction: column;
		justify-content: flex-start;
		align-items: flex-start;
		padding: 20rpx;
		width: 95%;

		.item {
			display: flex;
			flex-direction: column;
			background: white;
			border-radius: 10rpx;
			margin: 20rpx 0rpx;
			width: 100%;
			box-shadow: 0rpx 7rpx 33rpx 16rpx rgba(188, 226, 204, 0.15);

			.item-content {
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 10rpx;

				image {
					width: 200rpx;
					height: 130rpx;
				}

				.item-box {
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: flex-start;
					width: 100%;
					margin-left: 20rpx;

					.item-title {
						color: #747474;

					}

					.item-person {
						color: #747474;
					}

					.item-bottom {
						display: flex;
						flex-direction: row;
						width: 95%;
						justify-content: space-between;
						color: #747474;

						.status {
							color: #00821E;
							border: 1rpx #8cc7b5 solid;
							padding: 0rpx 20rpx;
							margin: 0rpx;
							font-size: 10rpx;
							text-align: center;
						}
					}
				}
			}



			.title {
				font-size: 30rpx;
				display: -webkit-box;
				text-overflow: ellipsis;
				-webkit-line-clamp: 1;
				-webkit-box-orient: vertical;
				overflow: hidden;
				padding: 10rpx;
				color: #000;
			}


		}

	}
</style>
