<template>
	<view class="main pt0">
		<view class="message _error" v-if="total > 0">你有：{{ this.total }}份简历未处理，请及时处理。</view>
		<view class="item" v-for="(item, index) in list" :key="index" @click="go('/pages/user/resume/deliver/receive/list?id=' + item.id + '&title=' + item.title + '&total=' + item.total)">
			<view class="title omit">{{ item.title }}</view>
			<view class="desc">
				<view class="progress">
					<u-line-progress :percentage="(item.isRead / item.total).toFixed(2) * 100" :height="20" text="已读"></u-line-progress>
				</view>
				<view class="all">{{ item.total }}份</view>
			</view>
		</view>
		<view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
		<u-empty v-if="!loadMore && list.length == 0"></u-empty>
	</view>
</template>
<script>
export default {
	data() {
		return {
			list: [],
			param: { pageNum: 1, pageSize: 10 },
			loadMore: true,
			total: 0
		};
	},
	onLoad(e) {
		this.getData();
	},
	methods: {
		getData() {
			this.total = 0;
			this.http.request({
				url: '/app/deliver/receive',
				data: this.param,
				loading: 'false',
				success: (res) => {
					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
					res.data.rows.forEach((item) => {
						this.list.push(item);
						this.total = this.total + (item.total - item.isRead);
					});
				}
			});
		},
		go(url) {
			uni.navigateTo({ url: url });
		},
		//刷新数据
		refresh() {
			this.loadMore = true;
			this.param.pageNum = 1;
			this.list = [];
			this.getData();
		}
	},
	//下拉刷新
	onPullDownRefresh() {
		setTimeout(() => {
			this.refresh();
			uni.stopPullDownRefresh();
		}, 1000);
	},
	//上拉加载
	onReachBottom() {
		if (this.loadMore) {
			this.param.pageNum++;
			this.getData();
		}
	}
};
</script>

<style lang="scss">
.item {
	background-color: white;
	border-radius: 7px;
	padding: 15px;
	overflow: hidden;
	margin-bottom: 12px;
	.title {
		border-radius: 3px;
		font-weight: bold;
		font-size: 18px;
	}
	.desc {
		margin-top: 10px;
		color: $font-c;
		font-size: 15px;
		margin-left: -5px;
		.progress {
			float: left;
			width: 90%;
		}
		.all {
			float: left;
			padding-left: 5px;
		}
	}
}
</style>
