<template>
	<view class="distribution">
		<view class="distribution-block">
			<!-- 	<view class="title" @click="handleCollapse(item.id)">
				<text>{{item.label}}</text>
				<u-icon :name="getIsOpenItem(item.id) ? 'arrow-down-fill' : 'arrow-up-fill'" color="#9D9D9D" size="12">
				</u-icon>
			</view> -->
			<view class="list" v-for="info in list" :key="info.id">
				<view class="item">
					<view class="display-flex-between">
						<view class="code">
							订单编号：{{info.order_no}}
						</view>
						<view class="time">
							{{info.date}}
						</view>
					</view>
					<view class="display-flex-between">
						<view class="name">
							<text style="color: #696969;font-weight: 400;">用户昵称：</text>{{info.order_user}}
						</view>
						<view class="amount">
							<text class="color-red">￥{{info.amount}}</text>
							<!-- <text style="font-weight: 400;">({{info.status == 0 ? '冻结':'解冻'}})</text> -->
						</view>
					</view>
					<view class="display-flex-between">
						<view class="name">
							<text style="color: #696969;font-weight: 400;">订单金额：</text>￥{{info.order_amount}}
						</view>
						<view class="amount">
							<text>{{info.status == 0 ? '冻结':'解冻'}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				collapseIds: ["00000"],
				list: [],
				page: 1,
				pageSize: 10,
				total: 0,
			};
		},
		onLoad() {
			this.getData(true)
		},
		onReachBottom() {
			this.getData()
		},
		methods: {
			getData(initFlag) {
				if (!initFlag) {
					if (this.page * this.pageSize < this.total) {
						this.page++
					} else {
						return
					}
				} else {
					this.page = 1
					this.total = 0
					this.list = []
				}
				let sendData = {
					page: this.page,
					pageSize: this.pageSize
				}
				this.$api.getDistributionData(sendData).then(res => {
					this.list = this.list.concat(res.data.list)
					// this.list = [{ order_no: 1111, order_user: '测试', date: '2022-09-20 13:77:11', amount: 1000 }]
					this.total = res.data.page.total
				})
			},
			getIsOpenItem(id) {
				return this.collapseIds.includes(id)
			},
			handleCollapse(id) {
				if (this.getIsOpenItem(id)) {
					this.collapseIds = this.collapseIds.filter(c => c !== id)
					console.log('this.collapseIds', this.collapseIds)
				} else {
					this.collapseIds.push(id)
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.distribution {
		height: 100%;
		background-color: #F5F6F8;
		padding: 20rpx 20rpx 40rpx;
		box-sizing: border-box;

		&-block {
			&:nth-child(n+2) {
				margin-top: 20rpx;
			}

			.title {
				height: 76rpx;
				background: #ECECEC;
				border-radius: 10rpx;
				display: flex;
				align-items: center;
				font-size: 26rpx;
				font-weight: 500;
				color: #222423;
				line-height: 1;
				padding: 0 24rpx;

				text {
					margin-right: 8rpx;
				}
			}

			.item {
				// height: 159rpx;
				background: #FFFFFF;
				border-radius: 10rpx;
				padding: 20rpx 25rpx;
				margin-top: 15rpx;
				// display: flex;
				// justify-content: space-between;
				// align-items: center;

				.code {
					font-size: 28rpx;
					font-weight: 500;
					color: #222423;
					line-height: 39rpx;
				}

				.name {
					font-size: 28rpx;
					font-weight: bold;
					color: #232323;
					line-height: 39rpx;
					margin-top: 18rpx;
				}

				.time {
					font-size: 24rpx;
					font-family: PingFang SC-Medium, PingFang SC;
					font-weight: 500;
					color: #B2B2B2;
					line-height: 34rpx;
				}

				.amount {
					text-align: right;
					margin-top: 18rpx;
					font-size: 32rpx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;

					line-height: 46rpx;
				}
			}
		}
	}
</style>
