执行顺序

This commit is contained in:
魏啾 2024-06-13 13:45:33 +08:00
parent 84b5632d23
commit 4465ddf666
3 changed files with 15 additions and 22 deletions

View File

@ -25,24 +25,22 @@ class webSocketUtils {
// 进入这个页面的时候创建websocket连接【整个页面随时使用】 // 进入这个页面的时候创建websocket连接【整个页面随时使用】
connectSocketInit(data) { connectSocketInit(data) {
this.data = data; this.data = data;
this.socketTask ? this.socketTask.Close() : null
this.socketTask = uni.connectSocket({ this.socketTask = uni.connectSocket({
url: this.url, url: this.url,
success: () => { success: () => {
console.log('正准备建立websocket中...'); console.log('正准备建立websocket中...');
// uni.hideLoading(); // uni.hideLoading();
// 返回实例 // 返回实例
uni.hideLoading()
return this.socketTask; return this.socketTask;
}, },
}); });
this.socketTask.onOpen((res) => { this.socketTask.onOpen((res) => {
uni.hideLoading()
this.connectNum = 1; this.connectNum = 1;
console.log('WebSocket连接正常'); console.log('WebSocket连接正常');
if (this.params) { //是否初始化请求 if (this.params) { //是否初始化请求
this.send(this.params); this.send(this.params);
} }
clearInterval(this.reconnectTimeOut); clearInterval(this.reconnectTimeOut);
clearInterval(this.heartbeatInterval); clearInterval(this.heartbeatInterval);
this.is_open_socket = true; this.is_open_socket = true;

View File

@ -7,7 +7,7 @@ const proxyApi = "/api"
// const proxyApi = 'http://192.168.2.74:9888/cashierService' // 帆哥 // const proxyApi = 'http://192.168.2.74:9888/cashierService' // 帆哥
// const proxyApiwws = 'ws://192.168.2.74:9888/cashierService' // 测试 // const proxyApiwws = 'ws://192.168.2.74:9888/cashierService' // 测试
const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试 const proxyApi = 'https://wxcashiertest.sxczgkj.cn/cashierService' // 测试
const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/cashierService' // 测试 const proxyApiwws = 'wss://wxcashiertest.sxczgkj.cn/netty' // 测试
// #endif // #endif
// #ifdef H5 // #ifdef H5
@ -16,10 +16,10 @@ const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
// #endif // #endif
// #ifdef APP || MP-WEIXIN // #ifdef APP || MP-WEIXIN
// const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上 const baseUrl = debug ? proxyApi : 'https://cashier.sxczgkj.cn/cashierService' // 线上
// const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上 const baseUrlwws = debug ? proxyApiwws : 'wss://cashier.sxczgkj.cn/netty' // 线上
const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上 // const baseUrl = 'https://cashier.sxczgkj.cn/cashierService' // 线上
const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上 // const baseUrlwws = 'wss://cashier.sxczgkj.cn/netty' // 线上
// #endif // #endif
// import VConsole from "./vConsole.js" // import VConsole from "./vConsole.js"

View File

@ -274,17 +274,16 @@
this.countScrollTitle(e.scrollTop); this.countScrollTitle(e.scrollTop);
}, },
onLoad(e) { 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({ uni.reLaunch({
url: '/pages/login/login?types=' + 0 url: '/pages/login/login?types=' + 0
}); });
return false 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) uni.$on('message', this.getMessage)
this.$nextTick(() => { this.$nextTick(() => {
this.countTitleTopNum(); // this.countTitleTopNum(); //
@ -302,14 +301,15 @@
uni.$off('message') uni.$off('message')
}, },
onShow() { onShow() {
if (uni.cache.get('token')) {
this.productqueryShopIdByTableCode() //shop User id
}
}, },
methods: { methods: {
// shopUserid // shopUserid
async productqueryShopIdByTableCode() { async productqueryShopIdByTableCode() {
let res = await this.api.productqueryShopIdByTableCode({ let res = await this.api.productqueryShopIdByTableCode({
code: uni.cache.get('tableCode') code: this.tableCode
}) })
if (res.code == 0) { if (res.code == 0) {
let time = new Date let time = new Date
@ -339,7 +339,6 @@
return false; return false;
} }
} else { } else {
wx.hideLoading()
switch (msg.type) { switch (msg.type) {
case 'sku': // sku case 'sku': // sku
this.$set(this, 'amountcartNumber', msg.amount) this.$set(this, 'amountcartNumber', msg.amount)
@ -407,10 +406,6 @@
} }
}, },
handlemessage() { handlemessage() {
wx.showLoading({
title: '',
})
this.socketTicket ? this.socketTicket.Close() : null //socket this.socketTicket ? this.socketTicket.Close() : null //socket
this.socketTicket = new webSocketUtils(`${uni.conf.baseUrlwws}`, 5000, { this.socketTicket = new webSocketUtils(`${uni.conf.baseUrlwws}`, 5000, {
tableId: uni.cache.get('tableCode'), tableId: uni.cache.get('tableCode'),