<template>
	<view>
		<view class="dtop">
			<view class="title">{{ item.title || '' }}</view>
		</view>
		<view class="mbos">
			<view class="ms mt0">
				<view class="mtitle">兼职金额</view>
				<view class="desc mb15">{{ item.salary }}元</view>
				<view class="mtitle">兼职时间</view>
				<view class="desc mb15">{{ item.startDate }}至{{ item.endDate }}，共计：{{ item.days }}天</view>
				<view class="mtitle">兼职地点</view>
				<view class="desc mb15">{{ item.address || '工作地点不限' }}</view>
				<view class="mtitle">结算方式</view>
				<view class="desc mb15">在规定时间内完工结算（平台打款）</view>
				<view class="mtitle">兼职描述</view>
				<u-parse :content="item.contents" class="item"></u-parse>
				<map :latitude="item.latitude" :longitude="item.longitude" :markers="covers" v-if="item.latitude"></map>
			</view>
		</view>
		<view class="mfooter">
			<view class="cn">
				<button class="btn" @click="go('/pages/user/resume/application/task_list?taskId=' + item.taskId)">
					<text class="icon">&#xe652;</text>
					<text>任务日志</text>
				</button>
				<button class="btn" @click="send()">
					<text class="icon">&#xe652;</text>
					<text>确认完成</text>
				</button>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			item: {}
		};
	},
	onLoad(e) {
		this.http.request({
			url: '/app/position/detail/' + e.id,
			success: (res) => {
				this.item = res.data.data.position;
				this.item.days = this.util.days(this.item.startDate, this.item.endDate);
				this.item.taskId = e.taskId;
			}
		});
	},
	methods: {
		go(url) {
			uni.navigateTo({ url: url });
		},
		//投递简历
		send() {
			this.http.request({
				url: '/app/deliver/send/' + this.item.id,
				success: (res) => {
					//实名认证跳转
					if (res.data.code == 7878) {
						uni.showModal({
							title: '提示',
							content: res.data.msg,
							showCancel: false,
							success: (res) => {
								uni.navigateTo({ url: '/pages/user/auth' });
							}
						});
						return;
					}
					//完善简历跳转
					if (res.data.code == 7979) {
						uni.showModal({
							title: '提示',
							content: res.data.msg,
							showCancel: false,
							success: (res) => {
								uni.navigateTo({ url: '/pages/user/resume/index' });
							}
						});
						return;
					}
					let tmplIds = [];
					if (this.item.type == 0) {
						tmplIds = ['ll-qdaEgbDN4rEod0nJpsjUuSqHT9e12EniZfRPiNqM'];
					}
					if (this.item.type == 1) {
						tmplIds = ['yhFtY-hzXerPnIxXcYcRCLpbkuNrzn5yk-rWgHVX2Aw', '87jYTnpeZJnvdQ6gHcscZ96eQYlSXpfGeFU3g9deTeA'];
					}
					//通知模板订阅消息
					uni.requestSubscribeMessage({
						tmplIds: tmplIds,
						complete: (c) => {
							uni.showModal({ content: this.item.type == 0 ? '投递成功，等待企业回应' : '报名成功，等待雇主审核', showCancel: false });
						}
					});
				}
			});
		}
	}
};
</script>

<style lang="scss">
.mfooter {
	background-color: white;
	bottom: 0px;
	border-top: 1px solid $line;
	.cn {
		padding: 10px 10px 15px 10px;
		overflow: hidden;
		.btn {
			flex: 1;
		}
	}
}
</style>
