<template>
	<view class="body">
		<!-- <view v-if="browsingResultList.length > 0" class="search-result">
			<view v-for="(item, index) in browsingResultList" class="search-item" v-if="item.workname" :key="index" @click="">
				<image src="../../static/img/search.svg" style="width: 32rpx;height: 32rpx;margin-right: 10rpx;" mode=""></image>
				<view  style="flex:1">{{ item.workname }}</view>
				<view class="type" v-if="item.type == 0">任务</view>
				<view class="type" v-else-if="item.type == 1">岗位</view>
				<view class="type" v-else-if="item.type == 2">政策</view>
			</view>
		</view> -->
		<block v-for="(page, pIndex) in data" :key="pIndex">
			<block v-for="(item, index) in page" :key="item.id">
				<view class="search-item" @click="toDetail(item)">
					<!-- <company-list :companyitem="item" :noApply="false"></company-list> -->
					<image src="../../static/img/eyeopen.svg" style="width: 32rpx;height: 32rpx;margin-right: 10rpx;" mode=""></image>
					<view  style="flex:1;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">{{ item.workname }}</view>
					<view class="type" v-if="item.type == 0">零工岗位</view>
					<view class="type" v-else-if="item.type == 1">全职岗位</view>
					<view class="type" v-else-if="item.type == 2">政策</view>
					<view class="baddd"></view>
				</view>
			</block>
		</block>
		<view class="nothing" v-if="data.length === 0">
			<image src="/static/img/pic_notask.svg" mode=""></image>
			<view class="nothingContnt">
				暂无浏览信息
			</view>
		</view>
	</view>
</template>

<script>
	import vTabs from '@/components/v-tabs/v-tabs.vue';
	import {
		myBrowing
	} from '@/api/mission.js';

	export default {
		components: {
			vTabs,
		},
		data() {
			return {
				data: [],
				activeTab: 0,
				current: 1,
				size: 10,
				total: 0,
				browsingResultList: []
			}
		},
		onLoad: function() {
			this.init()
		},
		/*页面滚动到底部 换页*/
		onReachBottom: function() {
			if (this.current <= Math.ceil(this.total / this.size)) {
				this.getData();
			} else {
				uni.showToast({
					icon: "none",
					title: '已经是最后一页',
				})
			}
		},
		/*下拉刷新*/
		onPullDownRefresh:function(){
			this.init()
		},
		methods: {
			init(){
				this.current = 1
				this.data = []
				this.getData()
			},
			getData() {
				var status = Number(this.activeTab) + 1
				myBrowing(this.current, this.size, status).then(res => {
					uni.stopPullDownRefresh();
					console.log(res)
					if (this.current === 1) {
						this.data = [];
					}
					this.current += 1;
					this.total = res.data.data.total;
					if (res.data.data && res.data.data.records.length) {
						this.data.push(res.data.data.records);
					}
				})
			},
			gomap: function() {
				uni.navigateTo({
					url: '../mapSeach/mapSeach'
				})
			},
			changeTab: function(e) {
				this.activeTab = e;
				this.init()
			},
			toDetail(item) {
				const no = item.id
				// 判断是岗位还是任务 0：任务，1：岗位，2：政策
				if(item.type == 0) {
					uni.navigateTo({
						url: `/pages/projectInfo/projectInfo?missionNo=${encodeURIComponent(no)}&isCan=1`
					})
				} else if(item.type == 1) {
					uni.navigateTo({
						url: `/pages/projectInfo/workInfo?workId=${encodeURIComponent(no)}&isCan=1`
					})
				} else if(item.type == 2) {
					uni.navigateTo({
						url:`/pages/user/policyContent?id=${no}`
					})
				}
				
			},
		}
	}
</script>

<style scoped>
	page {
		height: 100%;
	}

	.tab {
		height: 46px;
	}

	.body {
		height: 100%;
	}
	
	.probody image {
		width: 88rpx;
		height: 88rpx;
		position: absolute;
		right: 0;
		top: 0;
	}
	
	.probody {
		width: 100%;
		position: relative;
	}
	
	.baddd {
		background: #f6f6f6;
		height: 20rpx;
	}
	
	.nothing {
		height: 100%;
		padding-top: 50%;
		box-sizing: border-box;
	}
	
	.nothing image {
		width: 400rpx;
		height: 200rpx;
		display: block;
		margin: 0 auto;
	}
	
	.nothingContnt {
		font-family: PingFangSC-Regular;
		font-size: 28rpx;
		color: #666;
		margin-top: 30rpx;
		text-align: center;
	}
	
	.title {
		font-size: 26rpx;
		font-weight: bold;
		border-bottom: 1rpx solid #ddd;
		height: 60rpx;
		line-height: 60rpx;
	}
	.search-item {
		display: flex;
		align-items: center;
		font-size: 26rpx;
		border-bottom: 1rpx solid #ddd;
		height: 80rpx;
		line-height: 80rpx;
		padding: 10rpx 30rpx;
	}
	.search-item .type {
		font-size: 20rpx;
		color: #707070;
		background-color: #dddddd;
		border-radius: 15rpx;
		height: 30rpx;
		line-height: 30rpx;
		padding: 0 20rpx;
	}
</style>
