<template>
	<div class="income">
		<view class="tips">
			<view>待结算：订单未满48小时退款保障期，资金暂未进余额</view>
			<view>已结算：订单已进入退款保障期，资金已计入可提现余额</view>
		</view>
		<view class="list">
			<view class="tabs">
				<view class="tabsItem" :class="{'active': tabsIndex === index}" v-for="(item,index) in tabs" :key="index" @click="handlechange(item, index)">{{ item }}</view>
			</view>
			<view class="all">
				<view class="incomeList">
					<view class="listItem" v-for="(item, index) in incomeList" :key="index">
						<view class="date">{{ item.date }}</view>
						<view class="subList">
							<view class="subItem" v-for="(sub, subindex) in item.records" :key="subindex">
								<view class="top">
									<view class="left">
										<view class="name">{{ sub.projectNames }}</view>
										<view :class="{'one': sub.wStatus != 2, 'two': sub.wStatus == 2}">{{ sub.wStatus == 2?'已结算':'待结算' }}</view>
									</view>
									<view class="right">
										+{{ sub.rPrice }}
									</view>
								</view>
								<view class="subDate">{{ sub.cTime }}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="pending">
				<view class="incomeList">
					<view class="listItem" v-for="(item, index) in incomeList" :key="index">
						<view class="date">{{ item.date }}</view>
						<view class="subList">
							<view class="subItem" v-for="(sub, subindex) in item.records" :key="subindex">
								<view class="top">
									<view class="left">
										<view class="name">{{ sub.projectNames }}</view>
										<view :class="{'one': sub.wStatus != 2, 'two': sub.wStatus == 2}">{{ sub.wStatus == 2?'已结算':'待结算' }}</view>
									</view>
									<view class="right">
										+{{ sub.rPrice }}
									</view>
								</view>
								<view class="subDate">{{ sub.cTime }}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="pass">
				<view class="incomeList">
					<view class="listItem" v-for="(item, index) in incomeList" :key="index">
						<view class="date">{{ item.date }}</view>
						<view class="subList">
							<view class="subItem" v-for="(sub, subindex) in item.records" :key="subindex">
								<view class="top">
									<view class="left">
										<view class="name">{{ sub.projectNames }}</view>
										<view :class="{'one': sub.wStatus != 2, 'two': sub.wStatus == 2}">{{ sub.wStatus == 2?'已结算':'待结算' }}</view>
									</view>
									<view class="right">
										+{{ sub.rPrice }}
									</view>
								</view>
								<view class="subDate">{{ sub.cTime }}</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</div>
</template>

<script>
	import { myIncomeDetail } from '@/api/index.js'
	export default {
		data() {
			return {
				tabs: [
					'全部','待结算','已结算'
				],
				tabsIndex: 0,
				incomeList: [],
			}
		},
		onShow() {
			this.getMyIncomeDetail()
		},
		methods: {
			handlechange(item, index) {
				this.tabsIndex = index
				this.getMyIncomeDetail()
			},
			getMyIncomeDetail() {
				let obj = null
				if(this.tabsIndex == 1) {
					obj = {
						wStatus: 1
					}
				}
				if(this.tabsIndex == 2) {
					obj = {
						wStatus: 2
					}
				}
				myIncomeDetail(obj).then(res => {
					if(res.data.code == 200) {
						if(res.data.data && res.data.data.length > 0) {
							this.incomeList = res.data.data
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.income{
		width: calc(100vw - 76rpx);
		height: calc(100vh - 60rpx);
		padding: 30rpx 38rpx;
		background: linear-gradient(152deg, #DCFFF8 0%, #F1FEFF 100%);
		.tips{
			color: #999999;
			font-size: 24rpx;
			height: 92rpx;
		}
		.list{
			width: 100%;
			height: calc(100% - 92rpx);
			background: #ffffff;
			border-radius: 10rpx;
			overflow: hidden;
			.tabs{
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin: 18rpx 24rpx;
				.tabsItem{
					padding: 0 26rpx;
					border-bottom: 4rpx solid #ffffff;
				}
				.active{
					border-bottom: 4rpx solid #03C1B8;
				}
			}
			.all, .pending, .pass{
				height: calc(100% - 100rpx);
				overflow-y: auto;
				.incomeList{
					.listItem{
						width: 100%;
						padding: 0 24rpx;
						.date{
							color: #333333;
							margin: 24rpx 0 16rpx;
						}
						.subList{
							.subItem{
								margin-bottom: 16rpx;
								.top{
									width: 100%;
									display: flex;
									align-items: center;
									justify-content: space-between;
									color: #333333;
									font-size: 28rpx;
									.left{
										display: flex;
										width: 70%;
										align-items: center;
										justify-content: flex-start;
										.name{
											margin-right: 16rpx;
											max-width: 70%;
											overflow: hidden;
											white-space: nowrap;
											text-overflow: ellipsis;
										}
										.one{
											padding: 4rpx;
											background: #EEEEEE;
											border-radius: 4rpx;
											font-size: 20rpx;
										}
										.two{
											padding: 4rpx;
											background: #ECFEFD;
											border-radius: 4rpx;
											font-size: 20rpx;
											color: #03C8BE;
										}
									}
								}
								.subDate{
									margin-top: 8rpx;
									font-size: 24rpx;
									color: #999999;
								}
							}
						}
					}
				}
			}
		}
	}
</style>
