<template>
	<view class="main pt0">
		<view class="item" v-for="(item, index) in list" :key="index" @click="go('/pages/user/resume/deliver/receive/list?id=' + item.id)">
			<image :src="ip + item.avatar" mode="widthFix" class="avatar"></image>
			<view class="con">
				<view class="name">{{ item.name }}</view>
				<text class="desc">{{ item.sex }} · {{ item.age }}岁 · {{ item.experience }}</text>
			</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 {
			ip: this.http.ip,
			list: [],
			param: { pageNum: 1, pageSize: 10, isRead: 0 },
			loadMore: true
		};
	},
	onLoad(e) {
		this.param.positionId = e.id;
		this.getData();
	},
	methods: {
		getData() {
			this.http.request({
				url: '/app/deliver/receive/list',
				data: this.param,
				loading: 'false',
				success: (res) => {
					this.loadMore = res.data.pages > this.param.pageNum ? true : false;
					this.list.push(...res.data.rows);
				}
			});
		},
		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;
	.avatar {
		float: left;
		width: 50px;
		height: 50px;
		border-radius: 50%;
	}
	.con {
		float: left;
		padding-left: 10px;
		.name {
			font-weight: bold;
			padding-bottom: 3px;
		}
		.desc {
			color: $font-c;
			font-size: 14px;
		}
	}
}
</style>
