<template>
	<view class="dikou">
		<view class="dikou-header u-flex u-row-between u-col-top">
			<image src="static/images/yjbg.png" class="header-img" mode=""></image>
			<view class="header-item u-flex-1 u-flex-col">
				<view class="item-top u-flex">
					<text>佣金余额</text>
					<image style="margin-left: 10rpx;" src="static/images/dikou-tips.png" mode=""></image>
				</view>
				<view class="item-price u-flex">
					{{sum || '0.00'}}
					<image style="margin-left: 20rpx;" @click="totixian" src="static/images/dikou-tixian.png"
						class="item-tixian" mode=""></image>
				</view>
				<view class="u-flex">
					<view class="left">
						<text class="top">订单佣金</text>
						<view class="bottom">
							{{order || '0.00'}}
						</view>
					</view>
					<view class="right">
						<text class="top">邀请佣金</text>
						<view class="bottom">
							{{invite || '0.00'}}
						</view>
					</view>
				</view>
			</view>
			<view class="header-item u-flex-1 u-flex-col " style="justify-content: center;" @click="tobank">
				<view class="box">
					<view class="u-flex top1" style="">
						<text class="fontm" style="margin-right: 8rpx;min-width: 100rpx;">佣金明细</text>
						<u-icon name="play-right-fill" style="transform: rotate(90deg);" color="#fff"
							size="12"></u-icon>
					</view>
					<view class="u-flex bottom1" style="">
						<text class="fontm" style="margin-right: 8rpx;min-width: 100rpx;">银行卡</text>
						<u-icon name="play-right-fill" color="#fff" size="12"></u-icon>
					</view>
				</view>
			</view>
		</view>
		<view class="dikou-list">
			<view class="list-header u-flex u-row-between">
				<view class="header-title u-flex-col">
					<text>收支明细</text>
					<text></text>
				</view>
				<view class="list-time u-flex" @click="showtime = true">
					<text class="text1">{{date || '选择时间'}}</text>
					<u-icon name="arrow-down-fill" size="9"></u-icon>
				</view>
			</view>
			<view class="list-item u-flex u-row-between" v-for="(item,index) in list" :key="index">
				<view class="u-flex-col">
					<text class="text1">{{item.remark}}</text>
					<text class="text2">{{item.createtime}}</text>
				</view>
				<text class="text3" style="color: #E02020;" v-if="item.amount < 0">{{item.amount}}</text>
				<text class="text3" v-else style="color: #35AA1F;">{{item.amount}}</text>
			</view>
			<view style="height: 70vh;justify-content: center;" class="u-flex" v-if="list.length == 0">
				<u-empty text="暂无数据" mode="list"></u-empty>
			</view>
		</view>
		<u-datetime-picker :show="showtime" mode="year-month" @confirm="changetime" @close="close()"></u-datetime-picker>
	</view>
</template>

<script>
	import {
		getBank,
		commission_list,
		index,
		commission_data
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				order: '0.00',
				sum: '0.00',
				invite: '0.00',
				page: 1,
				list: [],
				total: 0,
				date: '',
				showtime: false,
				bankdata: {},
			}
		},
		onShow() {
			this.getuser()
			this.page = 1
			this.total = 0
			this.list = []
			this.getlist()
			this.getdata()
			this.getBank()
		},
		onReachBottom() {
			if (this.total != this.list.length) {
				this.page++
				this.getlist()
			}
		},
		methods: {
			close() {
				this.showtime = false
			},
			getBank() {
				getBank().then(res => {
					this.bankdata = res.data || {}
				})
			},
			async changetime(e) {
				const timeFormat = uni.$u.timeFormat;
				let timeValue = await timeFormat(e.value, 'yyyy-mm');
				this.date = timeValue;
				this.page = 1
				this.total = 0
				this.list = []
				this.getlist()
				this.showtime = false
			},
			getdata() {
				commission_data().then(res => {
					if (res.code == 1) {
						this.invite = res.data.invite //邀请
						this.order = res.data.order //订单
						this.sum = res.data.sum //余额
					} else {
						this.$u.toast(res.msg)
					}
				})
			},
			getlist() {
				commission_list({
					begin_time: "",
					end_time: "",
				}).then(res => {
					console.log(res);
					this.list = this.list.concat(res.data.data)
					this.total = res.data.total
				})
			},
			getuser() {
				index().then(res => {
					this.money = res.data.money
				})
			},
			tobank() {
				uni.navigateTo({
					url: "/pagesD/bank-card"
				})
			},
			totixian() {
				uni.navigateTo({
					url: "/pagesD/tixian"
				})
			}
		}
	}
