<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>订单明细</title>
	<link rel="stylesheet" href="/component/pear/css/pear.css" />
	<style>
		.list {
			padding: 9px 0 !important;
			line-height: 20px;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
		}

		.container {
			padding: 20px;
			padding-left: 0;
		}

		.container hr {
			margin-left: 20px;
		}

		.paytype {
			display: flex;
			align-items: center;
		}

		.paytype>strong {
			margin-left: 3px;
		}

		.alipay {
			color: #1677ff;
		}

		.wxpay {
			color: #1AAD19;
		}

		.unionpay {
			color: #d81e06;
		}
	</style>
</head>

<body>
	<div class="layui-row container">
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>订单号</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $order_id ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>用户ID</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo "<strong>{$pid}</strong>" ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>收款方式</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list paytype">
					<?php $payway=['alipay'=>'支付宝','wxpay'=>'微信支付','unionpay'=>'云闪付'];$payway_img=['alipay'=>'/static/img/alipay.ico','wxpay'=>'/static/img/wxpay.ico','unionpay'=>'/static/img/unionpay.ico'];echo "<img src='{$payway_img[$type]}'width='16'><strong class='{$type}'>{$payway[$type]}</strong>" ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>商户订单号</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $out_trade_no ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>异步通知</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $notify_url ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>跳转通知</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $return_url ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>商品</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $name ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>成交金额</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $really_price ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>订单金额</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $money ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>客户IP</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $clientip ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>客户设备</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $device ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>支付状态</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php 
					if ($state === 0 && time() > strtotime($close_time)){$state = -1;}
					$status = ['0'=>'等待支付','1'=>'支付成功','-1'=>'订单过期'];
					$bg_color = ['0'=>'orange','1'=>'green','-1'=>'gray'];
					echo "<span class='layui-badge layui-bg-{$bg_color[$state]}'>{$status[$state]}</span>";
					?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>创建时间</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $create_time ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>关闭时间</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $close_time ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>支付时间</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $pay_time == $create_time ? '- -' : $pay_time ?>
				</div>
			</div>
		</div>
		<hr>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>收款平台</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $platform ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>收款流水号</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $platform_order ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>收款账号</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $account ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>收款终端</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<?php echo $channel ?>
				</div>
			</div>
		</div>
		<div class="layui-row">
			<div class="layui-col-xs3"><label class="layui-form-label"><strong>收款地址</strong></label></div>
			<div class="layui-col-xs9">
				<div class="list">
					<a href="javascript:;" class="layui-font-blue" lay-on="getQrcode"
						data-qrcode="<?php echo $qrcode ?>" data-type="<?php echo $url_type ?>"><span
							class="icon pear-icon">&#xe6cc;</span></a>
					<?php echo $qrcode ?>
				</div>
			</div>
		</div>
	</div>
	<script src="/component/layui/layui.js"></script>
	<script src="/component/pear/pear.js"></script>
	<script src="/static/js/awesome-qr.min.js"></script>
	<script>
		const QR = AwesomeQR.AwesomeQR;
		layui.use(['util', 'layer'], function () {
			let util = layui.util;
			let layer = layui.layer;
			util.on({
				getQrcode: function () {
					(async () => {
						const type_data = this.getAttribute("data-type");
						const qrcode_data = this.getAttribute("data-qrcode");
						if (type_data == 1) {
							layer.open({
								type: 1,
								area: ['200px', '200px'],
								title: false,
								closeBtn: 0,
								shadeClose: true,
								content: `<img width="100%" src="${qrcode_data}">`
							});
						} else if (type_data == 0) {
							const qrcode_img = await getQrcode(qrcode_data, QR);
							layer.open({
								type: 1,
								area: ['200px', '200px'],
								title: false,
								closeBtn: 0,
								shadeClose: true,
								content: `<img width="100%" src="${qrcode_img}">`
							});
						}
					})()
				}
			});
		})
		// 生成二维码
		async function getQrcode(text, QR) {
			const qrcodeUrl = await new Promise((resolve) => {
				new QR({
					text: text,
					size: 500,
				}).draw().then((dataURL) => { resolve(dataURL); });
			})
			return qrcodeUrl;
		}
	</script>
</body>

</html>