Commit 3b728edc by 李伟康

```

feat(login): 添加获取用户信息接口并优化登录逻辑

在登录成功后,调用新增的 getUserInfo 接口获取完整用户信息,并将 sessionId 和用户信息分别存储到本地缓存中。同时,在请求头中增加 Authorization 字段用于携带 sessionId,以实现身份认证。
```
1 parent 7f119871
......@@ -2,12 +2,15 @@ import http from '../request/http'
import { env } from '../../env'
module.exports = {
getLoginUrl () {
return http.uni_request({ url: `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=simgle-ww-login&env=${env}`})
return http.uni_request({ url: `https://config-center-backend.glsx.com.cn/glsxAdmin/config?moduleUrl=simgle-ww-login&env=${env}` })
},
getCorpInfo () {
return http.shukeRequest('linkwechat-api/auth/findAgentId')
},
login (data) {
return http.shukeRequest('linkwechat-api/auth/qrLogin', data, 'GET', true)
},
getUserInfo () {
return http.shukeRequest('linkwechat-api/system/user/getInfo', {}, 'GET', true)
}
}
\ No newline at end of file
......@@ -170,6 +170,8 @@ class Request {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json'
}
let { sessionId } = uni.$storage.get()
if (sessionId) header.Authorization = sessionId
return new Promise(resolve => {
uni.getNetworkType({
success (res) {
......@@ -196,6 +198,7 @@ class Request {
resolve(data)
return
}
resolve(data.data)
}
})
......
......@@ -145,12 +145,14 @@ export default {
title: '登录中...',
mask: true
})
const { data, msg, code } = await uni.$api.loginApi.login({
const { data, msg } = await uni.$api.loginApi.login({
authCode
})
uni.hideLoading()
if (data) {
uni.$storage.set('userInfo', data)
uni.$storage.set('sessionId', data.access_token)
const userInfo = await uni.$api.loginApi.getUserInfo()
uni.$storage.set('userInfo',userInfo)
uni.reLaunch({
url: '/pages/equity/index'
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!