<!-- 我的投递 -->
<template>
	<view class="delivery">
		<u-navbar back-text="" title="" back-icon-color="#FFFFFF" :background="{ background: '#3D5D4C' }" :border-bottom="false"></u-navbar>
		<z-paging
			 ref="paging"
			 v-model="deliveryList"
			 @query="queryList"
		>
			<view class="delivery-list">
				<view
					class="delivery-list-item"
					v-for="(item, index) in deliveryList"
					:key="index"
					@click="jumpPage('/pages/jobDetails/jobDetails', { id: item.id, isSubmit: true })"
					:class="{ 'off': item.postStatus == 0 }"
				>
					<view class="delivery-list-item-left">
						<view class="delivery-list-item-left-image">
							<image
								:src="item.companyLogoUrl"
							/>
						</view>
						<view class="delivery-list-item-left-info">
							<view>{{ item.postName }}</view>
							<view>{{ `${item.provinceName || ''} | 经验${item.workYear ? item.workYear + '年' : '不限'} | ${getEducationBg(item.educationBg)}` }}</view>
							<view>{{ item.companyName }}</view>
						</view>
					</view>
					<view class="delivery-list-item-right">
						<view align="right" class="off-the-shelf" v-if="item.postStatus == 0">职位已下架</view>
						<view align="right" class="salary" v-else>{{ `${item.lowestSalary || ''}k ~ ${item.highestSalary || ''}k` }}</view>
						<view>{{ item.createTime.split(' ')[0] }}</view>
					</view>
				</view>
			</view>
		</z-paging>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				deliveryList: [],
				degrEducList: []
			}
		},
		onShow() {
			this.getDictEduc()
		},
		methods: {
			/**
			 * 获取教育等级名称
			 * @param {Object} value
			 */
			getEducationBg(value) {
				let name;
				this.degrEducList.forEach(item => {
					if (item.text == value) {
						name = item.label
					}
				})
				return name;
			},
			/**
			 * 获取字典
			 */
			getDictEduc() {
				this.$u.api.getDictdataUrl({
					key: 'degr_educ'
				}).then(res => {
					if (res.code === 200) {
						this.degrEducList = res.data;
					}
				})
			},
			getList(pageNum, pageSize) {
				this.$u.api.delivery.getDeliveryList({
					pageNum,
					pageSize
				}).then(res => {
					if (res.code === 200) {
						this.$refs.paging.complete(res.rows)
					} else {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'error'
						})
						this.$refs.paging.complete([])
					}
				}).catch(() => {
					this.$refs.uToast.show({
						title: '系统异常!',
						type: 'error'
					})
					this.$refs.paging.complete([])
				})
			},
			/**
			 * 下拉上滑触发
			 */
			queryList(pageNo, pageSize) {
				// 组件加载时会自动触发此方法，因此默认页面加载时会自动触发，无需手动调用
				this.getList(pageNo, pageSize);
			},
			/**
			 * 跳转到指定页面
			 */
			jumpPage(url, params) {
				this.$u.route({
					url: url,
					params: params
				})
			}
		}
	}
</script>

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