158 lines
4.6 KiB
HTML
158 lines
4.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>订单详情</title>
|
|
<style>
|
|
body {
|
|
font-family: Arial, sans-serif;
|
|
background-color: #f4f4f4;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.container {
|
|
width: 90%;
|
|
max-width: 600px;
|
|
margin: auto;
|
|
background: #fff;
|
|
padding: 20px;
|
|
box-shadow: 1px 1px 4px #ccc;
|
|
margin-top: 50px;
|
|
box-sizing: border-box;
|
|
border-radius: 8px;
|
|
}
|
|
h1 {
|
|
text-align: center;
|
|
color: #333;
|
|
}
|
|
.order-details {
|
|
margin: 20px 0;
|
|
}
|
|
.order-details p {
|
|
font-size: 16px;
|
|
margin: 10px 0;
|
|
}
|
|
.order-details span {
|
|
font-weight: bold;
|
|
}
|
|
.refund-form {
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
}
|
|
.refund-form button {
|
|
padding: 10px 20px;
|
|
background: #007bff;
|
|
color: #fff;
|
|
border: none;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
}
|
|
.refund-form button:hover {
|
|
background: #0056b3;
|
|
}
|
|
.loading {
|
|
display: none;
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
}
|
|
.loading img {
|
|
width: 50px;
|
|
height: 50px;
|
|
}
|
|
.success-message {
|
|
display: none;
|
|
text-align: center;
|
|
margin-top: 20px;
|
|
color: green;
|
|
font-size: 18px;
|
|
}
|
|
@media (max-width: 600px) {
|
|
.container {
|
|
width: 100%;
|
|
margin-top: 20px;
|
|
box-shadow: none;
|
|
}
|
|
.order-details p {
|
|
font-size: 14px;
|
|
}
|
|
.refund-form button {
|
|
padding: 8px 16px;
|
|
font-size: 14px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h2>订单详情</h2>
|
|
<div class="order-details">
|
|
<div class="order-details">
|
|
<p><span>商户单号:</span> {{.OutTradeNo}}</p>
|
|
<p><span>微信订单号:</span> {{.TransactionId}}</p>
|
|
<p><span>用户ID:</span> {{.Userid}}</p>
|
|
<p><span>时间:</span> {{.CreatedAt}}</p>
|
|
<p><span>商品:</span> {{.Product}}</p>
|
|
<p><span>商品价格:</span> {{.Amount}} 元</p>
|
|
<p><span>支付状态:</span>
|
|
{{if eq .PayStatus "SUCCESS"}}支付成功
|
|
{{else if eq .PayStatus "NOTPAY"}}未支付
|
|
{{else if eq .PayStatus "PAYERROR"}}支付失败
|
|
{{else if eq .PayStatus "UNDERREFUND"}}退款中
|
|
{{else if eq .PayStatus "REFUND"}}已退款
|
|
{{else}}未知
|
|
{{end}}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
{{if eq .PayStatus "SUCCESS"}}
|
|
<div class="refund-form">
|
|
<button id="refundButton">确认退款</button>
|
|
</div>
|
|
{{end}}
|
|
<div class="loading" id="loading">
|
|
<!-- <img src="loading.gif" alt="Loading...">-->
|
|
申请退款中。。。
|
|
</div>
|
|
<div class="success-message" id="successMessage">
|
|
申请退款成功,尝试刷新查看退款进度
|
|
</div>
|
|
</div>
|
|
<script>
|
|
document.getElementById("refundButton").addEventListener("click", function() {
|
|
const orderID = "{{.ID}}";
|
|
const loading = document.getElementById("loading");
|
|
const successMessage = document.getElementById("successMessage");
|
|
|
|
loading.style.display = "block";
|
|
|
|
fetch(`/api/pay/refund/${orderID}`, {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json"
|
|
},
|
|
})
|
|
.then(response => {
|
|
if (!response.ok) {
|
|
throw new Error("Network response was not ok");
|
|
}
|
|
return response.json();
|
|
})
|
|
.then(data => {
|
|
if(data.code === 0){
|
|
loading.style.display = "none";
|
|
successMessage.style.display = "block";
|
|
}else{
|
|
throw new Error("refund error");
|
|
}
|
|
})
|
|
.catch(error => {
|
|
loading.style.display = "none";
|
|
alert("退款失败,请重试。");
|
|
console.error("There was a problem with the fetch operation:", error);
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|