Commit 3b728edc by 李伟康

```

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

在登录成功后,调用新增的 getUserInfo 接口获取完整用户信息,并将 sessionId 和用户信息分别存储到本地缓存中。同时,在请求头中增加 Authorization 字段用于携带 sessionId,以实现身份认证。
```
1 parent 7f119871
...@@ -2,12 +2,15 @@ import http from '../request/http' ...@@ -2,12 +2,15 @@ import http from '../request/http'
import { env } from '../../env' import { env } from '../../env'
module.exports = { module.exports = {
getLoginUrl () { 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 () { getCorpInfo () {
return http.shukeRequest('linkwechat-api/auth/findAgentId') return http.shukeRequest('linkwechat-api/auth/findAgentId')
}, },
login (data) { login (data) {
return http.shukeRequest('linkwechat-api/auth/qrLogin', data, 'GET', true) 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 \ No newline at end of file
...@@ -170,6 +170,8 @@ class Request { ...@@ -170,6 +170,8 @@ class Request {
'Cache-Control': 'no-cache', 'Cache-Control': 'no-cache',
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
let { sessionId } = uni.$storage.get()
if (sessionId) header.Authorization = sessionId
return new Promise(resolve => { return new Promise(resolve => {
uni.getNetworkType({ uni.getNetworkType({
success (res) { success (res) {
...@@ -196,6 +198,7 @@ class Request { ...@@ -196,6 +198,7 @@ class Request {
resolve(data) resolve(data)
return return
} }
resolve(data.data) resolve(data.data)
} }
}) })
......
...@@ -145,12 +145,14 @@ export default { ...@@ -145,12 +145,14 @@ export default {
title: '登录中...', title: '登录中...',
mask: true mask: true
}) })
const { data, msg, code } = await uni.$api.loginApi.login({ const { data, msg } = await uni.$api.loginApi.login({
authCode authCode
}) })
uni.hideLoading() uni.hideLoading()
if (data) { 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({ uni.reLaunch({
url: '/pages/equity/index' 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!