<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.detail.headimage" mode=""
						style="width: 690rpx;height: 482rpx;border-radius: 10rpx;"></image>
					<span class="title white-space">{{item.detail.title}}</span>
					<view class="icon flex align-items">
						<span class="white-space"
							style="font-size: 24rpx;">{{'活动时间: ' + item.detail.start_time_text + '-' + item.detail.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.detail.feel == 1">活动费用:{{'' + '公益'}}</span>
							<span style="color:#7A7A7A;" v-if="item.detail.feel == 2">活动费用:{{'￥'+ item.price}}</span>
						</span>

					</view>
					<view class="icon flex align-items" style="margin-top: 0rpx;margin-bottom: 32rpx;">
						<span class="status" v-if="item.status == -3" style="color: #FF0000;">已取消</span>
						<span class="status text-blue" v-if="item.status == 0">待支付</span>
						<span class="status text-blue" v-if="item.status == 2">待审核</span>
						<span class="status text-blue" v-if="item.status == 3">已预约</span>
						<span class="status" v-if="item.status == 4" style="color: #FF0000;">售后中</span>
						<span class="status" v-if="item.status == 5" style="color: #FF0000;">退款中</span>
						<span class="status" v-if="item.status == 6" style="color: #FF0000;">已退款</span>
						<span class="status" v-if="item.status == 9" style="color: #34DC12;">已完成</span>
					</view>
					<span class="Sign bg-blue flex justify-center align-items" v-if="item.status == 3"
						@click.stop="QR(item.id)">二 维 码</span>
					<span class="hui bg-hui flex justify-center align-items" v-if="item.status != 3">二 维 码</span>
				</view>

			</view>
		</view>
		<u-popup :show="show" mode="center" :zIndex="99999" :custom-style="popupStyle" closeable="true" @close="qrClose"
			@open="qrOpen">
			<view class="popup flex flex-column align-items">
				<view class="pop-center flex">
					<!-- <view class="left">
						<image :src="qrcode.detail.headimage" mode="" style="width: 280rpx;height: 200rpx;"></image>
					</view> -->
					<view class="right flex flex-column">
						<span class="title white-space">{{qrcode.detail.title}}</span>
						<span class="line-short"></span>
						<span class="hui" style="margin-bottom: 20rpx;">活动时间:{{' ' + qrcode.detail.start_time_text}} -
							{{qrcode.detail.end_time_text}}</span>
						<span class="hui">报名时间:{{' ' + qrcode.detail.sign_start_time_text}} -
							{{qrcode.detail.sign_end_time_text}}</span>
						<span class="hui" style="margin: 20rpx 0;">活动地址:{{' ' + qrcode.detail.address_detail}}</span>
						<view class="flex align-items">
							<span class="hui">{{'审核状态:' + ' '}}</span>
							<span class="status" v-if="qrcode.status == -3" style="color: #FF0000;">已取消</span>
							<span class="status text-blue" v-if="qrcode.status == 0">待支付</span>
							<span class="status text-blue" v-if="qrcode.status == 2">待审核</span>
							<span class="status text-blue" v-if="qrcode.status == 3">已预约</span>
							<span class="status" v-if="qrcode.status == 4" style="color: #FF0000;">售后中</span>
							<span class="status" v-if="qrcode.status == 5" style="color: #FF0000;">退款中</span>
							<span class="status" v-if="qrcode.status == 6" style="color: #FF0000;">已退款</span>
							<span class="status" v-if="qrcode.status == 9" style="color: #34DC12;">已完成</span>
						</view>

					</view>
				</view>
				<image :src="qrcode.codeimage" mode="" style="width: 376rpx;height: 376rpx;"></image>
				<span style="margin: 24rpx 0 64rpx 0;">核销二维码</span>
			</view>
		</u-popup>
		<u-loadmore :status="loadStatus" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				keywords: '',
				list: [],
				count: 0,
				loadStatus: 'loading',
				popupStyle: {
					width: '690rpx',
					margin: '0 auto', // 水平居中
					display: 'flex',
					justifyContent: 'center',
					alignItems: 'center',
					padding: '0',
					borderRadius: '20rpx'
				},
				show: false,
				qrcode: {}

			};
		},
		onLoad() {
			this.getList()
		},
		onReachBottom() {
			if (this.list.length < this.count) {
				this.page++;
				this.getList();
			}
		},
		methods: {
			// 关闭弹窗
			qrClose() {
				this.show = false
				// this.qrcode = ''
			},
			qrOpen() {
				this.show = true
			},
			// 核销码
			QR(id) {
				uni.$u.http.get('/api/school.activity.order/detail', {
					params: {
						id: id
					},
				}).then(res => {
					if (res.code == 1) {
						this.qrcode = res.data.detail
						this.show = true
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(error => {});

			},
			getList() {
				uni.$u.http.get('/api/school.activity.order/order_list', {
					params: {
						keywords: this.keywords,
						page: this.page,
						limit: this.limit,
						status: '-3,0,2,3,4,5,6,9'
					}
				}).then(res => {
					if (res.code == 1) {
						this.count = res.data.count
						this.list = [...this.list, ...res.data.list];
						if (this.list.length >= res.data.count) {
							this.loadStatus = 'nomore';
						} else {
							this.loadStatus = 'loading';
						}
					} else {
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				}).catch(error => {
					uni.showToast({
						title: '请求失败，请稍后再试',
						icon: 'none',
						duration: 2000
					});
				});
			},
			open(id) {
				uni.navigateTo({
					url: "/packageA/activity/exerciseDetaill?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%;
		}

		/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 {
				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;
			}

			.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>