执行顺序
This commit is contained in:
parent
84b5632d23
commit
4465ddf666
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue