Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
shishuangxi
2024-03-20 13:17:43 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
46d7313aa52b5beda141da70f0a1ce3b978cbfbf
46d7313a
1 parent
f31c0468
头信息添加登录信息
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
6 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginViewModel.ets
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
46d7313
import HashMap from '@ohos.util.HashMap'
import { ConfigConstants } from 'wdConstant'
import { DateTimeUtils, Logger } from 'wdKit'
import { DateTimeUtils, Logger
, SPHelper
} from 'wdKit'
/**
* 网络请求业务侧工具类
...
...
@@ -68,6 +68,9 @@ export class HttpUrlUtils {
static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo";
private static hostUrl: string = HttpUrlUtils.HOST_UAT;
private static userId=''
private static userType=''
private static token=''
static getCommonHeaders(): HashMap<string, string> {
let headers: HashMap<string, string> = new HashMap<string, string>()
...
...
@@ -80,7 +83,9 @@ export class HttpUrlUtils {
headers.set('timestamp', HttpUrlUtils.getTimestamp())
headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken())
headers.set('device_id', HttpUrlUtils.getDeviceId())
// headers.set('cookie', 'RMRB-X-TOKEN=eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc')
if(HttpUrlUtils.token!=''){
headers.set('cookie', 'RMRB-X-TOKEN='+HttpUrlUtils.token)
}
headers.set('build_version', HttpUrlUtils.getVersion())
headers.set('adcode', HttpUrlUtils.getAdCode())
headers.set('os_version', HttpUrlUtils.getOsVersion())
...
...
@@ -221,11 +226,11 @@ export class HttpUrlUtils {
private static getUserId() {
// TODO 对接登录
return
'459776297474949'
;
return
HttpUrlUtils.userId
;
}
private static getUserType() {
return
'2'
;
return
HttpUrlUtils.userType
;
}
static getVerifyCodeUrl() {
...
...
@@ -242,4 +247,16 @@ export class HttpUrlUtils {
let url = HttpUrlUtils.hostUrl + "/api/rmrb-user-center/auth/zh/c/checkVerifyCode";
return url;
}
public static setUserId(userId:string){
HttpUrlUtils.userId=userId;
}
public static setUserType(userType:string){
HttpUrlUtils.userType=userType;
}
public static setUserToken(token:string){
HttpUrlUtils.token=token;
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginViewModel.ets
View file @
46d7313
...
...
@@ -8,6 +8,7 @@ import buffer from '@ohos.buffer'
import {
SpConstants
} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants'
import { HttpUrlUtils } from 'wdNetwork/src/main/ets/http/HttpUrlUtils'
const TAG = "LoginViewModel"
...
...
@@ -42,7 +43,9 @@ export class LoginViewModel {
SPHelper.default.save(SpConstants.USER_STATUS, data.status)
SPHelper.default.save(SpConstants.USER_Type, data.userType)
SPHelper.default.save(SpConstants.USER_NAME, data.userName)
HttpUrlUtils.setUserId(data.id+"")
HttpUrlUtils.setUserType(data.userType+"")
HttpUrlUtils.setUserToken(data.jwtToken)
success(data)
}).catch(() => {
fail()
...
...
@@ -64,7 +67,9 @@ export class LoginViewModel {
SPHelper.default.save(SpConstants.USER_STATUS, data.status)
SPHelper.default.save(SpConstants.USER_Type, data.userType)
SPHelper.default.save(SpConstants.USER_NAME, data.userName)
HttpUrlUtils.setUserId(data.id+"")
HttpUrlUtils.setUserType(data.userType+"")
HttpUrlUtils.setUserToken(data.jwtToken)
success(data)
}).catch((value: string) => {
fail(value)
...
...
Please
register
or
login
to post a comment