From 98ce8b55446563164c6ec629a579f2b942df280b Mon Sep 17 00:00:00 2001 From: wwz <1144797966@qq.com> Date: Wed, 26 Mar 2025 17:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BD=91=E7=BB=9C=E6=B3=A2?= =?UTF-8?q?=E5=8A=A8=E5=8A=A0=E8=BD=BD=E4=B8=AD=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BF=A1=E6=81=AF=E6=89=AB=E7=A0=81=E5=85=85?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 36 + common/js/websocket.js | 26 +- components/Loading.vue | 83 +++ pages/index/components/todaylist.vue | 19 +- pages/index/index.vue | 17 +- pages/index/indexs.vue | 19 +- pages/order/components/orderInfoAfter.vue | 11 +- pages/order/detail.vue | 30 +- pages/product/choosetable.vue | 15 +- pages/product/components/confirmorder.vue | 12 +- pages/product/components/shoppingCartes.vue | 12 +- pages/product/index.vue | 77 +- pages/subscribeto/index.vue | 696 ++++++++++++++++++ .../user/member/components/registermember.vue | 11 +- pages/user/member/index.vue | 56 +- pages/user/user.vue | 1 - stores/order.js | 9 +- stores/user.js | 16 +- 18 files changed, 1018 insertions(+), 128 deletions(-) create mode 100644 components/Loading.vue create mode 100644 pages/subscribeto/index.vue diff --git a/App.vue b/App.vue index f334f06..d37448c 100644 --- a/App.vue +++ b/App.vue @@ -31,6 +31,42 @@ // }, onShow(async () => { + try { + // #ifdef MP-WEIXIN + // 当向小程序后台请求完新版本信息,会进行回调。res: {hasUpdate: true, version: 1.0.0} + const updateManager = uni.getUpdateManager(); + updateManager.onCheckForUpdate((res) => { + if (res.hasUpdate) { // 有更新 + uni.showLoading({ + title: '更新中...' + }); // 开始下载前,显示Loading + } + }); + // 当新版本下载完成,会进行回调 + updateManager.onUpdateReady(() => { + uni.hideLoading(); // 关闭 Loading + uni.showModal({ // 弹确认框(强制更新) + title: '更新提示', + content: '更新完毕,是否重启?', + success: function(res) { + if (res.confirm) { + updateManager.applyUpdate(); // 强制小程序重启并使用新版本。 + } + } + }) + }); + // 当新版本下载失败,会进行回调 + updateManager.onUpdateFailed(() => { + uni.hideLoading(); // 关闭 Loading + uni.showToast({ + title: '更新失败,稍后再试...', + icon: "error" + }); + }); + // #endif + } catch (error) { + //TODO handle the exception + } // #ifndef H5 // try { const storelogin = Storelogin(); diff --git a/common/js/websocket.js b/common/js/websocket.js index ca47168..89c0bdb 100644 --- a/common/js/websocket.js +++ b/common/js/websocket.js @@ -94,12 +94,13 @@ const useWebSocket = (options = {}) => { socketTask.value.onMessage((res) => { receivedMessages.value = JSON.parse(res.data) // receivedMessages.value.push(list); - if (receivedMessages.value == 'ok') { - console.log('心跳响应正常'); - // 心跳正常,重置重连尝试次数 - reconnectAttempts.value = 0; + if (receivedMessages.value == 'ok' || receivedMessages.value.operate_type == 'init') { + console.log('初始化正常,心跳响应正常'); + // 清除重连定时器 clearTimeout(reconnectTimer.value); + reconnectTimer.value = null; } + }); socketTask.value.onClose((res) => { @@ -109,13 +110,13 @@ const useWebSocket = (options = {}) => { clearTimeout(reconnectTimer.value); // 清除重连定时器 if (res.code == '1006') { uni.showToast({ - title: '操作异常,请重新扫码', + title: '网络异常,请重新扫码', icon: 'none' }); autoReconnect.value = false; setTimeout(() => { uni.pro.switchTab('index/index'); - }, 1500) + }, 1000) return false; } if (autoReconnect.value && !isManuallyClosed.value) { @@ -179,7 +180,9 @@ const useWebSocket = (options = {}) => { const handlePong = (res) => { try { let data = JSON.parse(res.data); - if (data.msg === 'ok' && data.msg_id == 'ping_interval') { + if (data.operate_type == "init" || (data.msg === 'ok' && + data.msg_id == + 'ping_interval')) { isPongReceived.value = true; console.log('收到心跳响应,清除超时定时器'); clearTimeout(pongTimer); @@ -252,9 +255,7 @@ const useWebSocket = (options = {}) => { mask: true }) console.log(`尝试第 ${reconnectAttempts.value} 次重连,重连间隔: ${randomizedInterval}ms...`); - setTimeout(() => { - uni.hideLoading(); - }, 1000) + reconnectTimer.value = setTimeout(() => { connect(); }, randomizedInterval); @@ -266,7 +267,10 @@ const useWebSocket = (options = {}) => { }); clearInterval(heartbeatTimer.value); autoReconnect.value = false; - uni.pro.switchTab('index/index'); + setTimeout(() => { + uni.hideLoading(); + uni.pro.switchTab('index/index'); + }, 1000) } }; diff --git a/components/Loading.vue b/components/Loading.vue new file mode 100644 index 0000000..c788fe2 --- /dev/null +++ b/components/Loading.vue @@ -0,0 +1,83 @@ + + + + + \ No newline at end of file diff --git a/pages/index/components/todaylist.vue b/pages/index/components/todaylist.vue index 3054d96..3970cce 100644 --- a/pages/index/components/todaylist.vue +++ b/pages/index/components/todaylist.vue @@ -1,5 +1,5 @@ @@ -139,7 +139,8 @@ reactive, onBeforeUnmount, watch, - getCurrentInstance + getCurrentInstance, + nextTick } from "vue"; import { onLoad, @@ -235,7 +236,7 @@ size: 10, //页容量 status: 'loadmore', name: '1', - list:[] + list: [] }) // 使用 reactive 创建响应式对象 const timeData = ref({}); @@ -287,7 +288,7 @@ formhomelist.status = 'loading'; } } - + } catch (e) {} } // /筛选数据处理 @@ -307,6 +308,10 @@ onLoadhome() } + const orderVIP = ref({ + shopExtendList:'' + }) + // 弹出层处理 const showproductlist = ref(false); // 定义方法 @@ -393,7 +398,9 @@ await proxy.$onLaunched; if (uni.cache.get('shopId')) { showindex.value = 'shopIndex' - await storeuser.actionsAPIuser() + await storeuser.actionsproductqueryProduct() + await nextTick() + orderVIP.value = uni.cache.get('orderVIP') } else { showindex.value = 'index' hometop() diff --git a/pages/index/indexs.vue b/pages/index/indexs.vue index 4e20c41..00cb5c6 100644 --- a/pages/index/indexs.vue +++ b/pages/index/indexs.vue @@ -1,7 +1,7 @@