增加支付延迟,修复首页公告不显示

This commit is contained in:
YeMingfei666 2025-10-29 10:27:07 +08:00
parent 64b7c90278
commit 16c36577e7
2 changed files with 12 additions and 29 deletions

View File

@ -607,23 +607,6 @@ async function goldPay(data) {
});
}
}
/**
* 异步等待函数随机等待 300-600ms包含边界值
* @returns {Promise<number>} 成功后返回实际等待的毫秒数方便调试或日志记录
*/
function randomWait() {
// 1. 300-600 300 600
const waitTime = Math.floor(Math.random() * (600 - 300 + 1)) + 300;
// 2. Promise waitTime resolve
return new Promise((resolve) => {
setTimeout(() => {
resolve(waitTime); // resolve 便使
}, waitTime);
});
}
//
async function payConfirm() {
const [type, num] = popup.payType.split('-');
@ -653,22 +636,21 @@ async function payConfirm() {
});
}
if (res) {
uni.showLoading()
console.log('等待开始');
const start=Date.now()
await randomWait()
const end=Date.now()
console.log('等待结束');
console.log('等待时间',end-start);
uni.hideLoading()
if (type == 'gold') {
goldPay({
orderId: res.orders.ordersId
});
} else {
payOrder({
orderId: res.orders.ordersId
});
uni.showLoading()
console.log('延迟开始')
setTimeout(()=>{
uni.hideLoading()
console.log('延迟结束')
payOrder({
orderId: res.orders.ordersId
});
},200)
}
} else {
}

View File

@ -165,6 +165,7 @@ onReachBottom(() => {
//
async function getMsg() {
let res = await messageselectMessage();
console.log('res',res)
let arr = [];
let ids = uni.getStorageSync('ids');
res.list.forEach((ele) => {
@ -177,7 +178,7 @@ async function getMsg() {
arr.push(ele);
}
});
datas.noticeList = arr;
datas.noticeList = res.list;
if (arr.length) {
if (ids.length) {
uni.setStorageSync('ids', [...uni.getStorageSync('ids'), datas.noticeList[datas.cloneNum].id]);