<template>
	<view class="order-detail-container">
		<!-- <statusBar /> -->
		<view class="top-area">
			<view class="order-state">
				<view class="state-left">
					{{ detailData.status < 2 ? "待支付" : detailData.status < 5 ? "进行中" : detailData.status == 5 ? "已完成" : "" }}
					<text class="pay-type">{{ getPayName(detailData.orderPlatform) }}</text>
				</view>
				<!-- view>
					<button class="pay-btn" @click="goPay(detailData)">去支付</button>
				</view> -->
			</view>
			<view class="number-area">
				<view class="number-area-item">
					<view>
						订单编号
					</view>
					<view class="number-value">
						{{ detailData.orderNo }}
						<image class="copy-img" src="/static/icon/icon-copy.png" @click="copy(detailData.orderNo)"></image>
					</view>
				</view>
				<view class="number-area-item">
					<view>
						充电桩编号
					</view>
					<view class="number-value">
						{{ detailData.gunNo }}
						<image class="copy-img" src="/static/icon/icon-copy.png" @click="copy(detailData.gunNo)"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="info-item">
			<view class="info-item-title">
				充电信息
			</view>
			<view class="flex-space-between">
				<view class="text-one">
					{{ detailData.startTime?.substring(5, 10)?.replace("-", "月") }}日
				</view>
				<view class="text-one">
					{{ detailData.endTime?.substring(5, 10)?.replace("-", "月") }}日
				</view>
			</view>
			<view class="flex-space-between mb16 item-flex-end">
				<view class="text-one">
					{{ detailData.startTime?.substring(11, 19) }}
				</view>
				<view class="time-area">
					<view class="use-time">
						{{ detailData.useTime }}分钟
					</view>
					<view class="arrow-line"></view>
				</view>
				<view class="text-one">
					{{ detailData.endTime?.substring(11, 19) }}
				</view>
			</view>
			<view class="flex-space-between">
				<view class="text-two">
					开始充电
				</view>
				<view class="text-two">
					结束充电
				</view>
			</view>
			<view class="line"></view>
			<view class="flex-space-between item-center">
				<view class="text-one">
					合计充电量
				</view>
				<view>
					<text class="text-three">{{ detailData.useDegree }}</text>
					<text class="text-one"> 度</text>
				</view>
			</view>
		</view>
		<view class="info-item">
			<view class="info-item-title">
				费用信息
			</view>
			<view class="flex-space-between">
				<view class="text-one">
					订单总额
				</view>
				<view class="text-one">
					{{ detailData.actuallyAmount }}元
				</view>
			</view>
			<view class="money-detail">
				<view class="money-detail-box">
					<view>
						电费
						<text class="text-one mx16">{{ detailData.electricityAmount }}</text>
						元
					</view>
					<view>
						服务费
						<text class="text-one mx16">{{ detailData.serviceAmount }}</text>
						元
					</view>
				</view>
			</view>
			<view class="flex-space-between mb16">
				<view class="text-two">
					支付金额
				</view>
				<view class="text-one">
					{{ detailData.actuallyAmount }}元
				</view>
			</view>
			<view class="flex-space-between">
				<view class="text-two">
					{{ detailData.payTime }}
				</view>
				<view class="text-two">
					{{ getPayName(detailData.orderPlatform) }}
				</view>
			</view>
			<view class="line"></view>
			<view class="flex-space-between item-center">
				<view class="text-one">
					实付金额
				</view>
				<view>
					<text class="text-three">{{ detailData.actuallyAmount }}</text>
					<text class="text-one"> 元</text>
				</view>
			</view>
		</view>
		<view class="info-item">
			<view class="info-item-title">
				终端信息
			</view>
			<!-- <view class="flex-space-between mb16">
				<view class="text-two">
					辅助电源
				</view>
				<view class="text-two text-bold">
					12/24v
				</view>
			</view> -->
			<view class="flex-space-between mb16">
				<view class="text-two">
					充电站
				</view>
				<view class="text-two text-bold">
					{{ detailData.stationName }}
				</view>
			</view>
			<view class="flex-space-between">
				<view class="text-two">
					终端名称
				</view>
				<view class="text-two text-bold">
					{{ detailData.deviceNo }}
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref, reactive } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { copy } from '@/utils/fun.js';
import { ordersInfo } from '@/api/api.js';

const detailData = ref();

onLoad((options) => {
	getDetail(options.transactionNo);
});

