<template>
	<view>
		<u-navbar >分润详情</u-navbar>
		<view class="details">
			<view class="details-head">
<!-- 				<u-icon name="charging-pile-fill" custom-prefix="custom-icon" color="#27B148" size="48"></u-icon>
 -->				<h4>{{detail.flowNo?detail.flowNo:'无充电单号'}}</h4>
			</view>
			<view class="details-main">
				<view class="details-price">
					<h3>{{detail.income}}元</h3>
				</view>
				<p>分润金额</p>
			</view>
	
		
			<view class="details-row" >
				<p>订单金额</p>
				<span>{{detail.actualFee  }}元</span>
			</view>
			<view class="details-row"  v-if="chargeDetails"  >
				<p>电费金额</p>
				<span>{{detail.electricityAmount }}元</span>
			</view>
			<view class="details-row"  v-if="chargeDetails"  >
				<p>服务费</p>
				<span>{{detail.surplusAmount-detail.discountAmount}}元
				<span v-if="couponObj&&couponObj.status=='1'">({{detail.surplusAmount}}-{{detail.discountAmount}})</span>
				
				</span>
			</view>
			<view class="details-row" v-if="couponObj&&couponObj.status=='1'" >
				<p>优惠券 </p>
				<span>
					{{couponObj.useText}}	
				</span>
			</view>
			
		
			
		</view>
		<view class="details">
			<view class="details-title">
				<h4>用电明细</h4>
			</view>
			<view class="details-row" >
				<p>总充电量</p>
				<span>{{detail.electricQuantity/10000}}度</span>
			</view>
					<view class="details-row" v-if="!chargeDetails" >
						<p>电费单价</p>
						<span>{{detail.unitPrice}}元/小时</span>
					</view>
					<view class="details-row"><p>充电时长</p><span>{{getPercent(detail.chargingMinute)}}</span></view>
					
				<view v-for="(item,i) in chargeDetails" :key="i">
					<view class="details-row" style=" margin-top: 18px;" >
						<p>区间充电量({{item.startTime}}-{{item.endTime}})</p>
						<span >{{item.kwh }}度</span>
					</view>
					
					<view class="details-row" style="display: block;" >
						<p>
							<span style="    color: #37393c;">区间定价</span>
							
							<span style="float: right; color: #333;font-weight: normal;">{{(item.electricityPrice*100+item.servicePrice*100)/100}}元/度</span>
							
						</p>
							<span class="details-row-sum">{{item.electricityPrice}}元/度(电费)+{{item.servicePrice}}元/度(服务费) </span>
											
					</view>
				</view>
		</view>
		
		<view class="details">
			<view class="details-title">
				<h4>分润明细</h4>
			</view>
			<view class="details-row" v-for="(item,i) in frmxList" :key="i" v-if="item.disProportion" >
				<p>{{item.merchantAccountName}}({{(item.disProportion*100).toFixed(2)}}%)</p>
				<span>{{item.shareProfitAmount}}元</span>
			</view>
		
		</view>
		
		<view class="details">
			<view class="details-title">
				<h4>更多信息</h4>
			</view>
			<view class="details-row"><p>来源站点</p><span>{{detail.stationName}}</span></view>
			<view class="details-row"><p>来源充电桩</p><span>{{detail.deviceName}}</span></view>
			<view class="details-row"><p>发放时间</p><span>{{detail.createTime}}</span></view>
 		</view>
		<view class="detailsBtn">
			<u-button class="detailsBtn-btn" @click="back" type="primary" plain>返回</u-button>
		</view>
	</view>
</template>

<script>
	import * as API from '@/apis/finance.js'
	
	export default {
		data() {
			return {
				chargeDetails:[],
				data:{},
				id:'',
				frmxList:[
					
				],
				couponObj:null,
				detail:{
					
				},
				title:"",
				 
			}
		},
		onLoad(op){
			
			this.data.detailId=op.id;
			this.getInfo()
		},
		methods: {
			getPercent(estimateMinute) {
				var value="";
				 
				var ms =estimateMinute
				if (ms > 0) {
					var Hour = parseInt(Math.floor(ms / 60 ));
					var Fen = parseInt(Math.floor(ms % 60 ));	
				//	value = Hour + "小时"  + Fen+"分钟"
					if(Hour){
						value += Hour + "小时" 
					}
						
					if(Fen){
						value += Fen+"分钟"
					}
				}
			
				return value;
			},
			showDateMoth(date){
				
				var back=date;
				if(date){
					var k=	date.slice(5,6)
					console.log(k)
					if(k=='0'){
						back=	date.slice(6,7)
					}else{
						back=	date.slice(5,7)
					}
					
					
				}
				return back;
			},
		 
			back(){
				uni.navigateBack({
					
				})
			},
			getInfo(){
				uni.showLoading({
					title:"加载中",mask:true,
				})
				API.recordDetailData(this.data).then((res) => {
					this.detail=res.data
						this.couponObj=res.data.userCoupon;
						
					 this.chargeDetails=JSON.parse(res.data.ChargeDetails)
					 console.log( this.chargeDetails)
					this.frmxList=res.data.detailList	 
					uni.hideLoading()
					 
				}).catch(error => {
						uni.showToast({
							
							title:error
						})
				})
			}
		}
	}
</script>
<style>
	page{
		background-color: #F7F7F7;
	}
</style>
<style lang="scss" scoped>
	.detailsBtn{
		margin: 16px;
		.detailsBtn-btn{
			border-color:#185AC6!important;
			border-radius: 8px!important;
			background: none!important;
			color:#185AC6!important;
		}
	}
	.details-title{
		margin-bottom: 16px;
		h4{
			font-weight: normal;
			font-size: 16px;
			position: relative;
			padding-left:10px;
			&::after{
				content: '';
				position: absolute;
				height: 12px;
				width: 4px;
				background-color: #27B148;
				left: 0;
				top:5px;
			}
		}
	}
	.details-row{
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 15px;
	
				p{
					color: #37393c;
					font-weight: bold;	
				}

	}
	.details-row-sum{
		float: right;
		color: #888;
		font-size: 12px;
	
	}
	.details{
		margin: 16px;
		padding: 20px;
		background-color: #fff;
		border-radius: 8px;
		.details-head{
			text-align: center;
			display: flex;
			align-items: center;
			justify-content: center;
			h4{
				font-size: 18px;
				font-weight: normal;
				margin-left: 4px;
			}
		}
		.details-price{
			margin-top: 28px;
			display: flex;
			align-items: flex-end;
			justify-content: center;
			h3{
				font-size: 36px;
				color:#27B148;
				line-height: 36px;
				margin: 0  4px;
				font-weight: normal;
			}
			span{
				font-size: 20px;
				color:#27B148;
			}
		}
		.details-main{
			text-align: center;
			margin-bottom: 20px;
			p{
				color:#777;
				margin-top: 4px;
			}
		}
	}
</style>
