<template>
	<view class="pageStyleInfo">
		<view class="subList">
			<u-subsection
				:list="list"
				:current="current"
				@change="sectionChange"
				height="54"
				button-color="rgba(47,67,121,0.6)"
				bg-color="#F8F9FF"
				active-color="#FFFFFF"
				inactive-color="#636A75"
				:bold="false"
			></u-subsection>
		</view>
		<view class="liBox" v-if="current === 0">
			<view class="lisboxs" v-for="(item, index) in pageInfoList1" :key="index" @click="jumpPages(item)">
				<view class="headList">
					<view class="headText">{{ item.job }}</view>
					<view class="headText">
						{{ item.incomeStart }}-{{ item.incomeEnd }}/{{
							item.incomeType === 1 ? '月' : item.incomeType === 2 ? '年' : '未知'
						}}
					</view>
				</view>
				<view class="contexts">{{ item.companyName }}</view>
				<view class="headList" style="margin-bottom: 0rpx;">
					<view class="fotText">{{ $method.timestampToTime(item.createTime, false) }} 投递</view>
					<view class="fotText">{{ item.companyCity }}·{{ item.companyDistrict }}</view>
				</view>
			</view>
		</view>
		<view class="liBox" v-if="current === 1">
			<view class="lisboxs" v-for="(item, index) in pageInfoList2" :key="index">
				<view class="headList">
					<view class="headText">{{ item.job }} ></view>
					<view class="rightTs">{{ $method.timestampToTime(item.createTime, false) }}</view>
				</view>
				<view class="contexts2">
					<view class="leftTes">
						<view>公</view>
						<view>司</view>
					</view>
					：
					<view class="infoRights">{{ item.companyName }}</view>
				</view>
				<view class="contexts2">
					<view class="leftTes">
						<view>面</view>
						<view>试</view>
						<view>时</view>
						<view>间</view>
					</view>
					：
					<view class="infoRights">{{ $method.timestampToTime(item.resumeTime, false) }}</view>
				</view>
				<view class="contexts2">
					<view class="leftTes">
						<view>面</view>
						<view>试</view>
						<view>地</view>
						<view>点</view>
					</view>
					：
					<view class="infoRights">{{ item.companyProvince }}{{ item.companyCity }}{{ item.companyDistrict }}{{ item.companyAddress }}</view>
				</view>
				<view class="contexts2">
					<view class="leftTes">
						<view>联</view>
						<view>系</view>
						<view>电</view>
						<view>话</view>
					</view>
					：
					<view class="infoRights">{{ item.linkTel }}</view>
				</view>
				<view class="contexts2">
					<view class="leftTes">
						<view>联</view>
						<view>系</view>
						<view>人</view>
					</view>
					：
					<view class="infoRights">{{ item.linkMan }}</view>
				</view>
				<view class="cent">
					<view class="btnSty1" v-if="item.status === 1" @click="rejects(item)">拒绝</view>
					<view class="btnSty2" v-if="item.status === 1" @click="jeshou(item)">接受邀请</view>
					<view class="btnSty2" v-if="item.status === 2" style="opacity: 0.3;">已接受邀请</view>
					<view class="btnSty2" v-if="item.status === 3" style="opacity: 0.3;">已谢绝邀请</view>
					<view class="btnSty2" v-if="item.status === 4" style="opacity: 0.3;">已通过初试</view>
					<view class="btnSty2" v-if="item.status === 5" style="opacity: 0.3;">初试不通过</view>
					<view class="btnSty2" v-if="item.status === 6" style="opacity: 0.3;">已通过复试</view>
					<view class="btnSty2" v-if="item.status === 7" style="opacity: 0.3;">复试不通过</view>
					<view class="btnSty2" v-if="item.status === 8" style="opacity: 0.3;">已发offer</view>
					<view class="btnSty2" v-if="item.status === 9" style="opacity: 0.3;">爽约</view>
					<view class="btnSty2" v-if="item.status === 10" style="opacity: 0.3;">淘汰</view>
					<view class="btnSty2" v-if="item.status === 11" style="opacity: 0.3;">放弃</view>
					<view class="btnSty2" v-if="item.status === 12" style="opacity: 0.3;">转正</view>
				</view>
			</view>
		</view>
		<u-popup v-model="showPopp" mode="center" border-radius="14">
			<view style="padding: 20rpx;width: 80vw;">
					<view style="text-align: center;margin: 20rpx 0rpx; font-size: 30rpx;font-weight: bold;">拒绝理由</view>
					<u-input v-model="refuse" focus type="textarea" border :height="150" auto-height placeholder="请输入拒绝理由"/>
					<view style="margin-top: 30rpx; display: flex;align-items: center;justify-content: space-around;">
						<u-button size="medium" type="warning" style="width: 200rpx;font-size: 24rpx;" @click="clearModels">取消</u-button>
						<u-button size="medium" type="info" style="width: 200rpx;font-size: 24rpx;" @click="quxExit">确定</u-button>
					</view>
			</view>
				</u-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			showPopp: false,
			refuse: '',
			indexIds: null,
			pageInfoList1: [],
			pageInfoList2: [],
			list: [
				{
					name: '全部投递'
				},
				{
					name: '邀面试'
				}
			],
			current: 0
		};
	},
	mounted() {
		this.init();
	},
	methods: {
		jumpPages(item){
			this.$navTo.togo('/pages2/recruitment/detailsInfo', {
				id:item.needsId,
				companyId: item.companyId
			});
		},
		init() {
			this.$api.systeminterviewlistAll().then(res => {
				if (res.data.code === 200) {
					this.pageInfoList1 = res.data.rows;
				}
			});
		},
		sectionChange(index) {
			if(index === 0){
				this.$api.systeminterviewlistAll().then(res => {
					if (res.data.code === 200) {
						this.pageInfoList1 = res.data.rows;
					}
				});
			}
			if(index === 1){
				this.$api.systeminterviewlist().then(res => {
					if (res.data.code === 200) {
						this.pageInfoList2 = res.data.rows;
					}
				});
			}
			this.current = index;
		},
		jeshou(options){
			this.$api.editsysteminterview({
				interviewId: options.interviewId,
				status: 2
			}).then(res => {
				if(res.data.code === 200){
					uni.showToast({
						title: '已接受邀请',
						icon: 'success'
					})
					this.init();
				}else{
					uni.showToast({
						title: '接受邀请失败',
						icon: 'error'
					})
				}
			})
		},
		rejects(options){
			this.refuse = ''
			this.indexIds = options.interviewId
			this.showPopp = true
		},
		quxExit(){
			if(!this.refuse || this.refuse === ''){
				uni.showToast({
					title: '请输入拒绝理由',
				})
				return
			}
			var data = {
				interviewId: this.indexIds,
				status: 3,
				refuse: this.refuse
			}
			this.$api.editsysteminterview(data).then(res => {
				if(res.data.code === 200){
					uni.showToast({
						title: '已谢绝',
						icon: 'success'
					})
					this.init();
					this.showPopp = false
				}else{
					uni.showToast({
						title: '接口报错',
						icon: 'error'
					})
				}
			})
		},
		clearModels(){
			this.showPopp = false
		},
	}
};
</script>

<style scoped>
.pageStyleInfo {
	padding: 32rpx 35rpx;
}
.subList {
	width: 536rpx;
	height: 56rpx;
	margin: 0rpx auto 24rpx;
}
.lisboxs {
	margin-bottom: 24rpx;
	border-radius: 32rpx;
	background: #ffffff;
	box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.05);
	padding: 31rpx 31rpx 28rpx 38rpx;
}
.headList {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 24rpx;
}
.headText {
	font-size: 30rpx;
	color: #2a4174;
	font-weight: bold;
}
.contexts {
	margin-bottom: 33rpx;
	font-size: 30rpx;
	font-weight: 500;
	color: #636a75;
}
.fotText {
	color: #636a75;
	font-size: 24rpx;
	font-weight: 500;
}
.rightTs {
	font-size: 20rpx;
	font-weight: 500;
	color: #babfc6;
}
.contexts2 {
	display: flex;
	align-items: center;
	margin-bottom: 17rpx;
}
.leftTes {
	display: flex;
	align-items: center;
	justify-content: space-between;
	color: #636a75;
	width: 110rpx;
	font-size: 26rpx;
	font-weight: bold;
	text-align: justify;
}
.infoRights {
	color: #a8acb3;
	font-size: 26rpx;
	font-weight: bold;
}
.cent {
	display: flex;
	align-items: center;
	justify-content: center;
}
.btnSty1 {
	width: 200rpx;
	border: 1rpx solid #32467b;
	height: 65rpx;
	line-height: 65rpx;
	text-align: center;
	border-radius: 32rpx;
	background-color: #fff;
	color: #32467b;
	font-weight: bold;
	font-size: 24rpx;
	margin-right: 40rpx;
}
.btnSty2 {
	width: 200rpx;
	color: #fff;
	font-weight: bold;
	font-size: 24rpx;
	height: 65rpx;
	line-height: 65rpx;
	text-align: center;
	border-radius: 32rpx;
	background: #32467b;
	box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(47, 67, 121, 0.15);
}
</style>
