<template>
	<view class="content">
		<view class="content-money">
			<view class="money-box">
				<view class="goback-box" @click="toBack">
					<image class="goback" src="../../static/img/fanhui.png" mode=""></image>
				</view>
				<view class="header">金豆池</view>
				<image class="money_bg" src="../../static/img/anchor8.png"></image>
				<view class="money">{{jd}}</view>
				<view class="tip">
					金豆数量
				</view>
			</view>
		</view>
		<view class="title">
			- 实时累计 -
		</view>
		<scroll-view class="swiper-box" scroll-y>
			<!-- 空白页 -->
			<!-- <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty> -->
			<!-- 订单列表 -->
			<template>
				<view v-for="(item, index) in dataList" class="order-item flex">
					<view class="left flex">
						<view class="avator">
							<image :src="item.pay_evaluation" mode=""></image>
						</view>
						<view class="order-font">
							{{item.user.real_name}}扣除<text>{{item.use_integral}}</text>个金豆
						</view>
					</view>
					<view class="time">
						{{item.add_time}}
					</view>
				</view>
			</template>
			<!-- <uni-load-more :status="tabItem.loadingType"></uni-load-more> -->
		</scroll-view>
	</view>
</template>

<script>
	import {
		getTime
	} from '@/utils/rocessor.js'
	import {
		jdCoool
	} from '@/api/wallet.js';
	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
	import empty from '@/components/empty';
	export default {
		components: {
			empty,
			uniLoadMore
		},
		data() {
			return {

				jd: 0,
				loadingType: 'more',
				limit: 10, //每次加载多少信息
				page: 1, //页数
				dataList: []

			}
		},

		onReady(res) {
			// 初始化获取页面宽度
			var _this = this;
			uni.getSystemInfo({
				success: resu => {
					const query = uni.createSelectorQuery();
					query.select('.swiper-box').boundingClientRect();
					query.exec(function(res) {
						_this.maxheight = resu.windowHeight - res[0].top + 'px';
						console.log('打印页面的剩余高度', _this.height);
					});
				},
				fail: res => {}
			});
		},
		onLoad() {
			this.loadData();

		},
		methods: {
			toBack() {
				uni.switchTab({
					url: '/pages/user/user'
				});
			},
			loadData() {
				let obj = this
				if(obj.loadingType == 'noMore'){
					return
				}
				jdCoool({
					page: obj.page,
					limit: obj.limit
				}).then(res => {
					console.log(res);
					obj.jd = res.data.sum
					res.data.data = res.data.data.map(item => {
						item.add_time = getTime(item.add_time);
						let data = item.add_time.split(' ');
						item.add_time = data[0]
						return item;
					})
					obj.dataList = obj.dataList.concat(res.data.data)
					obj.page++;
					//判断是否还有数据，有改为more，没有各位noMore
					if(obj.limit == res.data.data.length){
						obj.loadingType = 'more'
						return
					}else{
						obj.loadingType = 'noMore'
					}
					this.$set(obj.dataList,'loaded',true)
				}).catch(e=>{
					console.log(e);
				})
			}
		}
	};
</script>

<style lang="scss">
	page {
		background: #ffffff;
		height: 100%;
	}

	.content-money {
		background: $page-color-base;

		// border: 2px solid #ffffff;
		// padding-top: var(--status-bar-height);
		.moneyTx {
			position: absolute;
			top: 120rpx;
			right: 0rpx;
			// width: 150rpx;
			padding: 10rpx 10rpx;
			border: 2px solid #ffffff;
			border-top-left-radius: 15rpx;
			border-bottom-left-radius: 15rpx;
			line-height: 1;
			font-size: $font-base;
			background: #ffffff;
		}

		.buttom-box {
			background-color: #ffffff;
			text-align: center;
			margin: 0 30rpx;
			padding: 20rpx 0;
			border-radius: $border-radius-sm;
			margin-top: -60rpx;

			.buttom {
				font-size: $font-lg;
				flex-grow: 1;
			}

			.interval {
				width: 2px;
				height: 60rpx;
				background-color: #eeeeee;
			}

			.icon {
				height: 36rpx;
				width: 36rpx;
				margin: 0 auto;

				.icon-img {
					width: 100%;
					height: 100%;
				}
			}
		}
	}

	.money-box {
		height: 430rpx;
		color: #ffffff;
		text-align: center;
		position: relative;
		background-color: pink;

		.header {
			position: absolute;
			left: 0;
			top: 0;
			width: 100%;
			height: 80rpx;
			font-size: 32rpx;
			font-weight: 700;
			z-index: 99;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.goback-box {
			position: absolute;
			left: 18rpx;
			top: 0;
			height: 80rpx;
			display: flex;
			align-items: center;
		}

		.goback {
			z-index: 100;
			width: 34rpx;
			height: 34rpx;
		}

		.money_bg {
			width: 100%;
			height: 430rpx;
			display: block;
		}

		.text {
			padding-top: 80rpx;
			font-size: $font-lg;
		}

		.money {
			position: absolute;
			top: 0;
			width: 100%;
			padding-top: 186rpx;
			font-size: 84rpx;
			font-weight: bold;
		}

		.tip {
			position: absolute;
			top: 0;
			width: 100%;
			text-align: center;
			padding-top: 304rpx;
			font-size: 26rpx;
			font-family: PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
		}
	}

	.title {
		height: 82rpx;
		line-height: 82rpx;
		text-align: center;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: #333333;
		border-bottom: 1px solid #f0f0f0;
	}

	// 列表
	.swiper-box {
		.order-item {
			padding: 18rpx 24rpx 14rpx;
			border-bottom: 1px solid #f0f0f0;

			.left {
				justify-content: flex-start;

				.avator {
					width: 70rpx;
					height: 70rpx;
					border-radius: 50rpx;
					background: #03A9F4;

					image {
						width: 70rpx;
						height: 70rpx;
						border-radius: 50rpx;
					}
				}

				.order-font {
					margin-left: 10rpx;
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 500;
					color: #3F454B;

					text {
						color: #FF4D4C;
					}
				}
			}

			.time {
				font-size: 22rpx;
				font-family: PingFang SC;
				font-weight: 400;
				color: #999999;
			}

		}
	}

	.content {
		height: 100%;

		.empty-content {
			background-color: #ffffff;
		}
	}
</style>
