feat: 提交订单的loading 添加

This commit is contained in:
2025-12-01 16:55:10 +08:00
parent c20563ecf5
commit 09452bf600
2 changed files with 108 additions and 94 deletions

View File

@@ -71,10 +71,14 @@ const handleButtonClick = async (orderData) => {
uni.navigateTo({
url: `/pages/goods/index?commodityId=${orderData.commodityId}`,
});
return;
}
// 待支付状态,调用支付接口
if (statusCode.value === "0") {
// 显示 loading
uni.showLoading({ title: "正在提交订单..." });
const orderId = orderData.orderId;
const payWay = orderData.payWay;
const paySource = orderData.paySource;
@@ -84,6 +88,7 @@ const handleButtonClick = async (orderData) => {
// 检查接口返回数据
if (!res || !res.data) {
uni.hideLoading();
uni.showToast({ title: "订单创建失败,请重试", icon: "none" });
return;
}
@@ -93,17 +98,14 @@ const handleButtonClick = async (orderData) => {
// 验证支付参数是否完整
if (!nonceStr || !packageVal || !paySign || !signType || !timeStamp) {
// console.error("支付参数不完整:", {
// nonceStr: !!nonceStr,
// packageVal: !!packageVal,
// paySign: !!paySign,
// signType: !!signType,
// timeStamp: !!timeStamp,
// });
uni.hideLoading();
uni.showToast({ title: "支付参数错误,请重试", icon: "none" });
return;
}
// 在发起微信支付前关闭 loading避免与原生支付 UI 冲突)
uni.hideLoading();
// 调用微信支付
uni.requestPayment({
provider: "wxpay",
@@ -126,6 +128,7 @@ const handleButtonClick = async (orderData) => {
}
} catch (error) {
console.error("操作失败:", error);
uni.hideLoading();
}
};
</script>