Commit cc99bb22 by yixinjj

WS改设备号登录

1 parent b3809c29
Showing 1 changed file with 9 additions and 7 deletions
...@@ -19,7 +19,7 @@ export class Ws { ...@@ -19,7 +19,7 @@ export class Ws {
async connect() { async connect() {
const { code, data, ...o } = await this.login() const { code, data, ...o } = await this.login()
if (code == 200) { if (code == 200) {
this.deviceId = data.device_id this.deviceId = data.id
this.token = data.token this.token = data.token
this.ws = io(this.wsAddress, { this.ws = io(this.wsAddress, {
auth: { token: this.token, deviceId: this.deviceId }, auth: { token: this.token, deviceId: this.deviceId },
...@@ -32,15 +32,17 @@ export class Ws { ...@@ -32,15 +32,17 @@ export class Ws {
} }
} }
async login() { async login() {
const userInfo = uni.$storage.get('userInfo') const sysInfo = uni.getSystemInfoSync()
;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574') // const userInfo = uni.$storage.get('userInfo')
if (!userInfo) return uni.$logger.local.error('未获取到系统登录信息') // ;(userInfo.name = '胡悦'), (userInfo.phone = '18754575574')
const { name: user, phone: mobile, merchantName } = userInfo if (!sysInfo?.deviceId) return uni.$logger.local.error('未获取到系统设备信息')
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify({ user, mobile, merchantName })}========`) // sysInfo.deviceId='sn123456'
// const { name: user, phone: mobile, merchantName } = userInfo
uni.$logger.local.info(`========WS,用户登录 ${JSON.stringify({deviceId:sysInfo.deviceId})}========`)
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
url: this.loginAddress, url: this.loginAddress,
data: { user, mobile }, data: { sn: sysInfo.deviceId },
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
success(response) { success(response) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!