<template>
	<view class="container">
		<view class="list-box flex">
			<view class="list-tpl">
				<view class="num">{{data.recommend_num || 0}}</view>
				<view class="name">你的矿工数</view>
			</view>
			<view class="list-tpl" @click="nav('/pages/finance/allMiner')">
				<view class="num">{{data.group_num || 0}}</view>
				<view class="name">总矿工数</view>
			</view>
			<!-- <view class="list-title">我的团队</view> -->
		</view>
		<view class="info-box">
			<view class="info-name flex">
				<view class="info-cell">
					<view class="cell">{{data.recommend_achievement || 0}}T</view>
					<view class="cell-title">分享业绩</view>
				</view>
				<view class="info-cell" >
					<view class="cell">{{data.group_achievenent || 0}}T</view>
					<view class="cell-title">我的业绩</view>
				</view>
				<view class="info-cell" @click="navto()">
					<view class="cell">{{data.today_achievement || 0}}T</view>
					<view class="cell-title">今日新增业绩</view>
				</view>
			</view>
			<view class="list-cell" v-if="list.length > 0">
				<view class="cell-name flex">
					<view class="title">成员信息</view>
					<view class="title-box flex">
						<view class="title">等待算力</view>
						<view class="title">算力</view>
						<view class="title">等级</view>
					</view>
				</view>
				<view class="cell-box flex" v-for="(ls,index) in list" :key='index'>
					<view class="cell-tit flex_item">
						<image :src="ls.avatar"></image>
						<view class="tit-box">
							<view class="tit-tpl clamp">{{ls.nickname}}</view>
							<view class="tit-tip">{{ls.phone}}</view>
						</view>
					</view>
					<view class="flex num-box">
						<view class="num clamp">{{ls.wait_mining}}T</view>
						<view class="num clamp">{{ls.mining}}T</view>
						<view class="level">V{{ls.level}}</view>
					</view>
				</view>
				<view class="nav flex" v-show="page != 1 || isLast">
						<view class="next" @click="last" >
							上一页
						</view>
						
						<view class="next"  @click="next">
							下一页
						</view>
					</view>
				</view>
			<view class="empty-box" v-show="list.length === 0"><empty></empty></view>
		</view>
	</view>
</template>
<script>
import { spread } from '@/api/finance.js';
import empty from '@/components/empty';
export default {
	components: {
		empty
	},
	data() {
		return {
			page: 1,
			limit: 5,
			data:'',
			list:'',
			isLast: true,
		};
	},
	onLoad(option){
		this.loadData();
		this.loadDataNext();
	},
	onShow() {
	},
	methods: {
		// 请求载入数据
		async loadData() {
			let obj = this;
			spread({
				page: obj.page,
				limit: obj.limit
			}).then(({ data }) => {
				obj.data = data;
				obj.list = data.list;
			   console.log(obj.list)
			});
		},
		async loadDataNext() {
			let obj = this;
			console.log(obj.page)
			spread({
				page: obj.page + 1,
				limit: obj.limit,
				
			}).then(({ data }) => {
				if(data.list.length === 0){
					obj.isLast = false;
				}else{
					obj.isLast = true;
				}
				console.log(this.isLast)
			});
		},
		nav(url){
			uni.navigateTo({
				url:url
			})
		},
		navto(url){
			uni.navigateTo({
				url:'/pages/finance/today?num=' + this.data.today_achievement
			})
		},
		next(){
			let that = this;
			this.page = this.page + 1;
			this.loadDataNext();
			if(this.isLast){
				
				this.loadData();
			}else{
				this.page = this.page - 1;
				that.$api.msg('已经是最后一页了')
			}
			
			
			
		},
		last(){
			let that = this;
			if(this.page != 1){
				this.page = this.page - 1;
				this.loadData();
				this.loadDataNext();
			}else{
				that.$api.msg('已经是第一页了')
			}
			
		}
	}
};
</script>

<style lang="scss">
page {
	min-height: 100%;
	background-color: #ffffff;
	.container {
		width: 100%;
	}
}
.list-box{
	width: 100%;
	padding: 50rpx 41rpx;
	padding-top: 80rpx !important;
	background-color: #5771DF;
	position: relative;
	.list-title{
		position: absolute;
		top: 80rpx;
		color: #FFFFFF;
		left: 40%;
		font-size: 36rpx;
	}
	.list-tpl{
		background-color: #FFFFFF;
		width: 314rpx;
		height: 168rpx;
		text-align: center;
		padding-top:40rpx;
		border-radius: 15rpx;
		.num{
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
			padding-bottom: 15rpx;
		}
		.name{
			font-size: 26rpx;
			font-weight: 500;
			color: #999999;
		}
	}
}
.info-box{
	// padding: 25rpx 25rpx;
	.info-name{
		padding: 40rpx 0rpx;
		.info-cell{
			width: 33.33%;
			text-align: center;
			.cell{
				font-size: 38rpx;
				font-weight: bold;
				color: #333333;
			}
			.cell-title{
				font-size: 26rpx;
				font-weight: 500;
				color: #999999;
				padding-top: 20rpx;
			}
		}
	}
	.list-cell{
		padding: 40rpx 25rpx;
		.cell-name{
			padding:50rpx 50rpx;
			.title-box{
				width: 60%;
			}
		}
		.cell-box{
			margin-bottom: 94rpx;
			.cell-tit{
				width: 40%;
				image{
					width: 80rpx;
					height: 80rpx;
					border-radius: 100%;
				}
				.tit-box{
					padding-left: 15rpx;
					width: 70%;
					.tit-tpl{
						font-size: 30rpx;
						font-weight: 500;
						color: #333333;
					}
					.tit-tip{
						font-size: 24rpx;
						font-weight: 500;
						color: #999999;
						padding-top: 20rpx;
					}
				}
			}
			.num-box{
				width: 60%;
				.num{
					width: 33.33%;
					text-align: center;
				}
				.level{
					background-color: #FED82F;
					border-radius: 25rpx;
					padding: 8rpx 50rpx;
					font-size: 26rpx;
				}
			}
		}
	}
}
.empty-box{
	margin-top: 60rpx;
	width: 100%;
	height: 500rpx;
}
.nav{
	.next{
		margin: 40rpx;
		width: 50%;
		background-color: #5771DF;
		color: #FFFFFF;
		text-align: center;
		padding:10rpx 0rpx;
		border-radius: 50rpx;
	}
}
</style>