hookehuyr

fix: 将清空购物车逻辑从订单提交移至支付成功

在订单提交成功后清空购物车可能导致用户在支付失败后购物车被清空,因此将清空购物车的逻辑移至支付成功后执行,确保只有在支付成功时才清空购物车
...@@ -126,8 +126,6 @@ export function provideCart(mode = CartMode.MULTIPLE) { ...@@ -126,8 +126,6 @@ export function provideCart(mode = CartMode.MULTIPLE) {
126 126
127 return addOrderAPI(orderData).then(response => { 127 return addOrderAPI(orderData).then(response => {
128 if (response.code === 1) { 128 if (response.code === 1) {
129 - // 订单提交成功后清空购物车
130 - clearCart()
131 return { 129 return {
132 success: true, 130 success: true,
133 orderId: response.data.id, 131 orderId: response.data.id,
......
...@@ -390,6 +390,8 @@ const handlePaymentResult = async (res) => { ...@@ -390,6 +390,8 @@ const handlePaymentResult = async (res) => {
390 let retryCount = 0; 390 let retryCount = 0;
391 const verifyPayment = async () => { 391 const verifyPayment = async () => {
392 if (await checkPaymentStatus(orderId.value)) { 392 if (await checkPaymentStatus(orderId.value)) {
393 + // 支付成功后清空购物车
394 + clearCart();
393 return; 395 return;
394 } 396 }
395 if (retryCount < MAX_RETRY_ATTEMPTS) { 397 if (retryCount < MAX_RETRY_ATTEMPTS) {
......