<template>
	<view class="main pt0">
		<view class="message _error" v-if="total > 0">你有：{{ 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="top">
				<view class="title omit">{{ item.title }}</view>
				<view class="bage" v-if="item.noRead > 0">{{ item.noRead > 99 ? '99+' : item.noRead }}</view>
			</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);
						item.noRead = parseInt(item.total) - parseInt(item.isRead);
						this.total = this.total + item.noRead;
					});
					console.log('asd:' + this.total);
				}
			});
		},
		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;
	.top {
		overflow: hidden;
		position: relative;
		.title {
			border-radius: 3px;
			font-weight: bold;
			font-size: 18px;
			width: 70%;
			float: left;
		}
		.bage {
			position: absolute;
			padding: 0px 5px;
			border-radius: 20px;
			background-color: red;
			color: white;
			top: 2px;
			right: 7px;
			font-size: 14px;
		}
	}
	.desc {
		margin-top: 10px;
		color: $font-c;
		font-size: 15px;
		margin-left: -5px;
		overflow: hidden;
		.progress {
			float: left;
			width: 90%;
		}
		.all {
			float: left;
			padding-left: 5px;
		}
	}
}
</style>
