From 554217180e3647b8dd6171283994c051826bb6c9 Mon Sep 17 00:00:00 2001 From: duan <1004387497@qq.com> Date: Thu, 6 Jun 2024 14:55:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=95=BF=E8=BF=9E=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/websocket.js | 8 ++++---- framework/0-conf.js | 10 +++++----- pages/order_detail/order_detail.vue | 16 +++++++++++++--- pages/order_food/order_food.vue | 24 +++++++++++++++++------- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/common/js/websocket.js b/common/js/websocket.js index 894adbb..e222569 100644 --- a/common/js/websocket.js +++ b/common/js/websocket.js @@ -125,10 +125,10 @@ class webSocketUtils { start(data) { console.log('开启心跳检测',data) this.heartbeatInterval = setInterval(() => { - // this.send({ - // data: '心跳检测', - // type: 'jc', - // }); + this.send({ + data: '心跳检测', + type: 'heartbeat', + }); }, this.timeout); } //重新连接 diff --git a/framework/0-conf.js b/framework/0-conf.js index 560a293..eb5f767 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -16,12 +16,12 @@ const baseUrl = debug ? proxyApi : "https://wxcashiertest.sxczgkj.cn/cashierServ const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService' // #endif // #ifdef APP || MP-WEIXIN -const baseUrl = 'https://cashier.sxczgkj.cn/cashierService'// 线上 -const baseUrlwws = 'wss://cashier.sxczgkj.cn/cashierService' // 线上 +// const baseUrl = 'https://cashier.sxczgkj.cn/cashierService'// 线上 +// const baseUrlwws = 'wss://cashier.sxczgkj.cn/cashierService' // 线上 // const baseUrl = 'http://192.168.2.42:9888/cashierService'// 测试-w -// const baseUrlwws ='wss://192.168.2.42:9999/cashierService' // 测试-w -// const baseUrl = 'https://wxcashiertest.sxczgkj.cn/cashierService'// 测试 -// const baseUrlwws ='wss://wxcashiertest.sxczgkj.cn/cashierService' // 测试 +// const baseUrlwws ='wss://192.168.2.42:9999/netty' // 测试-w +const baseUrl = 'https://wxcashiertest.sxczgkj.cn/cashierService'// 测试 +const baseUrlwws ='wss://wxcashiertest.sxczgkj.cn/cashierService' // 测试 // #endif diff --git a/pages/order_detail/order_detail.vue b/pages/order_detail/order_detail.vue index 2664ccb..5752327 100644 --- a/pages/order_detail/order_detail.vue +++ b/pages/order_detail/order_detail.vue @@ -300,10 +300,20 @@ } }, handlemessage() { + console.log(this.socketTicket,'detail页面') this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接 - this.socketTicket = new webSocketUtils( - `${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`, - 5000) + // this.socketTicket = new webSocketUtils( + // `${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`, + // 5000) + + this.socketTicket = new webSocketUtils( + `${uni.conf.baseUrlwws}`, + 5000, { + tableId: uni.cache.get('tableCode'), + shopId: uni.cache.get('shopUser'), + userId: uni.cache.get('userInfo').id, + "type": "connect", + }) }, // 数据处理 diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index e638248..17f697a 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -60,7 +60,8 @@ - + @@ -310,6 +311,7 @@ // // ...这里写你的业务逻辑 // } // }); + // setTimeout() setTimeout(() => { console.log('调试1') if (uni.cache.get('token') && uni.cache.get('tableCode')) { @@ -328,10 +330,10 @@ console.log(time, '时间戳') uni.cache.set('shopUser', res.data) this.handlemessage() - }else{ - setTimeout(()=>{ + } else { + setTimeout(() => { uni.pro.switchTab('index/index') - },1000) + }, 1000) } // try { // if (res.data) { @@ -428,10 +430,17 @@ }, handlemessage() { // this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接 + // this.socketTicket = new webSocketUtils( + // `${uni.conf.baseUrlwws}/websocket/table?tableId=${uni.cache.get('tableCode')}&shopId=${uni.cache.get('shopUser')}&userId=${uni.cache.get('userInfo').id}`, + // 5000) this.socketTicket = new webSocketUtils( - `${uni.conf.baseUrlwws}/websocket/table?tableId=${uni.cache.get('tableCode')}&shopId=${uni.cache.get('shopUser')}&userId=${uni.cache.get('userInfo').id}`, - // `${uni.conf.baseUrlwws}/websocket/table/${uni.cache.get('tableCode')}/${uni.cache.get('shopUser')}/${uni.cache.get('userInfo').id}`, - 5000) + `${uni.conf.baseUrlwws}`, + 5000, { + tableId: uni.cache.get('tableCode'), + shopId: uni.cache.get('shopUser'), + userId: uni.cache.get('userInfo').id, + "type": "connect", + }) }, // 数据处理 socketSendMsg(data) { @@ -488,6 +497,7 @@ }, async cartadd(item, index, index1, a, b, guge) { //列表添加 console.log(item, index, index1, a, b, guge) + if (guge == '单规格') { //没有规格为空 this.specifications.duoguge = '' this.skuidname = []