50 lines
1.5 KiB
JavaScript
50 lines
1.5 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');
|
|
});
|
|
}
|
|
}
|