const getDetail = async (transactionNo) => {
	console.log("------transactionNo-----", transactionNo)
	let _res = await ordersInfo({ transactionNo });
	detailData.value = _res;
};

const getPayName = v => {
	if(v == 1){
		return "微信支付"
	}else if(v == 2){
		return "支付宝支付"
	}else{
		return ""
	}
}

const goPay = () => {
	console.log("去支付")
}
</script>

<style scoped lang="scss">
.order-detail-container {
	.top-area {
		background: linear-gradient( 180deg, #FFFFFF 0%, #F7F7F7 100%);
		padding: 24rpx 30rpx 36rpx;
		.order-state {
			display: flex;
			justify-content: space-between;
			align-items: center;
			.state-left {
				font-weight: bold;
				font-size: 44rpx;
				color: #232323;
				.pay-type {
					width: 120rpx;
					height: 38rpx;
					background: rgba(111,162,86, 0.1);
					border-radius: 8rpx;
					font-weight: bold;
					font-size: 24rpx;
					color: #6FA256;
					padding: 6rpx 12rpx;
					margin-left: 8rpx;
				}
			}
			.pay-btn {
				width: 156rpx;
				height: 50rpx;
				line-height: 50rpx;
				background: #6FA256;
				border-radius: 26rpx;
				font-weight: bold;
				font-size: 30rpx;
				color: #FFFFFF;
			}
		}
		.number-area {
			display: flex;
			justify-content: space-between;
			margin-top: 36rpx;
			&-item {
				width: 50%;
				font-family: DIN, DIN;
				font-weight: 400;
				font-size: 24rpx;
				color: #232323;
				.number-value {
					margin-top: 16rpx;
					.copy-img {
						width: 24rpx;
						height: 24rpx;
						margin-left: 6rpx;
					}
				}
			}
		}
	}
	
	.info-item {
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 24rpx;
		margin: 0 30rpx 36rpx;
		.info-item-title {
			font-weight: bold;
			font-size: 32rpx;
			color: #232323;
			margin-bottom: 28rpx;
		}
		.time-area {
			flex: 1;
			margin: 0 18rpx;
			.use-time {
				font-weight: bold;
				font-size: 28rpx;
				color: #3BCF73;
				text-align: center;
				margin-bottom: 8rpx;
			}
			.arrow-line {
				border-top: 2rpx dashed #999999;
				padding-top: 6rpx;
				position: relative;
			}
			.arrow-line::after {
			  content: '';
			  position: absolute;
			  width: 14rpx;
			  height: 14rpx;
			  right: 4rpx;
			  top: 0;
			  transform: translateY(-60%) rotate(-50deg);
			  border-right: 2rpx dashed #999999;
			}
		}
		.money-detail {
			padding: 24rpx 24rpx 0;
			margin-bottom: 24rpx;
			&-box {
				background: rgba(111, 162, 86, 0.1);
				font-weight: bold;
				font-size: 24rpx;
				color: #6FA256;
				padding: 14rpx 30rpx;
				border-radius: 16rpx;
				display: flex;
				justify-content: space-between;
				position: relative;
			}
			&-box::after {
				content: '';
				position: absolute;
				top: -10rpx;
				right: 20rpx;
				transform: translateY(-75%);
				border-top: 20rpx solid transparent;
				border-bottom: 20rpx solid rgba(111, 162, 86, 0.1);
				border-left: 18rpx solid transparent;
				border-right: 18rpx solid transparent;
			}
		}
	}
	.flex-space-between {
		display: flex;
		justify-content: space-between;
	}
	.item-flex-end {
		align-items: flex-end;
	}
	.item-center {
		align-items: center;
	}
	.mb16 {
		margin-bottom: 16rpx;
	}
	.mx16 {
		margin-left: 16rpx;
		margin-right: 16rpx;
	}
	.text-one {
		font-weight: bold;
		font-size: 28rpx;
		color: #232323;
	}
	.text-two {
		font-weight: 400;
		font-size: 24rpx;
		color: #666666;
	}
	.text-three {
		font-family: DIN, DIN;
		font-weight: bold;
		font-size: 44rpx;
		color: #232323;
	}
	.text-bold {
		font-weight: bold;
	}
	.line {
		height: 0rpx;
		border-bottom: 2rpx solid #EEEEEE;
		margin: 24rpx 0 26rpx;
	}
}
</style>
