Showing
4 changed files
with
18 additions
and
35 deletions
| @@ -6,41 +6,34 @@ import { SPHelper } from './SPHelper' | @@ -6,41 +6,34 @@ import { SPHelper } from './SPHelper' | ||
| 6 | import { StringUtils } from './StringUtils' | 6 | import { StringUtils } from './StringUtils' |
| 7 | 7 | ||
| 8 | export class UserDataLocal { | 8 | export class UserDataLocal { |
| 9 | - public static userId='' | ||
| 10 | - public static userType='' | ||
| 11 | - public static token='' | ||
| 12 | - public static userName='' | ||
| 13 | - | ||
| 14 | - public static userHeaderUrl='' | ||
| 15 | - public static userLevel = -1 | ||
| 16 | - public static userLevelHeaderUrl='' | 9 | + private static userId='' |
| 10 | + private static userType='' | ||
| 11 | + private static userName='' | ||
| 12 | + private static userHeaderUrl='' | ||
| 13 | + private static userLevel = -1 | ||
| 14 | + private static userLevelHeaderUrl='' | ||
| 17 | 15 | ||
| 18 | //先写死 | 16 | //先写死 |
| 19 | static USER_ID="userId" | 17 | static USER_ID="userId" |
| 20 | static USER_Type="userType" | 18 | static USER_Type="userType" |
| 21 | - static USER_JWT_TOKEN="jwtToken" | ||
| 22 | static USER_NAME="userName" | 19 | static USER_NAME="userName" |
| 23 | - | ||
| 24 | static USER_HEADER_URL="userHeaderUrl" | 20 | static USER_HEADER_URL="userHeaderUrl" |
| 25 | static USER_LEVEL="userLevel" | 21 | static USER_LEVEL="userLevel" |
| 26 | static USER_LEVEL_HEADER_URL="userLevelHeaderUrl" | 22 | static USER_LEVEL_HEADER_URL="userLevelHeaderUrl" |
| 27 | - static USER_FOLLOW_OPERATION="user_follow_operation" | ||
| 28 | - | ||
| 29 | - //刷新token 用到 | ||
| 30 | - static USER_REFRESH_TOKEN="refreshToken" | ||
| 31 | 23 | ||
| 24 | + static USER_FOLLOW_OPERATION="user_follow_operation" | ||
| 32 | 25 | ||
| 33 | /** | 26 | /** |
| 34 | * 清除 本地用户数据 | 27 | * 清除 本地用户数据 |
| 35 | */ | 28 | */ |
| 36 | public static clearUserData(){ | 29 | public static clearUserData(){ |
| 37 | - SPHelper.default.deleteSync(UserDataLocal.USER_ID) | ||
| 38 | - SPHelper.default.deleteSync(UserDataLocal.USER_Type) | ||
| 39 | - SPHelper.default.deleteSync(UserDataLocal.USER_JWT_TOKEN) //待确认 | ||
| 40 | - SPHelper.default.deleteSync(UserDataLocal.USER_NAME) | ||
| 41 | - SPHelper.default.deleteSync(UserDataLocal.USER_HEADER_URL) | ||
| 42 | - SPHelper.default.deleteSync(UserDataLocal.USER_LEVEL) | ||
| 43 | - SPHelper.default.deleteSync(UserDataLocal.USER_LEVEL_HEADER_URL) | 30 | + UserDataLocal.userId='' |
| 31 | + UserDataLocal.userType='' | ||
| 32 | + UserDataLocal.userName='' | ||
| 33 | + | ||
| 34 | + UserDataLocal.userHeaderUrl='' | ||
| 35 | + UserDataLocal.userLevel = -1 | ||
| 36 | + UserDataLocal.userLevelHeaderUrl='' | ||
| 44 | } | 37 | } |
| 45 | 38 | ||
| 46 | public static getUserId() { | 39 | public static getUserId() { |
| @@ -59,17 +52,6 @@ export class UserDataLocal { | @@ -59,17 +52,6 @@ export class UserDataLocal { | ||
| 59 | return UserDataLocal.userType; | 52 | return UserDataLocal.userType; |
| 60 | } | 53 | } |
| 61 | 54 | ||
| 62 | - private static getXToken() { | ||
| 63 | - if(StringUtils.isNotEmpty(UserDataLocal.token)){ | ||
| 64 | - return UserDataLocal.token | ||
| 65 | - } | ||
| 66 | - UserDataLocal.token = SPHelper.default.getSync(UserDataLocal.USER_JWT_TOKEN,"") as string | ||
| 67 | - if(StringUtils.isNotEmpty(UserDataLocal.token)) { | ||
| 68 | - return UserDataLocal.token | ||
| 69 | - } | ||
| 70 | - return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc'; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | public static getUserName() { | 55 | public static getUserName() { |
| 74 | if(StringUtils.isNotEmpty(UserDataLocal.userName)){ | 56 | if(StringUtils.isNotEmpty(UserDataLocal.userName)){ |
| 75 | return UserDataLocal.userName | 57 | return UserDataLocal.userName |
| @@ -118,4 +100,5 @@ export class UserDataLocal { | @@ -118,4 +100,5 @@ export class UserDataLocal { | ||
| 118 | public static setUserLevelHeaderUrl(url:string) { | 100 | public static setUserLevelHeaderUrl(url:string) { |
| 119 | SPHelper.default.save(UserDataLocal.USER_LEVEL_HEADER_URL, url) | 101 | SPHelper.default.save(UserDataLocal.USER_LEVEL_HEADER_URL, url) |
| 120 | } | 102 | } |
| 103 | + | ||
| 121 | } | 104 | } |
| @@ -36,7 +36,7 @@ export struct SearchResultComponent { | @@ -36,7 +36,7 @@ export struct SearchResultComponent { | ||
| 36 | getSuggestData() { | 36 | getSuggestData() { |
| 37 | this.isLoading = true | 37 | this.isLoading = true |
| 38 | 38 | ||
| 39 | - let request: SearchSuggestRequestItem = new SearchSuggestRequestItem(2, "", "", HttpUrlUtils.getImei(), UserDataLocal.userId, 8, "") | 39 | + let request: SearchSuggestRequestItem = new SearchSuggestRequestItem(2, "", "", HttpUrlUtils.getImei(), UserDataLocal.getUserId(), 8, "") |
| 40 | 40 | ||
| 41 | SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => { | 41 | SearcherAboutDataModel.getSearchSuggestData(request, getContext(this)).then((value) => { |
| 42 | value.forEach((item) => { | 42 | value.forEach((item) => { |
| @@ -7,7 +7,7 @@ export class LogoutModel{ | @@ -7,7 +7,7 @@ export class LogoutModel{ | ||
| 7 | 7 | ||
| 8 | requestLogout(){ | 8 | requestLogout(){ |
| 9 | let bean: Record<string, string> = {}; | 9 | let bean: Record<string, string> = {}; |
| 10 | - bean['refreshToken'] = UserDataLocal.USER_REFRESH_TOKEN | 10 | + bean['refreshToken'] = HttpUrlUtils.getRefreshToken() |
| 11 | bean['refreshToken'] = 'ddrqreeee' | 11 | bean['refreshToken'] = 'ddrqreeee' |
| 12 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 12 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 13 | return new Promise<string>((success, fail) => { | 13 | return new Promise<string>((success, fail) => { |
| @@ -19,7 +19,7 @@ const TAG = "SearcherAboutDataModel" | @@ -19,7 +19,7 @@ const TAG = "SearcherAboutDataModel" | ||
| 19 | class SearcherAboutDataModel{ | 19 | class SearcherAboutDataModel{ |
| 20 | private static instance: SearcherAboutDataModel; | 20 | private static instance: SearcherAboutDataModel; |
| 21 | public searchHistoryData:SearchHistoryItem[] = [] | 21 | public searchHistoryData:SearchHistoryItem[] = [] |
| 22 | - public SEARCH_HISTORY_KEY:string = "SEARCH_HISTORY_KEY" + UserDataLocal.userId | 22 | + public SEARCH_HISTORY_KEY:string = "SEARCH_HISTORY_KEY" + UserDataLocal.getUserId() |
| 23 | 23 | ||
| 24 | private constructor() { } | 24 | private constructor() { } |
| 25 | 25 |
-
Please register or login to post a comment