[AI Generated]: feat(*): 对接登录token存储、设备列表自动连接及成员管理蓝牙状态实时同步
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { post } from '../../utils/request/index'
|
||||
|
||||
/** 通过 OpenID 登录的用户信息 */
|
||||
interface CheckOpenIdLoginResult {
|
||||
interface UserInfo {
|
||||
id: string
|
||||
userId: string
|
||||
parentUserId: string | null
|
||||
@@ -33,6 +33,12 @@ interface CheckOpenIdLoginResult {
|
||||
connectDeviceInfo: string
|
||||
}
|
||||
|
||||
/** 登录接口 result 结构 */
|
||||
interface CheckOpenIdLoginResult {
|
||||
user: UserInfo | null
|
||||
token: string
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false,
|
||||
@@ -55,11 +61,11 @@ Page({
|
||||
success: ({ code }) => {
|
||||
post<CheckOpenIdLoginResult>('weighingScale/v2/checkOpenIdLogin', { code })
|
||||
.then(({ result }) => {
|
||||
/* 存储用户信息 */
|
||||
wx.setStorageSync('userInfo', result)
|
||||
wx.setStorageSync('token', result.token)
|
||||
wx.setStorageSync('userInfo', result.user)
|
||||
|
||||
/* 上次连接设备不为空对象则直接进首页 */
|
||||
const connectDeviceInfo = result.connectDeviceInfo
|
||||
const connectDeviceInfo = result.user?.connectDeviceInfo
|
||||
if (connectDeviceInfo && connectDeviceInfo !== '{}') {
|
||||
wx.setStorageSync('connectDeviceInfo', JSON.parse(connectDeviceInfo))
|
||||
wx.reLaunch({ url: '/pages/home/home' })
|
||||
|
||||
Reference in New Issue
Block a user