Commit c23a2806 by liimin

更新ws服务路径

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