<template>
	<view class="se-p-40">
		<view class="se-fs-36 se-c-black se-fw-6 se-py-20">
			{{items.title}}
		</view>
		<view class="se-fs-26 se-c-orange se-fw-6 ">
			{{items.salaryMin}} - {{items.salaryMax}}
		</view>
		<view class="se-flex se-flex-v se-py-20">
			<view class="se-fs-24 se-c-text">
				<text>{{items.address}}</text>
				<!-- <text class="se-ml-20">不限</text> -->
			</view>
			<view class="se-fs-24 se-c-99 se-pt-20">
				该职位位于{{items.createTime}}发布
			</view>
		</view>
		<view class="se-flex se-flex-h-sb se-py-40 se-b-b">
			<view class="se-flex">
				<view>
					<image class="se-a-80 se-br-p-50 se-bgc-f5" :src="items.employAuthenticationPerson.image" mode=""></image>
				</view>
				<view class="se-ml-20 se-flex se-flex-v-sa se-flex-ai-fs">
					<text class="se-fw-6 se-c-black se-fs-30">{{items.employAuthenticationCompany.name}}</text>
					<text class="se-fs-24 se-c-text-third">{{items.employAuthenticationCompany.company}}</text>
				</view>
			</view>
		</view>
		<view class="se-py-40 se-b-b">
			<view class="se-fs-36 se-c-black">
				工作地址
			</view>
			<view class="se-fs-24 se-c-66 se-pt-10 se-flex se-flex-h" @click="openAddress()">
				<text>{{items.address}}</text>
				<u-icon name="arrow-right"></u-icon>
			</view>
		</view>
		<view class="se-py-40 se-b-b">
			<view class="se-fs-36 se-c-black">
				职位详情
			</view>
			<view class="se-pt-20">
				<text class="se-c-text-sub se-fs-22 se-mr-10 se-py-5 se-px-20 se-br-5 se-bgc-f5" v-if="items.payType">{{items.payType}}</text>
				<text class="se-c-text-sub se-fs-22 se-mr-10 se-py-5 se-px-20 se-br-5 se-bgc-f5" v-if="items.categoryOne">{{items.categoryOne}}</text>
				<text class="se-c-text-sub se-fs-22 se-mr-10 se-py-5 se-px-20 se-br-5 se-bgc-f5" v-if="items.categoryTwo">{{items.categoryTwo}}</text>
				<!-- <text class="se-c-text-sub se-fs-22 se-mr-10 se-py-5 se-px-20 se-br-5 se-bgc-f5">水泥搬运</text> -->
			</view>
		</view>
		<view class="se-fs-24 se-pt-20 se-pb-20 se-lh-40">
			<text class="se-fs-24 se-c-text-third">岗位要求</text>
			<u-parse :content="items.details"></u-parse>
		</view>
		<view class="se-px-20 se-pt-20">
			<view class="se-px-20 se-pb-80 se-fs-20 se-flex">
				<view @click="onPayment"
					class="se-mx-10 se-flex-1 se-br-40 se-flex-h-c se-h-80 se-lh-80 se-ta-c se-fs-28 se-c-white se-bgc-orange">
					<text>立即接单</text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		getTaskById,orderTask,addOrderWork
	} from "@/common/api.js"
	export default{
		data(){
			return{
				id:"",
				items:{},
			}
		},
		onLoad(options) {
			console.info(options)
			this.id = options.id
			this.onTask()
		},
		methods:{
			onTask(){
				let that = this
				getTaskById({id:that.id}).then(response=>{
					console.info('getTaskById',response);
					that.items = response.result
				}).catch(error=>{
					
				})
			},
			onPayment(){
				addOrderWork({id:this.id}).then(response=>{
					
					console.log("下单成功");
					uni.navigateTo({
						url:"/pages_subpack/payment/index?id="+response.result.id
					})
				}).catch(error=>{
					
				})
			},
			openAddress(){
				let that = this
				console.info(that.items.latitude)
				console.info(that.items.longitude)
				wx.openLocation({
					latitude: Number(that.items.latitude),
					longitude: Number(that.items.longitude),
					name: that.items.title, 
					address: that.items.address,
					scale: 12,
					    success: function(res) {
					        console.log(JSON.stringify(res));
					    },
					    fail: function(res) {
					        console.log(`openLocation fail:${JSON.stringify(res)}`);
					    }
				})
				// uni.openLocation({
				//     latitude: 30.492121,
				//     longitude: 114.410324,
				//     name: "保利国际中心",
				//     address: "武汉市洪山区关山大道",
				//     scale: 12,
				//     success: function(res) {
				//         console.log(JSON.stringify(res));
				//     },
				//     fail: function(res) {
				//         console.log(`openLocation fail:${JSON.stringify(res)}`);
				//     }
				// })
			}
		}
	}
</script>

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