feat: 修复toast异常问题

This commit is contained in:
duanshuwen
2026-04-11 18:00:32 +08:00
parent 677333cc5f
commit 349e2a8f3d

View File

@@ -147,7 +147,7 @@ watch(
if (newQuantity > currentLength) {
// 数量增加,添加新的表单项
const newForms = Array.from({ length: newQuantity - currentLength }, () =>
createEmptyUserForm(),
createEmptyUserForm()
);
userFormList.value.push(...newForms);
} else if (newQuantity < currentLength) {
@@ -158,7 +158,7 @@ watch(
// 等待DOM更新完成
await nextTick();
},
{ immediate: false },
{ immediate: false }
);
onLoad((options) => {
@@ -184,7 +184,7 @@ const getGoodsDetail = async (commodityId) => {
// 取commodityFacilityList前3个
orderData.value.commodityFacilityList = res.data.commodityFacilityList.slice(
0,
3,
3
);
};
@@ -211,7 +211,6 @@ const validateUserForms = () => {
// 处理支付点击事件
const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
try {
console.log("处理支付点击事件", userFormList.value);
// 校验用户姓名
if (!validateUserForms()) {
@@ -314,16 +313,18 @@ const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
uni.showToast({ title: "支付失败,请重试", icon: "none" });
},
});
} catch (error) {
console.error(error);
uni.hideLoading(); // 提前关闭 loading确保 toast 能在安卓正常弹出
setTimeout(() => {
uni.showToast({ title: "请求出错,请重试", icon: "none" });
}, 100);
} finally {
// 最终兜底关闭 loading
uni.hideLoading();
}
// try {
// } catch (error) {
// console.error(error);
// uni.hideLoading(); // 提前关闭 loading确保 toast 能在安卓正常弹出
// setTimeout(() => {
// uni.showToast({ title: "请求出错,请重试", icon: "none" });
// }, 100);
// } finally {
// // 最终兜底关闭 loading
// uni.hideLoading();
// }
}, 1000);
</script>