<template>
	<app-layout>
		<view class="container">
			<template  v-if="lists.length > 0">
				<view class="cell-box main-left" v-for="(item,index) in lists" :key="index">
					<view class="head-img">
						<u-image
								width="140"
								height="140"
								:src="item.child.head_img"
								shape="circle"></u-image>
					</view>
					<view class="nickname main-left cross-center">
						<text>{{item.child.nickname}}</text>
						<u-image
								width="35"
								height="35"
								src="@/static/images/vip.png"
								v-if="item.child.is_vip"
						></u-image>
					</view>
					<view class="price main-center cross-center">
						推荐奖励：<text>{{item.income}}</text>元
					</view>
				</view>
				<u-line></u-line>
			</template>
			<view class="no-data main-center cross-center" v-else>
				<text>暂无数据</text>
			</view>
		</view>
	</app-layout>
</template>

<script>
	import appLayout from "@/components/app-layout"
	export default {
		components:{
			appLayout,
		},
		data() {
			return {
				lists: [],
				currentPage: 1,
				totalPage: 0
			}
		},
		methods: {
			getList(page){
				this.$u.api.userIncome(page).then(res => {
					this.currentPage = res.current_page
					this.totalPage = res.last_page
					this.lists = this.lists.concat(res.data);
				})
			}
		},
		onLoad(){
			this.getList();
		},
		onReachBottom(){
			if(this.currentPage < this.totalPage){
				this.getList(this.currentPage+1)
			}
		}
	}
</script>

<style lang="scss" scoped>
	.cell-box{
		padding: 30rpx 0;
		.head-img{}
		.nickname{
			flex: 1;
			padding: 0 30rpx;
			color: #333333;
			font-size: 32rpx;
			font-weight: 500;
			text{
				margin-right: 12rpx;
			}
		}
		.price{
			color: #666666;
			font-size: 28rpx;
		}
	}
</style>
