taibai_shopping/app/static/js/order_detail.js
2025-07-04 19:07:35 +08:00

50 lines
1.4 KiB
JavaScript

// 订单详情页面脚本
// 取消订单
function cancelOrder(orderId) {
if (confirm('确定要取消这个订单吗?取消后无法恢复。')) {
fetch(`/order/cancel/${orderId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
showAlert(data.message, 'success');
setTimeout(() => location.reload(), 1000);
} else {
showAlert(data.message, 'error');
}
})
.catch(error => {
showAlert('操作失败,请重试', 'error');
});
}
}
// 确认收货
function confirmReceipt(orderId) {
if (confirm('确定已收到商品吗?确认后订单将完成。')) {
fetch(`/order/confirm_receipt/${orderId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
showAlert(data.message, 'success');
setTimeout(() => location.reload(), 1000);
} else {
showAlert(data.message, 'error');
}
})
.catch(error => {
showAlert('操作失败,请重试', 'error');
});
}
}