Commit c23a2806 by liimin

更新ws服务路径

1 parent 6f9f6034
......@@ -14,9 +14,8 @@ module.exports = {
TOKEN_NAME: 'glsk-oss',
PROTOCAL: 'http',
SERVER: '192.168.1.129',
SOCKET_PORT: '8080',
SERVER: 'app-admin-server.test.glsx.com.cn',
SOCKET_PORT: '9081',
HTTP_PORT: '3000',
FILE_UPLOAD_URL: 'file/upload',
}
......@@ -13,8 +13,8 @@ export class Ws {
onMessage
ws
constructor() {
this.wsAddress = `${config.PROTOCAL}://${config.SERVER}:${config.SOCKET_PORT}`
this.loginAddress = `${config.PROTOCAL}://${config.SERVER}:${config.HTTP_PORT}/login`
this.wsAddress = `${config.PROTOCAL}://${config.SERVER}`
this.loginAddress = `${config.PROTOCAL}://${config.SERVER}/login`
}
async connect() {
const { code, data, ...o } = await this.login()
......@@ -22,8 +22,9 @@ export class Ws {
this.deviceId = data.id
this.token = data.token
this.ws = io(this.wsAddress, {
path:'/websocket/',
auth: { token: this.token, deviceId: this.deviceId },
transports: ['websocket'],
transports: ['websocket'],
timeout: 5000
})
this.subscribe()
......@@ -36,7 +37,7 @@ export class Ws {
// const userInfo = uni.$storage.get('userInfo')
// ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
if (!sysInfo?.deviceId) return uni.$logger.local.error('未获取到系统设备信息')
// sysInfo.deviceId='sn123456'
sysInfo.deviceId='4DF8801064461802495A2452CCD04EE4'
// const { name: user, phone: mobile, merchantName } = userInfo
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify({deviceId:sysInfo.deviceId})}========`)
return new Promise((resolve, reject) => {
......@@ -81,6 +82,7 @@ export class Ws {
})
}
send(data, type = WsTyps.MessageTypes.Private) {
console.log(data)
this.ws.emit(type, { device_id: this.deviceId, ...data })
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!