<template>
	<view class="page">
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
		<view class="content">
			
		<view class="top">
			<view class="topphone">
				<view class="topphonebg"><image src="../../static/btn.png"></image></view>
				<view class="topphonetext"><image src="../../static/phone1.png"></image>联系电话</view>
			</view>
			<!-- <view class="topimg"><image src="../../static/img/05.jpg" mode="widthFix"></image></view> -->
			<map v-if="mapshow" style="width: 100%; height: 300px;" :latitude="latitude" :longitude="longitude" :markers="covers">
			</map>
		</view>
			
			<view class="message-list">
			<view class="titleall-box">
				<view class="titleall-left"><view class="titleall-left-line"></view>逝者信息</view>
			</view>
			<view class="info-box">
				<view class="info-box-list">
					<view class="info-box-width">
						<view>{{info.deceasedName}}</view>
						<view class="info-box-small">逝者姓名</view>
					</view>
					<view class="info-box-width">
						<view>{{info.deceasedAge}}</view>
						<view class="info-box-small">逝者年龄</view>
					</view>
				</view>
				<view class="info-box-list">
					<view class="info-box-width">
						<view>{{info.deceasedSex == '0' ? '男' : '女'}}</view>
						<view class="info-box-small">逝者性别</view>
					</view>
				</view>
			</view>
			</view>
			
			<view class="message-list">
			<view class="titleall-box">
				<view class="titleall-left"><view class="titleall-left-line"></view>预约人信息</view>
			</view>
			<view class="info-box">
				<view class="info-box-list">
					<view class="info-box-width">
						<view>{{info.contactName}}</view>
						<view class="info-box-small">预约人姓名</view>
					</view>
					<view class="info-box-width">
						<view>{{info.contactPhone}}</view>
						<view class="info-box-small">预约人电话</view>
					</view>
				</view>
				<!-- <view class="info-box-list">
					<view class="info-box-width">
						<view>内地居民身份证</view>
						<view class="info-box-small">预约人证件类型</view>
					</view>
					<view class="info-box-width">
						<view>38172648172618819</view>
						<view class="info-box-small">预约人证件号码</view>
					</view>
				</view> -->
			</view>
			</view>
			
			<view class="message-list">
			<view class="titleall-box">
				<view class="titleall-left"><view class="titleall-left-line"></view>死亡相关信息</view>
			</view>
			<view class="info-box">
				<view class="info-box-list">
					<view class="info-box-width">
						<view>{{info.deathdate}}</view>
						<view class="info-box-small">死亡日期</view>
					</view>
					<view class="info-box-width">
						<view>{{info.deathCase}}</view>
						<view class="info-box-small">死亡原因</view>
					</view>
				</view>
			</view>
			</view>
			
			<view class="message-list">
			<!-- <view class="titleall-box">
				<view class="titleall-left"><view class="titleall-left-line"></view>火化时间</view>
			</view>
			<view class="info-box">
				<view class="info-box-list">
					<view class="info-box-width width100">
						<view>2023-01-01</view>
						<view class="info-box-small">火化日期</view>
					</view>
				</view>
				<view class="info-box-list">
					<view class="info-box-width width100">
						<view>16:20-17:00</view>
						<view class="info-box-small">火化时间（此为预约时间，非实际火化时间）</view>
					</view>
				</view>
			</view> -->
			</view>
		</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				OrderType: 0,
				nvConfig:{
					title:"报丧订单详情",
					bgColor:"#ffffff",
					color:"#000000",
					fixedAssist:{
						hide:true,
					},
				},
				price:0,
				number:0,
				info:{},
				fwinfo:[],
				
				// 地图
				mapshow:true,
				id:0, // 使用 marker点击事件 需要填写id
				title: 'map',
				latitude: 39.909,
				longitude: 116.39742,
				covers: [{
					latitude: 39.909,
					longitude: 116.39742,
					iconPath: '../../../static/location.png'
				}],
			};
		},
		onPageScroll(e) {this.$refs.nv.pageScroll(e)},
		computed:{
			pageTop(){return parseInt(88*uni.getSystemInfoSync().windowWidth/750) + uni.getSystemInfoSync().statusBarHeight}
		},
		onLoad(params) {
			this.info = JSON.parse(params.info)
			console.log(this.info);
			this.getbsdetail(this.info.orderNumber)
			// this.OrderType = params.type;
		},
		methods:{
			/**
			 * 返回点击
			 */
			onBack(){
				uni.navigateBack();
			},
			/**
			 * 订单tab点击
			 */
			onOrderTab(type){
				this.OrderType = type;
				// #ifdef H5
				uni.redirectTo({
					url: '/pages/MyOrderList/MyOrderList?type=' + type,
				})
				//#endif
			},
			/**
			 * 订单列表点击
			 */
			// onOrderList(){
			// 	uni.navigateTo({
			// 		url: '/pages/OrderDetails/OrderDetails',
			// 	})
			// },
			// 获取订单详情
			getbsdetail(id){
				id = parseInt(id)
				console.log(typeof(id));
				this.API.getbsdetail(id).then(res=>{
					console.log(11111);
					console.log("用户订单",res);
					this.getGps(res.data.vehicleNumber);
					this.number = res.data.funeralOrderDetailsInfoPo.quantityNumber
					this.price = res.data.funeralOrderDetailsInfoPo.unitPrice
					this.API.getspjcxx(res.data.funeralOrderDetailsInfoPo.productId).then(res1=>{
						console.log("获取库存基础信息",res1);
						this.fwinfo = res1.rows
					})
				})
			},
			// 获取gps定位
			getGps(vehicleNumber){
				var EndTime = Date.parse(new Date());
				EndTime = this.parseTime(EndTime)
				console.log("当前时间",EndTime);
				var BeginTime = Date.parse(new Date()) - 1800000
				BeginTime = this.parseTime(BeginTime)
				var info = {
					request:{
						"Action":"GetVehicleTrackData",
						"UserId":"user",
						"Pwd":"6B18CFA67F76F079B0BFFBD773DC4494",
						"PlateNum":vehicleNumber,
						"ColorCode":"0",
						"BeginTime":"20231010090000",
						"EndTime":"20231010150000",
						"MinSpeed":"1",
						"NeedAddress":"0",
					}
				}
				info.request.BeginTime = BeginTime;
				info.request.EndTime = EndTime
				info.request = JSON.stringify(info.request)
				this.API.getGps(info).then(res=>{
					console.log("gps",res);
					if(res.Msg == "未找到指定时间段内车辆的轨迹信息！"){
						this.mapshow = false
					}else{
						var len = res.Data.length - 1
						this.latitude = res.Data[len].Latitude
						this.longitude = res.Data[len].Longitude
						this.covers[0].latitude = res.Data[len].Latitude
						this.covers[0].longitude = res.Data[len].Longitude
					}
					
				})
			},
			parseTime(EndTime){
			    var date = new Date(EndTime);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
			    var Y = date.getFullYear() + '';
			    var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1)+ '';
			    var D = (date.getDate() < 10 ? '0'+date.getDate() : date.getDate())+ '';
			    var h = (date.getHours() < 10 ? '0'+date.getHours() : date.getHours())+ '';
			    var m = (date.getMinutes() < 10 ? '0'+date.getMinutes() : date.getMinutes())+ '';
			    var s = (date.getSeconds() < 10 ? '0'+date.getSeconds() : date.getSeconds())+ '';
			
			    let strDate = Y+M+D+h+m+s;
				console.log(strDate) //2020-05-08 17:44:56　
				return strDate;
			},

      /**
       * 评价点击
       */
      onEvaluate(){
			  uni.navigateTo({
          url: '/pages/MyEvaluatePush/MyEvaluatePush'
        })
      }
		}
	}
</script>

<style scoped lang="scss">
	@import 'mydeathdetail.scss';
	.ssss{
		
	}
</style>
