<template>
	<view>
		<u-navbar back-text="共享用工" back-icon-size="28" back-icon-color="#ffffff" :background="{backgroundColor: '#2795FD',}"
			:back-text-style="{color: '#ffffff'}"></u-navbar>

		<view class="tabs">
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
		</view>
		<view class="info-card" v-for="(item,i) in list[current].list" :key="i"
			@click="gotoUrl('pages/packages/shareEmployment/articleDetail?id='+item.id)">
			<!-- 卡片信息 -->
			<view class="detail">
				{{item.title}}
			</view>
			<view class="tag">
				<view class="item1" v-if="item.type == '1'">
					急需用工
				</view>
				<view class="item2" v-if="item.type == '2'">
					资源共享
				</view>
				<view class="date-item">
					{{item.createTime.slice(0,10)}}
				</view>
			</view>



		</view>

		<u-divider v-if="formList[current].recordsTotal==list[current].list.length"
			:isnone="formList[current].recordsTotal==0" nonetext="没有找到相关内容" border-color="#CFD2D5">已经到底了</u-divider>

		<!-- 底部按钮 -->



	</view>
</template>

<script>
	import * as API from '@/apis/pagejs/packages.js'
	export default {
		data() {
			return {
				formList: [{

						pageIndex: 1,
						pageSize: 20,
						recordsTotal: 1,
						type: "1",

					},
					{

						pageIndex: 1,
						pageSize: 20,
						recordsTotal: 1,
						type: "2",

					}
				],
				list: [{
						name: '急需用工',

						list: []
					},
					{
						name: '资源共享',

						list: []
					}
				],
				current: 0

			}
		},
		onReachBottom() {
			var obj = this.list[this.current]
			var objf = this.formList[this.current]
			if (obj.list.length < objf.recordsTotal) {
				this.myLoadmore();
			}
		},
		onReady() {
			this.getList()
		},
		methods: {
			getList() {

				uni.showLoading({
					title: "加载中",
					mask: true,
				})
				var list = this.list[this.current].list

				var listForm = this.formList[this.current]


				API.shareWorksList(listForm).then((res) => {

					if (listForm.pageIndex == 1) {
						list = res.data.data;
					} else {
						list = [
							...list,
							...res.data.data
						];
					}

					this.list[this.current].list = list

					this.formList[this.current].recordsTotal = res.data.recordsTotal;
					uni.hideLoading();
				}).catch(error => {
					uni.showToast({icon: 'none',
						title: error,
						icon: "none"
					})
				})

			},
			myLoadmore() {
				this.formList[this.current].pageIndex += 1;
				this.getList();
			},
			change(index) {
				this.current = index;
				var list = this.list[this.current].list
				if (list.length == 0) {
					this.getList();
				}
			}
		}
	}
</script>

<style>
	page {
		background: #F0F0F2;
		padding-bottom: 100px;
	}
</style>
<style scoped lang="scss">
	.info-card {
		margin: 24rpx 32rpx 0;
		padding: 24rpx;
		background-color: #fff;
		border-radius: 24rpx;

		// 卡片信息
		.detail {
			color: rgba(16, 16, 16, 1);
			line-height: 40rpx;

		}

		.tag {
			display: flex;
			justify-content: space-between;
			margin-top: 16rpx;
			margin-bottom: 24rpx;

			.item1 {
				color: rgba(39, 149, 253, 1);
				font-size: 24rpx;
			}

			.item2 {
				color: rgba(0, 185, 98, 1);
				font-size: 24rpx;
			}
		}

		// 审核
		.check {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-top: 32rpx;

			.state {
				color: rgba(51, 51, 51, 1);
				font-weight: 600;
			}

			.handle {
				display: flex;
				align-items: center;

				.unamend {
					width: 120rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					font-family: Microsoft Yahei;
					border: 1px solid rgba(231, 232, 234, 1);
					border-radius: 50px;
					opacity: 0.4;
				}

				.amend {
					width: 120rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					font-family: Microsoft Yahei;
					border: 1px solid rgba(231, 232, 234, 1);
					border-radius: 50px;

				}

				.delete {
					width: 120rpx;
					height: 56rpx;
					line-height: 56rpx;
					text-align: center;
					font-family: Microsoft Yahei;
					border: 1px solid rgba(231, 232, 234, 1);
					border-radius: 50px;
					margin-left: 24rpx;
					color: #E60012;
				}
			}
		}
	}

	// 底部按钮


	.btn {
		position: fixed;
		bottom: 32rpx;
		left: 0;
		right: 0;
		background-color: #F0F0F2;
		padding: 0 32rpx;
		border-radius: 50px;
		background-color: rgba(34, 149, 255, 1);
		color: rgba(241, 241, 241, 1);
		font-size: 36rpx;
		margin: 0 32rpx;
		box-shadow: 0px 0px 6px 0px rgba(0, 0, 0, 0.03);
	}
</style>