<template>
	<view class="my-order">
		<view class="my-order-header">
			<view class="header-search u-flex">
				<u-icon name="search" size="36" color="#444444"></u-icon>
				<input type="text" class="input" placeholder="请输入关键词搜索" v-model="keyword1" confirm-type="search"
					@confirm="tosearch(1)">
			</view>
			<scroll-view scroll-x="true" class="order-tabs">
				<view class="u-flex-col tabs-item u-col-center u-row-center" :class="{'tabs-item1':current == index}"
					@click="change(index)" v-for="(item,index) in tabslist" :key="index">
					<text>{{item.name}}</text>
					<text></text>
				</view>
			</scroll-view>
		</view>
		<!-- <view class="order-item" v-for="(item,index) in list" :key="index" @click="toinfo(item)">
			<view class="item-header u-flex u-row-between">
				<text>订单编号：{{item.order_no}}</text>
				<text v-if="item.stage == 'recommend'">推荐阶段</text>
				<text v-if="item.stage == 'interview'">面试阶段</text>
				<text v-if="item.stage == 'offer'">offer阶段</text>
				<text v-if="item.stage == 'entry'">入职阶段</text>
				<text v-if="item.stage == 'over_protected'">过保阶段</text>
				<text v-if="item.stage == 'failed'">已淘汰</text>
			</view>
			<view class="jieshao-user jieshao-user1 u-flex u-row-between">
				<view class="left u-flex-col">
					<text class="user-name">{{item.resume.name}}</text>
					<view class="user-tips1">
						{{item.resume.province}}·{{item.resume.city}}｜{{item.resume.experience}}年｜{{item.resume.education_name}}
						| {{item.resume.salary}}K/{{item.resume.salary_type == 'year' ? '年' : '月'}}
					</view>
				</view>
			</view>
			<view class="u-flex item-other" v-if="item.resume.job_experience[0]">
				<image src="../static/images/dizhi.png" mode=""></image>
				<text>{{item.resume.job_experience[0].company_name}}·{{item.resume.job_experience[0].job_name}}</text>
			</view>
			<view class="jieshao-user jieshao-user2 u-flex u-row-between" style="margin-top: 30rpx;">
				<view class="left u-flex-col">
					<text class="user-name">{{item.job.job_name}}</text>
					<view class="user-tips1">
						{{item.job.work_province}}·{{item.job.work_city}}｜{{item.job.experience_name}}｜{{item.job.education_name}}
						| {{item.job.salary_min}}-{{item.job.salary_max}}K
					</view>
				</view>
			</view>
			<view class="u-flex item-other">
				<image src="static/address.png" mode=""></image>
				<text>{{item.company.name}}</text>
			</view>
			<view class="u-flex item-other">
				<image src="static/dingwei.png" mode=""></image>
				<text>{{item.company.city}}</text>
			</view>
		</view> -->
		<view class="" style="padding:0 24rpx ;">
			<view class="content" @click="todetails(item.id)" v-for="(item,index) in list" :key="item.manager_id">
				<view class="u-flex u-row-between">
					<view class="u-flex">
						<view class="font">{{item.job.job_name}}</view>
					</view>
					<view class="money">{{item.job.salary_min}}-{{item.job.salary_max}}K
						<text v-if="item.job.salary_structure">·{{item.job.salary_structure}}</text>
					</view>
				</view>
				<view class="u-flex" style="margin: 16rpx 0 14rpx 0;">
					<text class="introduce">{{item.company.name}}</text>
					<text class="introduce">{{item.company.stage_name}}</text>
					<text class="introduce">{{item.company.scale_name}}</text>
				</view>
				<view class="u-flex" style="margin-bottom: 24rpx;">

					<view class="tabs">
						{{item.company.province}}{{item.company.city}}
					</view>
					<view class="tabs">
						{{item.job.education_name}}
					</view>
					<view class="tabs">
						{{item.job.experience_name}}
					</view>
				</view>
				<view class="u-flex u-row-between u-col-center">
					<view class=" u-flex u-col-center">
						<image :src="item.recommend_info.avatar" mode=""
							style="width: 50rpx;height: 50rpx;border-radius: 50%;">
						</image>
						<view class="" style="margin-left: 16rpx;">
							<text>{{item.recommend_info.username}}</text>·
							<text>{{item.recommend_info.type}}</text>
						</view>
					</view>
				</view>
				<view class="bottom u-flex  u-row-between">
					<text class="tou">{{item.updatetime}}{{item.updatetime?"投递":""}}</text>
					<text class="success">投递成功</text>
				</view>
			</view>
		</view>

		<view style="height: 70vh;justify-content: center;" class="u-flex" v-if="list.length == 0">
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import {
		orderlist
	} from "@/units/inquire.js"
	export default {
		data() {
			return {
				current: 0,
				tabslist: [{
					name: '投递阶段',
					id: 'recommend'
				}, {
					name: '面试阶段',
					id: 'interview'
				}, {
					name: '入职阶段',
					id: 'entry'
				}, {
					name: '过保阶段',
					id: 'over_protected'
				}, {
					name: '不合适',
					id: 'failed'
				}],
				page: 1,
				list: [],
				total: 0,
				keyword: '',
				keyword1: '',
				list1: [],
			}
		},
		onLoad(option) {
			this.current = option.current || 0
		},
		onShow() {
			this.page = 1
			this.list = []
			this.getlist()
			console.log(this.list);
		},
		onReachBottom() {
			if (this.total != this.list.length) {
				this.page++
				this.getlist()
			}
		},
		methods: {
			tosearch(type) {
				if (type == 1) {
					this.keyword = this.keyword1
				}
				this.page = 1
				this.list = []
				this.getlist()
			},
			getlist() {
				orderlist({
					stage: this.tabslist[this.current].id,
					page: this.page,
					name: this.keyword
				}).then(res => {
					if (res.code == 1) {
						if (this.page == 1) {
							this.list = res.data.data
							console.log(this.list);
						} else {
							this.list = this.list.concat(res.data.data)
						}
					}
					this.total = res.data.total
				})
			},
			change(index) {
				this.current = index
				this.tosearch()
			},
			todetails(id) {
				uni.navigateTo({
					url: "/pagesD/order-info?id=" + id
				})
			}
		}
	}
