feat: 给toast 添加延迟
This commit is contained in:
@@ -265,7 +265,13 @@ const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
|
|||||||
|
|
||||||
// 检查接口返回数据
|
// 检查接口返回数据
|
||||||
if (!res || !res.data) {
|
if (!res || !res.data) {
|
||||||
uni.showToast({ title: res.msg || "订单创建失败,请重试", icon: "none" });
|
uni.hideLoading();
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.showToast({
|
||||||
|
title: res.msg || "订单创建失败,请重试",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +281,9 @@ const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
|
|||||||
// 验证支付参数是否完整
|
// 验证支付参数是否完整
|
||||||
if (!nonceStr || !packageVal || !paySign || !signType || !timeStamp) {
|
if (!nonceStr || !packageVal || !paySign || !signType || !timeStamp) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({ title: "支付参数错误,请重试", icon: "none" });
|
setTimeout(() => {
|
||||||
|
uni.showToast({ title: "支付参数错误,请重试", icon: "none" });
|
||||||
|
}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,9 +316,12 @@ const handlePayClick = ThrottleUtils.createThrottle(async (goodsData) => {
|
|||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
uni.showToast({ title: "请求出错,请重试", icon: "none" });
|
uni.hideLoading(); // 提前关闭 loading,确保 toast 能在安卓正常弹出
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.showToast({ title: "请求出错,请重试", icon: "none" });
|
||||||
|
}, 100);
|
||||||
} finally {
|
} finally {
|
||||||
// 防止某些分支忘记 hide,确保最终关闭 loading(requestPayment 后也可以安全调用 hide)
|
// 最终兜底关闭 loading
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|||||||
@@ -90,7 +90,9 @@ const handleButtonClick = DebounceUtils.createDebounce(async (orderData) => {
|
|||||||
// 检查接口返回数据
|
// 检查接口返回数据
|
||||||
if (!res || !res.data) {
|
if (!res || !res.data) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({ title: res.msg || "订单创建失败,请重试", icon: "none" });
|
setTimeout(() => {
|
||||||
|
uni.showToast({ title: res.msg || "订单创建失败,请重试", icon: "none" });
|
||||||
|
}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +102,9 @@ const handleButtonClick = DebounceUtils.createDebounce(async (orderData) => {
|
|||||||
// 验证支付参数是否完整
|
// 验证支付参数是否完整
|
||||||
if (!nonceStr || !packageVal || !paySign || !signType || !timeStamp) {
|
if (!nonceStr || !packageVal || !paySign || !signType || !timeStamp) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({ title: "支付参数错误,请重试", icon: "none" });
|
setTimeout(() => {
|
||||||
|
uni.showToast({ title: "支付参数错误,请重试", icon: "none" });
|
||||||
|
}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -848,20 +848,24 @@ const sendMessage = async (message, isInstruct = false) => {
|
|||||||
// 检查连接是否成功建立
|
// 检查连接是否成功建立
|
||||||
if (!isWsConnected()) {
|
if (!isWsConnected()) {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
setTimeout(() => {
|
||||||
title: "连接服务器失败,请稍后重试",
|
uni.showToast({
|
||||||
icon: "none",
|
title: "连接服务器失败,请稍后重试",
|
||||||
});
|
icon: "none",
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("重新连接WebSocket失败:", error);
|
console.error("重新连接WebSocket失败:", error);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
setTimeout(() => {
|
||||||
title: "连接服务器失败,请稍后重试",
|
uni.showToast({
|
||||||
icon: "none",
|
title: "连接服务器失败,请稍后重试",
|
||||||
});
|
icon: "none",
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user