<template>
	<view class="running-water">
		<navbar :title="title[status]" leftClick @leftClick="leftClick" />

		<view style="background-color: red;height: 250rpx;">

		</view>

		<view class="sum">
			<view class="left">
				<view class="tiele">总佣金(元)</view>
				<view class="price">￥1240.00</view>
				<view class="btn">去提现</view>
			</view>
			<view class="right">
				<view class="tiele">累计提现(元)</view>
				<view class="price">￥1240.00</view>
				<view class="btn">提现记录</view>
			</view>
		</view>

		<view class="searchCondition">
			<!--搜索框-->
			<span style="margin-right: 40rpx;">金额明细</span>
			
			
			<view class="dateTimeCls">
				<view class="date" @click="startDateOpen">
					{{ queryParams.startDate }}
					<uv-datetime-picker ref="startDateRef" v-model="queryParams.startDate" mode="date"
						@confirm="startDateChange"></uv-datetime-picker>
				</view>
				<view class="image">
					<image src="../static/order/2.svg" style="width: 100%;height: 100%"></image>
				</view>
			</view>
			<span style="margin:  0 20rpx;">-</span>
			<view class="dateTimeCls">
				<view class="date" @click="endDateOpen">
					{{ queryParams.endDate }}
					<uv-datetime-picker ref="endDateRef" v-model="queryParams.endDate" mode="date"
						@confirm="endDateChange">
					</uv-datetime-picker>
				</view>
				<view class="image">
					<image src="../static/order/2.svg" style="width: 100%;height: 100%"></image>
				</view>
			</view>
		</view>

		<view class="tab-box">
			<view class="tab-box1" v-if="agentFlow.records.length>0 && agentFlow.total>0">
				<uv-cell center border :title="item.title" v-for="(item, index) in agentFlow.records"
					:value="x[item.type] + item.money" :label="item.createTime" />
			</view>
			<view style="padding: 100rpx 0;" v-else>
				<uv-empty mode="history" textSize="28rpx" iconSize="100rpx" />
			</view>
		</view>

	</view>
</template>

<script>
	import dayjs from "dayjs";
	export default {
		data() {
			return {
				queryParams: {
					pageNo: 1,
					pageSize: 10,
					startDate: dayjs(new Date()).subtract(30, 'day').format('YYYY-MM-DD'),
					endDate: dayjs(new Date()).format('YYYY-MM-DD'),
				},
				title: ['余额记录', '提现记录', '佣金记录'],
				agentFlow: {
					total: 1,
					records: [{
							type: 0,
							money: 100,
							createTime: '2024-04-02 20:00',
							title: "佣金提现",
						},
						{
							type: 0,
							money: 100,
							createTime: '2024-04-02 20:00',
							title: "佣金提现",
						},
						{
							type: 0,
							money: 100,
							createTime: '2024-04-02 20:00',
							title: "佣金提现",
						},
					]
				},
				x: ['+', '-', '-', '+'],
				status: 0,
			}
		},
		onLoad(e) {
			this.status = e.status
		},
		methods: {
			leftClick() { //返回钱包
				uni.navigateBack(-1)
			},
			getAgentFlow() { //获取流水记录
				let type = this.status;
				this.$api('getAgentFlow', {
					type
				}, res => {
					if (res.code == 200) {
						this.agentFlow = res.result
					}
				})
			},
			startDateChange(val) {
				this.$nextTick(() => {
					this.queryParams.startDate = dayjs(val.value).format("YYYY-MM-DD")
					// this.getData()
				});
			},
			startDateOpen() {
				this.$refs.startDateRef.open();
			},
			endDateChange(val) {
				this.$nextTick(() => {
					this.queryParams.endDate = dayjs(val.value).format("YYYY-MM-DD")
					// this.getData()
				});
			},
			endDateOpen() {
				this.$refs.endDateRef.open();
			},
		}
	}
</script>

<style lang="scss" scoped>
	.running-water {
		width: 750rpx;
		margin: 0 auto;
		min-height: 100vh;
		position: absolute;
		background: #F5F5F5;
		.tab-box {
			margin: 20rpx;
			// margin-top: 100rpx;
			background-color: #fff;
			border-radius: 20rpx;
			overflow: hidden;
		}

		.sum {
			display: flex;
			justify-content: center;
			gap: 100rpx;
			width: 90%;
			height: 200rpx;
			margin-top: 20rpx;
			padding: 20rpx;
			border: 1px solid #fff;
			background-color: #fff;
			z-index: 999;
			border-radius: 40rpx;
			box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);
			position: absolute;
			top: 220rpx;
			left: 20rpx;


			.left {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;

				.title {
					font-size: 28rpx;
				}

				.price {
					font-size: 30rpx;
					font-weight: 700;
					color: #dc2929;
				}

				.btn {
					padding: 10rpx 15rpx;
					border: 1px solid #dc2929;
					color: #dc2929;
					border-radius: 20rpx;
				}
			}

			.right {
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;

				.title {
					font-size: 28rpx;
				}

				.price {
					font-size: 30rpx;
					font-weight: 700;
					color: #dc2929;
				}

				.btn {
					padding: 10rpx 15rpx;
					border: 1px solid #dc2929;
					color: #dc2929;
					border-radius: 20rpx;
				}
			}
		}

		.searchCondition {
			
			display: flex;	
			width: 100vw;
			padding:  0 40rpx;
			padding-top: 130rpx;
			background-color: #fff;
			.dateTimeCls {
				
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 30%;
				border: 1px solid #b0b2b3;
				padding: 5rpx;
				border-radius: 20rpx;

				.date {
					font-size: 25rpx;
					display: flex;
					align-items: center;
					width: 80%;
					height: 100%;
					color: #b0b2b3;

				}

				.image {
					width: 20%;
					height: 100%;
				}
			}
		}
	}
</style>