<template>
	<view class="box">


		<!-- 统计 -->
		<view class="sumBg">
			<view class="viewBg">
				<view class="money" style="color: #FF4F00;">￥{{detailData.totalMoney}}</view>
				<view class="moneyTitle">累计佣金

				</view>
			</view>

			<view class="line"></view>
			<view class="viewBg">
				<view class="money">￥{{detailData.withdrawalMoney}}</view>
				<view class="moneyTitle">累计提现

				</view>
			</view>

			<view class="line"></view>
			<view class="viewBg">
				<view class="money">￥{{detailData.cantidatMoney}}</view>
				<view class="moneyTitle">可提现

				</view>
			</view>
		</view>

		<!-- 明细 -->
		<view class="mingxiBg" v-if="arr.length > 0">

			<view v-for="(item,index) in arr" :key="index">
				<view class="itemBg">
					<image :src='item.MemberHeadImg' mode="" style="width: 72rpx; height: 72rpx; border-radius: 36rpx;">
					</image>
					<view class="nickName" v-if="item.MemberNickName">{{item.MemberNickName}}</view>
					<view class="time">{{item.CreateTime.slice(0,item.CreateTime.length-8)}}</view>
					<view class="jine">+{{item.Money}}</view>
				</view>
			</view>


		</view>


		<!-- 上拉 加载更多 -->
		<view class="noMore" v-if="noMoreShow">没有更多数据</view>

		<view style="height: 120rpx;"></view>
		<view class="bottomView">
			<view class="goExtract" @click="gonavigateTo('extract?okMoney='+ detailData.cantidatMoney)">去提现</view>
		</view>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				detailData: {},
				arr: [],
				noMoreShow: false,
			}
		},
		onShow() {
			this.getDetailData();
			this.page = 1;
			this.getItemData();
		},
		methods: {
			getDetailData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'worldKeepCar/worldDistribution/queryDistributionIndexDetail',
					params = {

					}
				this.$http(url, params, 'GET').then(res => {
					uni.hideLoading();
					var data = res.data


					// 处理 undefined和null转为空白字符串

					for (const key in data) {
						data[key] = this.$praseStrEmpty(data[key])
					}

					this.detailData = data



				})
			},
			getItemData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'worldKeepCar/worldDistribution/listEarningsPage',
					params = {
						page: this.page,
						limit: 10,
					}
				this.$http(url, params, 'GET').then(res => {
					uni.hideLoading();
					var list = res.data.Items

					// 处理 undefined和null转为空白字符串
					list.forEach((item, index) => {
						for (const key in item) {
							item[key] = this.$praseStrEmpty(item[key])
						}
					})


					if (this.page == 1) {
						this.arr = list
					} else {
						this.arr = this.arr.concat(list)
					}

					if (list.length < 10) {
						this.noMoreShow = true
					} else {
						this.noMoreShow = false
					}


				})
			},
			gonavigateTo(url) {

				uni.navigateTo({
					url: url
				})
			}
		},

		// 下拉刷新 上拉加载更多
		onPullDownRefresh() {
			this.page = 1;
			this.getItemData()

			this.getDetailData()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;

			this.getItemData()

		},

	}
</script>

<style scoped>
	.box {
		min-height: 100vh;
		background: #F4F5F7;
		padding-top: 20rpx;
	}



	.sumBg {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 0 24rpx 20rpx;
		padding: 36rpx 50rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;
	}

	.viewBg {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #FFFFFF;
	}

	.money {
		font-size: 38rpx;
		color: #000000;
		font-weight: bold;
	}

	.moneyTitle {
		font-size: 28rpx;
		color: #666666;
	}

	.line {
		width: 1rpx;
		height: 73rpx;

		background-color: #EEEEEE;
	}

	.mingxiBg {
		margin: 0rpx 24rpx;
		background-color: #FFFFFF;

		border-radius: 10rpx;
		padding: 20rpx;
	}


	.itemBg {

		height: 98rpx;

		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.nickName {
		font-size: 30rpx;
		color: #3C3C3C;
		width: 40%;
		margin: 0 15rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.time {
		font-size: 30rpx;
		color: #999999;
		
		width: 27%;
	}

	.jine {
		font-size: 32rpx;
		color: #FF4F00;
		font-weight: bold;
		margin: 0 15rpx;
		
	}

	.bottomView {
		width: 100%;
		height: 120rpx;

		position: fixed;
		left: 0;
		bottom: 0;
		background-color: #FFFFFF;
	}

	.goExtract {
		margin: 23rpx 30rpx;
		border-radius: 37rpx;
		background: linear-gradient(124deg, #FF8700 0%, #FF4F00 100%);

		font-size: 30rpx;
		color: #FFFFFF;
		font-weight: bold;
		height: 74rpx;
		line-height: 74rpx;
		text-align: center;
	}

	.noMore {
		text-align: center;
		line-height: 50rpx;
		color: #999999;
		font-size: 28rpx;
	}
</style>