</script>

<style lang="scss">
	.my-order {
		.content {
			padding: 24rpx 20rpx;
			margin-top: 20rpx;
			background-color: #fff;
			border-radius: 16rpx;

			.bottom {
				border-top: 2rpx solid #F0F0F0;
				margin-top: 32rpx;
				padding-top: 20rpx;

				.tou {
					font-size: 20rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #666666;
				}

				.success {
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #F7B500;
				}
			}


			.font {
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #222222;
				line-height: 44rpx;
				max-width: 326rpx;
				overflow: hidden; //超出隐藏
				white-space: nowrap; //不换行，同一行展示
				text-overflow: ellipsis; //设置超出部分以省略号展示
			}

			.back {
				width: 58rpx;
				height: 32rpx;
				background: #FF5335;
				border-radius: 6rpx;
				font-size: 22rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
				line-height: 32rpx;
				text-align: center;
				margin-left: 16rpx;
			}

			.money {
				font-size: 32rpx;
				font-family: JDZhengHT-Regular, JDZhengHT;
				font-weight: 400;
				color: #0C66C2;
			}

			.introduce {
				height: 40rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #555555;
				line-height: 40rpx;
				margin-right: 16rpx;
			}

			.tabs {
				background: #F3F3F3;
				border-radius: 4rpx;
				padding: 6rpx 14rpx;
				margin-right: 16rpx;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #5F5F5F;
				height: 34rpx;
				line-height: 34rpx;
			}
		}


		.order-item {
			width: 702rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 20rpx auto;
			padding: 0 20rpx 8rpx 20rpx;


			.item-header {
				height: 84rpx;
				border-bottom: 2rpx solid #F3F3F3;
				margin-bottom: 22rpx;

				text:first-child {
					font-size: 22rpx;
					font-family: SFPro-Regular, SFPro;
					font-weight: 400;
					color: #555555;
				}

				text:nth-child(2) {
					line-height: 40rpx;
					background: #FEF7E5;
					border-radius: 6rpx;
					padding: 0 12rpx;
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #F7B500;
				}
			}

			.item-other {
				margin-bottom: 16rpx;
				padding-left: 32rpx;

				image {
					width: 28rpx;
					height: 28rpx;
					margin-right: 12rpx;
				}

				text {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #222222;
				}
			}

			.jieshao-user {
				padding-left: 32rpx;
				position: relative;
				margin-bottom: 20rpx;

				.left {
					.user-name {
						font-size: 32rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
						margin-bottom: 16rpx;
					}

					.user-tips1 {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #666666;
					}
				}

				.right {
					width: 96rpx;
					height: 96rpx;
					position: relative;

					.img1 {
						width: 96rpx;
						height: 96rpx;
						border-radius: 100rpx;
					}

					.sex {
						position: absolute;
						bottom: 0;
						right: 4rpx;
						width: 24rpx;
						height: 24rpx;
					}
				}
			}

			.jieshao-user1::after {
				position: absolute;
				content: " ";
				width: 12rpx;
				height: 12rpx;
				background: #131415;
				border-radius: 100rpx;
				top: 16rpx;
				left: 0;
			}

			.jieshao-user2::after {
				position: absolute;
				content: " ";
				width: 12rpx;
				height: 12rpx;
				background: #0C66C2;
				border-radius: 100rpx;
				top: 16rpx;
				left: 0;
			}
		}

		.my-order-header {
			padding: 20rpx 24rpx 0 24rpx;
			position: sticky;
			top: 0;
			left: 0;
			z-index: 99;
			background-color: #fff;

			.order-tabs {
				height: 96rpx;
				width: 100%;
				white-space: nowrap;

				.tabs-item {
					display: inline-flex;
					height: 96rpx;
					margin: 0 18rpx;

					text:first-child {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #444444;
					}

					text:last-child {
						width: 100%;
						height: 8rpx;

						border-radius: 4rpx;
						margin-top: -12rpx;
						position: relative;
						z-index: -1;
					}
				}

				.tabs-item1 {
					text:first-child {
						font-size: 26rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #141414;
					}

					text:last-child {
						background: linear-gradient(270deg, #0C66C2 0%, #FFFFFF 100%);
					}
				}
			}

			.header-search {
				height: 68rpx;
				background: #F3F3F3;
				border-radius: 38rpx;
				padding: 0 36rpx;

				.input {
					flex: 1;
					font-size: 28rpx;
					margin-left: 24rpx;
				}
			}
		}
	}

	page {
		background-color: #F3F3F3;
	}
</style>