-
Notifications
You must be signed in to change notification settings - Fork 0
/
thanks.html
74 lines (67 loc) · 2.57 KB
/
thanks.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>訂單完成</title>
<link rel="stylesheet" href="thanks.css">
</head>
<body>
<header>
<h1>訂單完成</h1>
</header>
<main>
<p>感謝您的訂購!</p>
<button onclick="goBackToObituary()">返回訃聞內容</button>
</main>
<footer>
<p>© 2024 祥安生命有限公司. 版權所有.</p>
</footer>
<script>
async function submitOrder() {
const orderData = {
name: document.getElementById('name').textContent,
orderName: document.getElementById('order-name').textContent,
orderNumber: document.getElementById('order-number').textContent,
ordererNames: document.getElementById('orderer-names').textContent,
invoice: document.getElementById('invoice').textContent,
invoiceInfo: {
companyName: document.getElementById('company-name').textContent,
recipientName: document.getElementById('recipient-name').textContent,
recipientAddress: document.getElementById('recipient-address').textContent,
},
signerNames: Array.from(document.getElementById('signer-names').getElementsByTagName('li')).map(li => li.textContent),
cartItems: Array.from(document.getElementById('cartItems').getElementsByTagName('li')).map(li => li.textContent),
};
try {
const response = await fetch('/api/orders', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(orderData)
});
if (response.ok) {
showThankYouModal();
// 5秒後自動重定向到指定頁面
setTimeout(() => window.location.href = 'obituary-page-url.html', 5000);
} else {
alert('提交订单失败,请重试。');
}
} catch (error) {
console.error('提交订单时发生错误:', error);
alert('提交订单失败,请重试。');
}
}
function showThankYouModal() {
document.getElementById('thankYouModal').style.display = 'block';
}
function closeThankYouModal() {
document.getElementById('thankYouModal').style.display = 'none';
}
function redirectToObituary() {
window.location.href = 'obituary-page-url.html';
}
</script>
</body>
</html>