<template>
	<view class="GroupPurchaseOrder">
		<u-navbar title="团购订单" leftIconColor="#000" rightIcon='../../static/common/white_left_arrrow.png' placeholder
			leftIconSize='38rpx' autoBack="true">
		</u-navbar>
		<view class="tabsList">
			<view class="tabsItem" v-for="(item,index) in tabs" :style="{color: tabsIndex==index ? '#FF4502':'#999999'}"
				:key="index" @click="cutTabs(item,index)">
				{{item.label}}
			</view>
		</view>
		<view class="cardList">
			<view class="cardItem" v-for="(item,index) in goodsList" :key="index" @click="skipPages(item,index)">
				<image :src="item.goodsImage" class="itemImg" :mode="'scaleToFill'"></image>
				<view class="itemText">
					<view class="textT">
						<view class="labelName ellipsis">
							{{item.goodsName}}
						</view>
						<view class="labelIcon" v-if="item.status==7">
							未成团
						</view>
						<view class="labelIcon" v-if="item.status==8">
							已成团
						</view>
						<view class="labelIcon" v-if="item.status==9">
							已取消
						</view>

					</view>
					<view class="textC">
						<view class="Clabel">
							团购人数：
						</view>
						<view class="Cnum">
							{{item.clusteringNum}}人
						</view>
						<view class="knockdownNum">
							已成团：{{item.groupNumbered}}人
						</view>
					</view>
					<view class="textB">
						<view class="currentPrice">
							￥{{item.groupBuyingPrice}}
						</view>
						<view class="originalPrice">
							￥{{item.originalPrice}}
						</view>
						<view class="timeRemaining">
							{{item.time}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				tabs: [{
					label: "未成团",
					index: 7
				}, {
					label: "已成团",
					index: 8
				}, {
					label: "已取消",
					index: 9
				}],
				tabsIndex: 0,
				pageNum: 1,
				pageSize: 10,
				goodsList: [],
				statusData: 7
			}
		},
		onShow() {
			this.getListData()
		},
		methods: {

			getListData() {
				this.$http.post('/api/client/userInfo/groupOrderList', {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
					status: this.statusData
				}).then(res => {
					this.goodsList = res.data.data.rows
				})
			},
			skipPages(data, index) {
				uni.navigateTo({
					url: `/pagesA/orderDetails/orderDetails?id=${data.orderId}`
				})
			},
			// orderDetails/orderDetails
			cutTabs(data, index) {
				this.tabsIndex = index
				this.statusData = data.index
				this.getListData()
			}
		}
	}
</script>

<style lang="scss">
	.GroupPurchaseOrder {
		min-height: 100vh;
		background-color: #FAF7F6;

		.tabsList {
			// margin: 30rpx;
			padding: 20rpx 24rpx;
			box-sizing: border-box;
			display: flex;
			align-items: center;
			justify-content: start;
			background-color: #FFFFFF;

			.tabsItem {
				margin-right: 56rpx;
				font-weight: 400;
				font-size: 32rpx;
				color: #999999;

			}
		}

		.cardList {
			margin-top: 31rpx;

			.cardItem {
				display: flex;
				// align-items: center;
				margin: auto;
				margin-top: 20rpx;
				padding: 20rpx;
				box-sizing: border-box;
				width: 702rpx;
				height: 199rpx;
				background: #FFFFFF;
				border-radius: 14rpx 14rpx 14rpx 14rpx;

				.itemImg {
					width: 156rpx;
					height: 156rpx;
					background: #FFECEC;
					border-radius: 8rpx 8rpx 8rpx 8rpx;
				}

				.itemText {
					position: relative;
					margin-left: 15rpx;
					width: calc(100% - 166rpx);

					.textT {
						display: flex;

						.labelName {
							width: 412rpx;
							font-weight: 400;
							font-size: 28rpx;
							color: #333333;
						}

						.labelIcon {
							position: absolute;
							top: -10rpx;
							right: 0;
							margin-left: auto;
							font-weight: 400;
							font-size: 24rpx;
							color: #FF4502;
						}
					}

					.textC {
						display: flex;
						margin: 18rpx 0;
						align-items: center;

						.Clabel {
							font-weight: 400;
							font-size: 28rpx;
							color: #333;
						}

						.Cnum {
							margin-left: 10rpx;
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
						}

						.knockdownNum {
							margin-left: auto;
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
						}
					}

					.textB {
						display: flex;
						align-items: center;

						.currentPrice {
							font-weight: bold;
							font-size: 28rpx;
							color: #FF4502;
						}

						.originalPrice {
							margin-left: 15rpx;
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
							// 删除线
							text-decoration: line-through;
						}

						.timeRemaining {
							position: absolute;
							right: 0;
							bottom: -10rpx;
							margin-left: auto;
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
						}
					}
				}
			}
		}
	}
</style>