</script>

<style lang="scss">
	.box {
		width: 172rpx;
		height: 188rpx;
		background: rgba(161, 208, 255, 0.2);
		border-radius: 16rpx;
		backdrop-filter: blur(3px);
		padding: 42rpx 28rpx;
		text-align: center;
		box-sizing: border-box;
		margin-left: 66rpx;
		margin-top: 30rpx;
	}

	.fontm {
		font-size: 24rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
	}

	.top1 {
		margin-bottom: 20rpx;
	}

	.bottom1 {
		border-top: 1rpx solid #FFFFFF;
		padding-top: 20rpx;
	}

	.dikou {
		.dikou-list {
			width: 686rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 20rpx auto;
			padding: 0 28rpx;


			.list-item {
				padding: 30rpx 0;
				border-bottom: 2rpx solid #F0F0F0;

				.text3 {
					font-size: 32rpx;
					font-family: JDZhengHT-Regular, JDZhengHT;
					font-weight: 400;
				}

				.text1 {
					font-size: 30rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
					margin-bottom: 12rpx;
				}

				.text2 {
					font-size: 24rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #222222;
				}
			}

			.list-header {
				padding: 28rpx 0 20rpx 0;

				.list-time {
					.text1 {
						font-size: 32rpx;
						font-family: SFPro-Regular, SFPro;
						font-weight: 400;
						color: #222222;
						margin-right: 8rpx;
					}
				}

				.header-title {
					text:first-child {
						font-size: 32rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						position: relative;
						z-index: 1;
					}

					text:last-child {
						width: 120rpx;
						height: 8rpx;
						background: linear-gradient(270deg, #0C66C2 0%, #FFFFFF 100%);
						border-radius: 6rpx;
						margin-top: -14rpx;
						margin-right: -20rpx;
					}
				}
			}
		}

		.dikou-header {
			margin: 20rpx auto;
			width: 686rpx;
			height: 264rpx;
			position: relative;
			z-index: 1;
			padding: 32rpx 0 0 0;

			.header-item {
				padding: 0 0 0 32rpx;

				.left {
					.top {
						font-size: 20rpx;
						font-family: PingFangSC-Light, PingFang SC;
						font-weight: 300;
						color: #FFFFFF;
					}

					.bottom {
						font-size: 28rpx;
						font-family: JDZhengHT-Regular, JDZhengHT;
						font-weight: 400;
						color: #FFFFFF;
					}
				}

				.right {
					margin-left: 72rpx;

					.top {
						font-size: 20rpx;
						font-family: PingFangSC-Light, PingFang SC;
						font-weight: 300;
						color: #FFFFFF;
					}

					.bottom {
						font-size: 28rpx;
						font-family: JDZhengHT-Regular, JDZhengHT;
						font-weight: 400;
						color: #FFFFFF;
					}
				}

				.item-tixian {
					width: 108rpx;
					height: 48rpx;
				}

				.item-price {
					font-size: 52rpx;
					font-family: JDZhengHT-Regular, JDZhengHT;
					font-weight: 400;
					color: #FFFFFF;
					margin-bottom: 20rpx;
				}

				.item-top {
					margin-bottom: 20rpx;

					text {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #FFFFFF;
						margin-right: 8rpx;
					}

					image {
						width: 28rpx;
						height: 28rpx;
					}
				}
			}

			.header-img {
				width: 686rpx;
				height: 264rpx;
				position: absolute;
				top: 0;
				left: 0;
				z-index: -1;
			}
		}
	}

	page {
		background-color: #F3F3F3;
	}
</style>