<template>
	<view class="container">
		<uni-navbar title="路线详情"></uni-navbar>
		<view class="box">
			<view class="reject-box commonBj commonMt">
				<view class="reject-box-top">
					<view class="top-left">
						<image src="../../static/images/path/location.png" mode="widthFix"></image>
						<text class="listTitle">路线信息</text>
					</view>
				</view>
				<view class="reject-box-bottom infoHeight">
					<view class="map">
						<!-- <mapNew height="469rpx">
							
						</mapNew> -->
						<mapImg :startPoint='form.startPoint' :endPoint='form.endPoint' :mtRoutePointList='form.mtRoutePointList'></mapImg>
					</view>
					<view class="state-icon">
						<view class="flexAlignCenter">
							<view class="greenCircle">
							</view>
							<text class="itemText">开始地址:</text>
						</view>
						<view class="flexAlignCenter">
							<text class="infoText">{{form.startName}}</text>
						</view>
					</view>
					<view class="state-icon">
						<view class="flexAlignCenter">
							<view class="greenCircle">
							</view>
							<text class="itemText">结束地址:</text>
						</view>
						<view class="flexAlignCenter">
							<text class="infoText">{{form.endName}}</text>
						</view>
					</view>
					<view class="state-icon">
						<view class="flexAlignCenter">
							<view class="greenCircle">
							</view>
							<text class="itemText">发起部门:</text>
						</view>
						<view class="flexAlignCenter">
							<text class="infoText">{{form.startDept}}</text>
						</view>
					</view>
					<view class="state-icon">
						<view class="flexAlignCenter">
							<view class="greenCircle">
							</view>
							<text class="itemText">发起时间:</text>
						</view>
						<view class="flexAlignCenter">
							<text class="infoText">{{form.auditTime}}</text>
						</view>
					</view>
				</view>
			</view>
			<!-- 审批状态 -->
			<view :class="'reject-box mt28 commonMb '+ (isPass?'commonGreenBj':'commonRedBj')">
				<view :class="'reject-box-top just-content-start '+(isPass?'bg-color-green':'bg-color-red')">
					<image src="../../static/images/car/yunshu.png" mode="widthFix"></image>
					<text class="listTitle">审批状态</text>
				</view>
				<view class="reject-box-bottom pb0">
					<view class="state-icon">
						<view class="flexAlignCenter">
							<view :class="'greenCircle '+(isPass?'':'bg-color-red') ">
							</view>
							<text class="itemText">审批状态:</text>
						</view>
						<view class="flexAlignCenter">
							<u-icon :color="isPass?'#017D3E':'#FB5637'" style="margin-right: 12rpx;"
								:name="isPass?'checkmark-circle-fill':'close-circle-fill'"></u-icon>
							<text :class="isPass?'greenText':'redText'">{{isPass?'通过':'驳回'}}</text>
						</view>
					</view>
					<!-- <view :class="isPass?'border-style mb':'border-style2'"></view> -->
					<view class="state-icon" v-if="!isPass">
						<view class="flexAlignCenter">
							<view class="redCircle">
							</view>
							<text class="itemText">驳回原因:</text>
						</view>
						<view class="flexAlignCenter">
							<text class="redText">汽车行驶证过期，需重新上传</text>
						</view>
					</view>
					<!-- <view v-if="!isPass" class="border-style2 mb"></view> -->
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		routeInfo
	} from "@/api/company/path.js"
	export default {
		data() {
			return {
				//通过或者驳回
				isPass: true,
				form: {
					id: null,
					endPoint: '',
					startName: '',
					endName: '',
					name: '',
					startDept: '',
					endPoint:'',
					startPoint:'',
					mtRoutePointList:[],
					auditTime:'',
				},
			}
		},
		methods: {
			// 4326转3857
			
			 WGS84ToMercator(lonlat){
			    const coord = {
					lat:0,
			    	lng:0
				};
			    const earthRad = 6378137.0; //地球半径
			    coord.lat = lonlat.lng * Math.PI / 180 * earthRad;
			    const param = lonlat.lat * Math.PI / 180;
			    coord.lng = earthRad / 2 * Math.log((1.0 + Math.sin(param)) / (1.0 - Math.sin(param)));
			    return coord;
			},
			// 3857转4326
			
			 mercatorToWGS84(data){
				 let list=data.split(',');
				 let lonlat={lng:list[1],lat:list[0]};
			    const coord = {
					lat:0,
			    	lng:0
				};
			    const lat = lonlat.lat/20037508.34*180;
			    let lng = lonlat.lng/20037508.34*180;
			    lng = 180/Math.PI*(2*Math.atan(Math.exp(lng*Math.PI/180))-Math.PI/2);
			    coord.lat = lat;
			    coord.lng = lng;
			    return coord.lat+','+coord.lng
			},
			routeInfo(id){
				routeInfo(id).then(res=>{
					this.form=res.data;
					// this.form.startPoint =this.mercatorToWGS84(res.data.startPoint);
					// this.form.endPoint =this.mercatorToWGS84(res.data.endPoint);
					// this.form.mtRoutePointList=res.data.mtRoutePointList.map(item=>{
					// 	return {pointCoordinate:this.mercatorToWGS84(item.pointCoordinate)}
					// })
					// console.log(this.form,'this.form');
				})
			},
	},
	onLoad: function(option) {
		if(option.id)
		{
			this.routeInfo(option.id)
		}
	}
	}
