<template>
	<view class="center">
		<view class="empty-box"><u-empty v-if="orderList.length === 0 && loadingType == 'nomore'"></u-empty></view>
		<scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
			<!-- 空白页 -->
			

			<!-- 订单列表 -->
			<view v-for="(item, index) in orderList" :key="index" class="order-item flex" @click="nav(item)">
				<view class="title-box flex_item">
					<view class="title-avatar"><image :src="item.avatar"></image></view>
					<view class="list_tpl">
						<view class="title">
							<text>{{ item.email || item.phone }}</text>
						</view>
						<view class="time">
							<text>{{ item.time }}</text>
						</view>
					</view>
				</view>
			</view>
			<u-loadmore v-if="orderList.length != 0" :status="loadingType" />
		</scroll-view>
	</view>
</template>

<script>
import { spread } from '@/api/finance.js';
export default {
	data() {
		return {
			orderList: [{}],
			loadingType: 'loadmore', //页面加载即时刷新
			page: 1, //默认展示一行
			limit: 10 //一行展示10条数据
		};
	},
	onLoad(options) {
		this.loadData(); //onload只是在第一次进入页面会刷新数据，从二级页面回来不会重新加载数据
	},

	onShow() {
		//onShow没有参数
		this.loadData(); //onshow在每次打开页面都会加载数据，可以用于数据在需要刷新的环境下
	},
	methods: {
		async loadData() {
			if (this.loadingType == 'nomore' || this.loadingType == 'loading') {
				return;
			}
			this.loadingType = 'loading';
			spread({
				limit: 10,
				page: 1
			}).then(({ data }) => {
				this.all = data.total;
				this.orderList = data.list;
				if (data.length != this.limit) {
					this.loadingType = 'nomore';
				} else {
					this.page++;
					this.loadingType = 'loadmore';
				}
			});
		},
		nav(e){
			uni.navigateTo({
				url:'/pages/user/rake?uid=' + e.uid
			})
		}
	}
};
</script>

<style lang="scss">
.list-scroll-content {
	height: auto;
}
.order-item {
	padding: 20rpx 30rpx;
	line-height: 1.5;

	.title-box {
		width: 100%;

		.title-avatar {
			width: 100rpx;
			height: 100rpx;
			margin-right: 25rpx;
			border-radius: 100%;
			image {
				width: 100%;
				height: 100%;
				border-radius: 100%;
			}
		}

		.list_tpl {
			width: 85%;

			.title {
				font-size: $font-lg;
				color: $font-color-base;
				overflow: hidden; //超出的文本隐藏
				text-overflow: ellipsis; //溢出用省略号显示
				white-space: nowrap;
			}

			.time {
				font-size: $font-base;
				color: $font-color-light;
			}
		}
	}

	.money {
		color: #db1935;
		font-size: $font-lg;
	}
}
.content {
	height: 100%;

	.empty-content {
		background-color: #ffffff;
	}
}
.empty-box {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	width: 100%;
	height: 100%;
}
</style>
