diff --git a/common/js/websocket.js b/common/js/websocket.js index 7100ec3..c9f3680 100644 --- a/common/js/websocket.js +++ b/common/js/websocket.js @@ -25,24 +25,22 @@ class webSocketUtils { // 进入这个页面的时候创建websocket连接【整个页面随时使用】 connectSocketInit(data) { this.data = data; - this.socketTask ? this.socketTask.Close() : null this.socketTask = uni.connectSocket({ url: this.url, success: () => { console.log('正准备建立websocket中...'); // uni.hideLoading(); // 返回实例 - uni.hideLoading() return this.socketTask; }, }); this.socketTask.onOpen((res) => { + uni.hideLoading() this.connectNum = 1; console.log('WebSocket连接正常!'); if (this.params) { //是否初始化请求 this.send(this.params); } - clearInterval(this.reconnectTimeOut); clearInterval(this.heartbeatInterval); this.is_open_socket = true; diff --git a/framework/0-conf.js b/framework/0-conf.js index c1f0aa1..d1efb19 100644 --- a/framework/0-conf.js +++ b/framework/0-conf.js @@ -7,7 +7,7 @@ const proxyApi = "/api" // const proxyApi = 'http://192.168.2.74:9888/cashierService' // 帆哥 // const proxyApiwws = 'ws://192.168.2.74:9888/cashierService' // 测试 const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试 -const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/cashierService' // 测试 +const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试 // #endif // #ifdef H5 @@ -16,10 +16,10 @@ const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService' // #endif // #ifdef APP || MP-WEIXIN -// const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 -// const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 -const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 -const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 +const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 +const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 +// const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 +// const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 // #endif // import VConsole from "./vConsole.js" diff --git a/pages/order_food/order_food.vue b/pages/order_food/order_food.vue index 4f43727..1fbd809 100644 --- a/pages/order_food/order_food.vue +++ b/pages/order_food/order_food.vue @@ -274,17 +274,16 @@ this.countScrollTitle(e.scrollTop); }, onLoad(e) { - if (!uni.cache.get('token') && uni.cache.get('tableCode')) { + if (e.q) { + this.tableCode = this.getQueryString(decodeURIComponent(e.q), 'code') + uni.cache.set('tableCode', this.tableCode) + } + if (!uni.cache.get('token')) { uni.reLaunch({ url: '/pages/login/login?types=' + 0 }); return false } - if (e.q) { - let tableCode = this.getQueryString(decodeURIComponent(e.q), 'code') - uni.cache.set('tableCode', tableCode) - } - this.productqueryShopIdByTableCode() //获取shop User id uni.$on('message', this.getMessage) this.$nextTick(() => { this.countTitleTopNum(); //导航栏 @@ -302,14 +301,15 @@ uni.$off('message') }, onShow() { - - + if (uni.cache.get('token')) { + this.productqueryShopIdByTableCode() //获取shop User id + } }, methods: { // 单独获取他的shopUserid async productqueryShopIdByTableCode() { let res = await this.api.productqueryShopIdByTableCode({ - code: uni.cache.get('tableCode') + code: this.tableCode }) if (res.code == 0) { let time = new Date @@ -339,7 +339,6 @@ return false; } } else { - wx.hideLoading() switch (msg.type) { case 'sku': // sku 数量 this.$set(this, 'amountcartNumber', msg.amount) @@ -407,10 +406,6 @@ } }, handlemessage() { - wx.showLoading({ - title: '', - }) - this.socketTicket ? this.socketTicket.Close() : null //调用前先判断是否有socket正在进行 先关闭后链接 this.socketTicket = new webSocketUtils(`${uni.conf.baseUrlwws}`, 5000, { tableId: uni.cache.get('tableCode'),