</script>

<style lang="scss" scoped>
	.reject-box {

		.reject-box-top {
			width: 100%;
			height: 69rpx;
			background: #7FB5FF;
			border-radius: 26rpx 26rpx 0px 0px;
			display: flex;
			justify-content: space-between;
			uni-image {
				width: 50rpx;
				margin-left: 32rpx;
				vertical-align: middle;
			}

		}

		.reject-box-bottom {
			padding: 40rpx;

			.state-icon {
				display: flex;
				margin: 70rpx 0;
			}

			.state-icon:nth-child(1) {
				margin: 0 0 40rpx;
			}

			.border-style {
				border-top: 1rpx dashed #F98803;
				width: 90%;
				margin: 0 auto;
			}

			.border-style2 {
				border-top: 1rpx dashed #FB5637;
				width: 90%;
				margin: 0 auto;
			}
		}
	}

	.reject-box-bottom:nth-child(2) {
		padding: 40rpx 40rx 20rpx !important;
	}

	.block {
		display: block !important;
	}

	.border {
		border: 1rpx solid #495B93;
	}

	.box-size {
		width: 598rpx;
		height: 198rpx;
	}

	.mt30 {
		margin-top: 30rpx;
	}

	.radius15 {
		border-radius: 15rpx;
	}

	.state-box-size {
		width: 180rpx;
		height: 180rpx;
	}

	.state-box-size-video {
		width: 175rpx !important;
		height: 175rpx !important;
	}

	.space-between {
		justify-content: space-between;
	}

	.just-content-start {
		justify-content: flex-start !important;
		align-items: center;
	}

	.bg-color-green {
		background: #36C372 !important;
	}

	.bg-color-red {
		background: #FB5637 !important;
	}

	.fontTongGuo {
		font-size: 26rpx !important;
		font-weight: bold !important;
		color: #007C3C !important;
	}

	.fontColor {
		color: #FC5536 !important;
	}

	.mb {
		margin-bottom: 53rpx !important;
	}

	.pb0 {
		padding-bottom: 0 !important;
	}

	.mt28 {
		margin-top: 40rpx;
	}

	.mb0 {
		margin-bottom: 0rpx !important;
	}
	
	.map{
		height: 469rpx;
		background: #FFFFFF;
		border: 2rpx solid #495B93;
		border-radius: 15rpx;
		margin-top: 20rpx;
	}
</style>
