<template>
	<view class="collectLog">
		<scroll-view scroll-y class="list" @scrolltolower="loadMore">
			<view class="list-item" v-for="item in list" @click="toDetail(item)">
				<view class="list-title">{{ item.name }}</view>
				<view class="money">{{item.salaryMin}}~{{item.salaryMax}}</view>
				<view class="f_s">
					<view class="tag">{{item.recruitType}}</view>
					<view class="tag">{{ item.qualification }}</view>
					<view class="tag">{{ item.experience }}</view>
				</view>
				<view class="company f_s">
					<u--image
					    :src="item.org.logo"
					    width="80rpx"
					    height="80rpx"
						radius="4"
					/>
					<text style="padding: 0 10px;font-weight: 300;font-size: 28rpx;">{{ item.orgName }}</text>
				</view>
				<view class="f_b occupational">
					<view>{{item.industryName}}</view>
					<view>{{item.org.city != '市辖区' ? item.org.city : item.org.province}}</view>
				</view>
			</view>
			<u-loadmore 
				v-if="list.length"
				:status="status" 
				:loading-text="loadingText" 
				:loadmore-text="loadmoreText" 
				:nomore-text="nomoreText" 
			/>
			<u-loadmore
				v-else
				status="nomore" 
				nomore-text="没有收藏岗位" 
			/>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pageNum: 1,
				pageSize: 10,
				list: [],
				status: 'nomore',
				loadingText: '努力加载中',
				loadmoreText: '轻轻上拉',
				nomoreText: '没有了',
			}
		},
		onLoad() {
			this.load()
		},
		onPullDownRefresh() {
			this.pageNum = 1
		    this.load('sx')
		},
		onShow() {

		},
		methods: {
			loadMore() {
				if (this.status == 'loadmore') {
					this.pageNum = this.pageNum + 1
					this.load()
				}
			},
			load(type) {
				this.$http.get('/collect/l', {
					pageNum: this.pageNum,
					pageSize: this.pageSize,
				}).then(res => {
					this.list = this.pageNum == 1 ? res.data.list : [...this.list,...res.data.list],
					this.status = this.list.length >= res.data.total ? 'nomore' : 'loadmore'
					if (type == 'sx') {
						uni.stopPullDownRefresh();
						setTimeout(() => {
							uni.showToast({
								title: '刷新成功',
								icon: 'none'
							})
						},500)
					}
				})
			},
			toDetail(el = {}) {
				uni.navigateTo({
					url: `/pages/home/jobDetails?id=${el.id}&source=jyzp`
				})
			}
		}
	}
</script>

<style lang="scss">
.collectLog{
	height: 100vh;
	overflow: hidden;
	.list{
		height: calc(100%);
		overflow: auto;
		padding: 30rpx;
		box-sizing: border-box;
		.list-item{
			background-color: #fff;
			border-radius: 20rpx;
			padding: 30rpx;
			.list-title{
				font-weight: bold;
				font-size: 32rpx;
				margin-bottom: 10rpx;
				
			}
			.money{
				color: #647BEB;
				text-align: right;
				margin-bottom: 10rpx;
				font-weight: bold;
			}
			.company{
				margin: 20rpx 0;
				color: #666;
				font-size: 30rpx;
			}
			.occupational{
				color: #666;
				font-size: 26rpx;
				font-weight: 300;
			}
		}
		.list-item + .list-item{
			margin-top: 30rpx;
		}
	}
}
</style>
