Commit 66959f50 by yixinjj

解决发送消息BUG

1 parent 3ab5a6dd
......@@ -26,7 +26,7 @@ class LogCat {
//文件名
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, ''))
let path = new this.File(this.LogPath)
if (!path.exists()) {
......
......@@ -33,11 +33,10 @@ export class Ws {
}
async login() {
const userInfo = uni.$storage.get('userInfo')
userInfo.name='庞丽丽',
userInfo.phone='15598191116'
;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
if (!userInfo) return uni.$logger.local.error('未获取到系统登录信息')
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify(userInfo)}========`)
const { name: user, phone: mobile } = userInfo
const { name: user, phone: mobile, merchantName } = userInfo
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify({ user, mobile, merchantName })}========`)
return new Promise((resolve, reject) => {
uni.request({
url: this.loginAddress,
......@@ -63,7 +62,7 @@ export class Ws {
uni.$logger.local.info(`WebSocket 收到消息 -> ${JSON.stringify(data)}`)
if (data.errorCode && data.errorCode == 907) return this.connect()
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)
}.bind(this)
)
......@@ -80,6 +79,6 @@ export class Ws {
})
}
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 {
}
})
}
work(deviceId, data) {
work(deviceId, data,ws) {
this.ws = ws
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!