Commit 66959f50 by yixinjj

解决发送消息BUG

1 parent 3ab5a6dd
...@@ -26,7 +26,7 @@ class LogCat { ...@@ -26,7 +26,7 @@ class LogCat {
//文件名 //文件名
let fileName = this.LogPath + '/' + date + '.txt' let fileName = this.LogPath + '/' + date + '.txt'
//写入的内容 //写入的内容
let content = `${datetime} [${tag}] : ${serializeIfObject(msg)}\n` let content = `${datetime} [${tag}] : ${msg}\n`
console.log(content.replace(/\n/g, '')) console.log(content.replace(/\n/g, ''))
let path = new this.File(this.LogPath) let path = new this.File(this.LogPath)
if (!path.exists()) { if (!path.exists()) {
......
...@@ -33,11 +33,10 @@ export class Ws { ...@@ -33,11 +33,10 @@ export class Ws {
} }
async login() { async login() {
const userInfo = uni.$storage.get('userInfo') const userInfo = uni.$storage.get('userInfo')
userInfo.name='庞丽丽', ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
userInfo.phone='15598191116'
if (!userInfo) return uni.$logger.local.error('未获取到系统登录信息') if (!userInfo) return uni.$logger.local.error('未获取到系统登录信息')
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify(userInfo)}========`) const { name: user, phone: mobile, merchantName } = userInfo
const { name: user, phone: mobile } = userInfo uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify({ user, mobile, merchantName })}========`)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
url: this.loginAddress, url: this.loginAddress,
...@@ -63,7 +62,7 @@ export class Ws { ...@@ -63,7 +62,7 @@ export class Ws {
uni.$logger.local.info(`WebSocket 收到消息 -> ${JSON.stringify(data)}`) uni.$logger.local.info(`WebSocket 收到消息 -> ${JSON.stringify(data)}`)
if (data.errorCode && data.errorCode == 907) return this.connect() if (data.errorCode && data.errorCode == 907) return this.connect()
const worker = CommandFactory.getInstance().dispatch(data.command) const worker = CommandFactory.getInstance().dispatch(data.command)
worker.work(this.deviceId, data, this.ws) worker.work(this.deviceId, data, this)
this.onMessage && this.onMessage(data) this.onMessage && this.onMessage(data)
}.bind(this) }.bind(this)
) )
...@@ -80,6 +79,6 @@ export class Ws { ...@@ -80,6 +79,6 @@ export class Ws {
}) })
} }
send(data, type = WsTyps.MessageTypes.Private) { send(data, type = WsTyps.MessageTypes.Private) {
// this.ws.emit(type, { device_id: this.deviceId, ...data }) this.ws.emit(type, { device_id: this.deviceId, ...data })
} }
} }
...@@ -35,7 +35,8 @@ export default class LogsWorker { ...@@ -35,7 +35,8 @@ export default class LogsWorker {
} }
}) })
} }
work(deviceId, data) { work(deviceId, data,ws) {
this.ws = ws
this.upload(deviceId, data) this.upload(deviceId, data)
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!