<!-- 我的面试 -->
<template>
	<view class="interview">
		<z-paging
			ref="paging"
			v-model="interviewList"
			@query="queryList"
		>
		<view class="interview-list">
			<view class="interview-list-item" v-for="(item, index) in interviewList" :key="index">
				<view class="interview-list-item-status">{{ getDictLabel(item.status, 'deliveryStatusList') }}</view>
				<view class="interview-list-item-time">{{ item.interviewTime || '2021-10-29 10:00' }}</view>
				<view class="interview-list-item-address">{{ item.interviewAddress }}</view>
				<view class="interview-list-item-company">
					<view class="left">
						<view>
							<image :src="item.companyLogoUrl"/>
						</view>
						<view class="left-info">
							<view>{{ item.postName }}</view>
							<view>{{ `${item.workPlace} | 经验${item.workYear}年 | ${item.educationBg}` }}</view>
							<view>{{ item.companyName }}</view>
						</view>
					</view>
					<view class="right">
						<view>{{ `${item.lowestSalary}k ~ ${item.highestSalary}k` }}</view>
						<view v-if="item.updateTime">{{ item.updateTime.split(' ')[0] }}</view>
						<view v-else>{{ item.createTime.split(' ')[0] }}</view>
					</view>
				</view>
				<view class="interview-list-item-btn">
					<view class="single-btn not-arrive" v-if="Number(item.status) === 20 && new Date('2021-10-29 10:00').valueOf() > new Date().valueOf()">未到面试时间</view>
					<view class="single-btn arrive" v-else-if="Number(item.status) === 20 && new Date('2021-10-29 10:00').valueOf() <= new Date().valueOf()">发起视频面试</view>
					<view class="double-btn" v-else-if="Number(item.status) === 50">
						<view>接受</view>
						<view>拒绝</view>
					</view>
				</view>
			</view>
		</view>
		</z-paging>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 面试列表
				interviewList: [],
				// 面试状态
				deliveryStatusList: []
			}
		},
		onLoad() {
			this.getDict('delivery_status')
		},
		methods: {
			/**
			 * 获取我的面试列表
			 * @param { Number } pageNum 
			 * @param { Number } pageSize
			 */
			getInterviewList(pageNum, pageSize) {
				this.$u.api.interview.getInterviewList({ pageNum, pageSize }).then(res => {
					if (res.code === 200) {
						this.$refs.paging.complete(res.rows)
					} else {
						this.$refs.paging.complete([])
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error'
						})
					}
				}).catch(err => {
					this.$refs.uToast.show({
						title: '系统异常!',
						type: 'error'
					})
				})
			},
			/**
			 * 组件下拉加载触发
			 * @param { Number } pageNo
			 * @param { Number } pageSize
			 */
			queryList(pageNo, pageSize) {
				this.getInterviewList(pageNo, pageSize)
			},
			/**
			 * 获取数据字典
			 * @param { String } key
			 */
			getDict(key) {
				this.$u.api.getDictdataUrl({ key }).then(res => {
					if (res.code === 200) {
						switch(key) {
							case 'delivery_status':
								this.deliveryStatusList = res.data;
								break;
						}
					}
				})
			},
			/**
			 * 获取字典名称
			 * @param { String } val
			 * @param { String } key
			 */
			getDictLabel(val, key) {
				let label;
				this[key].forEach(item => {
					if (Number(item.text) === Number(val)) {
						label = item.label
					}
				})
				return label;
			}
		}
	}
</script>

<style lang="scss" scoped>
@import './myInterview.scss';
</style>
