优惠卷和商品卷

This commit is contained in:
wwz
2025-03-10 16:33:43 +08:00
parent 70edc6756d
commit 5342133cbd
30 changed files with 2820 additions and 3338 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -56,7 +56,15 @@ const useWebSocket = (options = {}) => {
// 连接 WebSocket
const connect = () => {
if (!isNetworkConnected.value) {
uni.showToast({
title: '网络未连接...',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 1000)
console.log('网络未连接,暂不尝试连接 WebSocket');
return;
}
@@ -70,7 +78,7 @@ const useWebSocket = (options = {}) => {
isConnected.value = true;
reconnectAttempts.value = 0;
// 监听初始化成功在开启心跳
// startHeartbeat();
startHeartbeat();
},
fail: () => {
console.error('WebSocket 连接失败,尝试重连');
@@ -104,6 +112,7 @@ const useWebSocket = (options = {}) => {
clearTimeout(reconnectTimer.value); // 清除重连定时器
if (res.code == '1006') {
console.log('服务器正常关闭,停止重连');
uni.navigateBack()
autoReconnect.value = false;
return false;
}
@@ -129,6 +138,13 @@ const useWebSocket = (options = {}) => {
const startHeartbeat = () => {
if (!isNetworkConnected.value) {
console.log('网络未连接,暂停心跳');
uni.showToast({
title: '网络未连接...',
icon: 'none'
})
setTimeout(() => {
uni.navigateBack()
}, 1000)
return;
}
heartbeatTimer.value = setInterval(() => {
@@ -168,6 +184,7 @@ const useWebSocket = (options = {}) => {
// 手动关闭连接
const closeSocket = () => {
isManuallyClosed.value = true;
uni.navigateBack()
closeExistingConnection();
};
@@ -213,6 +230,7 @@ const useWebSocket = (options = {}) => {
title: '重连次数达到上限,停止重连',
icon: 'none'
});
uni.navigateBack()
}
};