<template>
	<view class="center-box">
		<view class="box flex flex-column flex-start">
			<view class="listBox flex flex-column flex-start">
				<view class="list flex flex-column flex-start" v-for="(item,index) in list" :key="index"
					@click="open(item.id)">
					<image :src="item.headimage" mode=""
						style="width: 690rpx;height: 482rpx;border-radius: 10rpx;"></image>
					<span class="title white-space">{{item.title}}</span>
					<view class="icon flex align-items">
						<span class="white-space"
							style="font-size: 24rpx;">{{'活动时间: ' + item.start_time_text + '-' + item.end_time_text}}</span>
					</view>
					<view class="icon flex align-items" style="margin-bottom: 8rpx;margin-top: 8rpx;width: 400rpx;">
						<span class="white-space" style="font-size: 24rpx;color: #FF2323;">
							<span style="color:#7A7A7A;" v-if="item.feel == 1">活动费用:{{'' + '公益'}}</span>
							<span style="color:#7A7A7A;" v-if="item.feel == 2">活动费用:{{'￥'+ item.price}}</span>
						</span>

					</view>
					<span class="Sign bg-blue flex justify-center align-items" @click.stop="open(item.id)">订单管理</span>
				</view>

			</view>
		</view>
		<u-loadmore :status="loadStatus" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				keywords: '',
				list: [],
				count: 1,
				loadStatus: 'nomore',
				shop_id: '',

			};
		},
		onLoad() {
			this.shop_id = uni.getStorageSync('shop_id')
		},
		onShow() {
			this.page = 1
			this.list = []
			this.getList();
		},
		onReachBottom() {
			// this.getList();
			if (this.count) {
				this.getList();
			}
		},
		methods: {
			// 活动管理
			open(id){
				uni.navigateTo({
					url:"/packageA/activity/acList?id=" + id
				})
			},
			getList() {
				uni.$u.http.get('/api/school/activity/activity_list', {
					params: {
						keywords: this.keywords,
						page: this.page,
						limit: this.limit,
						order: 'normal',
						shop_id: this.shop_id,
						status: '1'
					}
				}).then(res => {
					if (res.code == 1) {
						if (res.data.list.data.length > 0) {
							this.count = res.data.list.data.length;
							if(this.count){
								this.loadStatus = 'nomore';
								this.page++;
							} else {
								this.loadStatus = 'loading';
							}
							this.list = [...this.list, ...res.data.list.data]
							
							// if (this.list.length >= this.count) {
							// 	this.loadStatus = 'loading';
							// } else {
							// 	this.loadStatus = 'nomore';
							// }
						
						} else {
							// this.count = this.list.length
							this.loadStatus = 'nomore';
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(error => {
					console.log(error)
					uni.showToast({
						title: '请求失败，请稍后再试',
						icon: 'none',
						duration: 2000
					});
				});
			},
			open(id) {
				uni.navigateTo({
					url: "/packageA/activity/acList?id=" + id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.center-box {
		width: 750rpx;
		background: #F1F2F8;
		min-height: 100vh;
	}

	.box {
		width: 690rpx;
		padding: 0 30rpx 0rpx 30rpx;
		border-radius: 0px 0px 0px 0px;

	}

	.white-space {
		overflow: hidden;
		/* 确保超出容器的文本被隐藏 */
		white-space: nowrap;
		/* 确保文本在一行内显示 */
		text-overflow: ellipsis;
		/* 使用省略号表示被截断的文本 */
		width: 100%;
	}

	.search {
		margin-top: 27rpx;
		width: 690rpx;
		height: 64rpx;
		background: #FFFFFF;
		box-shadow: 2rpx 2rpx 0rpx 0rpx rgba(0, 0, 0, 0.4);
		border-radius: 8rpx 8rpx 8rpx 8rpx;
		border: 2rpx solid #008CFF;

		.dashed {
			image {
				width: 52rpx;
				height: 52rpx;
			}
		}

		.line-search {
			width: 2rpx;
			height: 42rpx;
			background: #008CFF;
			border-radius: 0rpx 0rpx 0rpx 0rpx;
		}

		.input {
			// border: 4rpx solid #EAEAEA;
			padding-left: 12rpx;
			height: 100%;
			width: 78%;
		}

		::v-deep .input-placeholder {
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #C0C0C0;
			line-height: 32rpx;
			text-align: left;
			font-style: normal;
			text-transform: none;

		}

		.searchBtn {
			width: 128rpx;
			height: 64rpx;
			background: #008CFF;
			border-radius: 5rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #FFFFFF;
			display: flex;
			justify-content: center;
			align-items: center;
		}

	}

	.white-space {
		overflow: hidden;
		/* 确保超出容器的文本被隐藏 */
		white-space: nowrap;
		/* 确保文本在一行内显示 */
		text-overflow: ellipsis;
		/* 使用省略号表示被截断的文本 */
		width: 100%;
	}

	.w-100 {
		width: 100%;
	}

	.flex {
		display: flex;
	}

	.justify-center {
		justify-content: center;
	}

	.align-items {
		align-items: center;
	}

	.flex-column {
		flex-flow: column;
	}

	.justify-start {
		justify-content: start;
	}

	.listBox {
		width: 690rpx;
		margin-top: 10rpx;

		.list {
			margin-top: 32rpx;
			position: relative;
			background: #FFFFFF;
			border-radius: 10rpx;

			.title {
				width: 642rpx;
				margin-top: 32rpx;
				margin-left: 24rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 32rpx;
				color: #343434;
			}

			.icon {
				width: 580rpx;
				margin-top: 24rpx;
				margin-left: 24rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #7A7A7A;
			}

			.Sign {
				width: 170rpx;
				height: 56rpx;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 32rpx;
				color: #FFFFFF;
				letter-spacing: 8rpx;
				align-self: flex-end;
				margin-right: 24rpx;
				margin-bottom: 32rpx;
			}

			.hui {
				position: absolute;
				bottom: 32rpx;
				right: 54rpx;
				width: 152rpx;
				height: 56rpx;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 32rpx;
				color: #FFFFFF;
			}
		}
	}

	.icon-size {
		width: 32rpx;
		height: 32rpx;
		margin-right: 8rpx;
	}

	.status {
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		font-size: 26rpx;
		color: #008CFF;
	}

	.popup {
		.header {
			margin-left: 24rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 800;
			font-size: 42rpx;
			color: #008CFF;
			margin-top: 34rpx;
			width: 690rpx;
		}

		.line-row {
			width: 690rpx;
			height: 1rpx;
			background: #D9D9D9;
			margin: 11rpx 0 31rpx 0;
		}

		.pop-center {
			margin-top: 50rpx;
			align-items: center;
			width: 650rpx;

			.left {
				image {
					border-radius: 12rpx;
				}
			}

			.right {
				// margin-left: 30rpx;

				.title {
					width: 650rpx;
					font-family: PingFang SC, PingFang SC;
					font-weight: 800;
					font-size: 42rpx;
					color: #343434;
				}

				.line-short {
					width: 642rpx;
					height: 1rpx;
					background: #D9D9D9;
					border-radius: 0rpx 0rpx 0rpx 0rpx;
					margin: 25rpx 0 25rpx 0;
				}

				.status {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 26rpx;
				}

				.hui {
					font-family: PingFang SC, PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #7A7A7A;
				}


			}
		}

		.popList {
			justify-content: space-between;
			width: 600rpx;
			margin-top: 32rpx;

			.hei {
				font-family: PingFang SC, PingFang SC;
				font-weight: 500;
				font-size: 26rpx;
				color: #343434;
			}
		}

		.pop-btn {
			width: 690rpx;
			margin-top: 62rpx;
			justify-content: space-around;

			.Cancel {
				width: 306rpx;
				height: 80rpx;
				border-radius: 401rpx 401rpx 401rpx 401rpx;
				border: 2rpx solid #008CFF;
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 34rpx;
				color: #008CFF;
			}

			.Confirm {
				width: 306rpx;
				height: 80rpx;
				background: #008CFF;
				border-radius: 401rpx 401rpx 401rpx 401rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 800;
				font-size: 34rpx;
				color: #FFFFFF;
			}
		}
	}
</style>