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
yangchenggong1_wd
2024-04-29 14:08:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2dda6e4179c1f8bea55ef48ef691e67e988175e1
2dda6e41
1 parent
149ce3dc
desc:历史搜索 关联用户
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
10 deletions
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchHotsComponent.ets
sight_harmony/features/wdComponent/src/main/ets/model/SearcherAboutDataModel.ets
sight_harmony/features/wdComponent/src/main/resources/base/media/search_hots_mark1.png
sight_harmony/features/wdComponent/src/main/resources/base/media/search_hots_mark2.png
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginViewModel.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchComponent.ets
View file @
2dda6e4
...
...
@@ -34,6 +34,8 @@ export struct SearchComponent {
aboutToAppear() {
//获取提示滚动
this.getSearchHint()
//清除缓存
SearcherAboutDataModel.searchHistoryData = []
//获取搜索历史
this.getSearchHistoryData()
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchHotsComponent.ets
View file @
2dda6e4
...
...
@@ -80,7 +80,7 @@ export struct SearchHotsComponent{
.fontWeight('400lpx')
.lineHeight('42lpx')
}.layoutWeight(1)
if(item.mark
!=0
){
if(item.mark
===1 || item.mark===2
){
Image(item.mark===1?$r('app.media.search_hots_mark1'):$r('app.media.search_hots_mark2'))
.width('42lpx')
.height('31lpx')
...
...
sight_harmony/features/wdComponent/src/main/ets/model/SearcherAboutDataModel.ets
View file @
2dda6e4
import { Logger, SPHelper, UserDataLocal } from 'wdKit';
import { Logger, SPHelper,
StringUtils,
UserDataLocal } from 'wdKit';
import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork';
import { SearchHistoryItem } from '../viewmodel/SearchHistoryItem';
import { SearchHotContentItem } from '../viewmodel/SearchHotContentItem';
...
...
@@ -18,7 +18,7 @@ const TAG = "SearcherAboutDataModel"
class SearcherAboutDataModel{
private static instance: SearcherAboutDataModel;
public searchHistoryData:SearchHistoryItem[] = []
public SEARCH_HISTORY_KEY:string = "SEARCH_HISTORY_KEY"
+ UserDataLocal.getUserId()
public SEARCH_HISTORY_KEY:string = "SEARCH_HISTORY_KEY"
private constructor() { }
...
...
@@ -37,7 +37,7 @@ class SearcherAboutDataModel{
* 插入搜索记录(单个)
*/
public async putSearchHistoryData(content:string){
let history = SPHelper.default.getSync(this.
SEARCH_HISTORY_KEY
,"[]") as string
let history = SPHelper.default.getSync(this.
generationSearchKey()
,"[]") as string
this.searchHistoryData = JSON.parse(history)
this.searchHistoryData.forEach((element,index) => {
if (element.searchContent == content) {
...
...
@@ -45,14 +45,14 @@ class SearcherAboutDataModel{
}
});
this.searchHistoryData.splice(0,0,new SearchHistoryItem(content))
await SPHelper.default.saveSync(this.
SEARCH_HISTORY_KEY
, JSON.stringify(this.searchHistoryData));
await SPHelper.default.saveSync(this.
generationSearchKey()
, JSON.stringify(this.searchHistoryData));
}
/**
* 删除搜索记录(所有)
*/
public async delSearchHistoryData(){
SPHelper.default.deleteSync(this.
SEARCH_HISTORY_KEY
)
SPHelper.default.deleteSync(this.
generationSearchKey()
)
this.searchHistoryData = []
}
/**
...
...
@@ -62,11 +62,11 @@ class SearcherAboutDataModel{
if(this.searchHistoryData!=null && this.searchHistoryData.length>0){
this.searchHistoryData.splice(index,1)
}else{
let history = SPHelper.default.getSync(this.
SEARCH_HISTORY_KEY
,"[]") as string
let history = SPHelper.default.getSync(this.
generationSearchKey()
,"[]") as string
this.searchHistoryData = JSON.parse(history)
this.searchHistoryData.splice(index,1)
}
SPHelper.default.saveSync(this.
SEARCH_HISTORY_KEY
, JSON.stringify(this.searchHistoryData))
SPHelper.default.saveSync(this.
generationSearchKey()
, JSON.stringify(this.searchHistoryData))
}
/**
...
...
@@ -79,7 +79,7 @@ class SearcherAboutDataModel{
}
return this.searchHistoryData
}
let history = SPHelper.default.getSync(this.
SEARCH_HISTORY_KEY
,"[]") as string
let history = SPHelper.default.getSync(this.
generationSearchKey()
,"[]") as string
this.searchHistoryData = JSON.parse(history)
if(this.searchHistoryData.length>10){
...
...
@@ -91,6 +91,15 @@ class SearcherAboutDataModel{
return this.searchHistoryData
}
public generationSearchKey():string{
let userId = UserDataLocal.getUserId()
if(StringUtils.isEmpty(userId)){
return this.SEARCH_HISTORY_KEY + "_" + "0000111122223333"
}else{
return this.SEARCH_HISTORY_KEY + "_" + userId
}
}
/**
* 首页 搜索提示滚动内容
*/
...
...
sight_harmony/features/wdComponent/src/main/resources/base/media/search_hots_mark1.png
View file @
2dda6e4
902 Bytes
|
W:
|
H:
2.33 KB
|
W:
|
H:
2-up
Swipe
Onion skin
sight_harmony/features/wdComponent/src/main/resources/base/media/search_hots_mark2.png
View file @
2dda6e4
863 Bytes
|
W:
|
H:
2.04 KB
|
W:
|
H:
2-up
Swipe
Onion skin
sight_harmony/features/wdLogin/src/main/ets/pages/login/LoginViewModel.ets
View file @
2dda6e4
import { Logger } from 'wdKit/src/main/ets/utils/Logger'
import { LoginModel } from './LoginModel'
import { LoginBean } from './LoginBean'
import { SPHelper, StringUtils } from 'wdKit'
import { SPHelper, StringUtils
, UserDataLocal
} from 'wdKit'
import { CheckVerifyBean } from './CheckVerifyBean'
import cryptoFramework from '@ohos.security.cryptoFramework'
import buffer from '@ohos.buffer'
...
...
@@ -157,6 +157,7 @@ export class LoginViewModel {
SPHelper.default.saveSync(SpConstants.USER_STATUS, '')
SPHelper.default.saveSync(SpConstants.USER_Type, '')
SPHelper.default.saveSync(SpConstants.USER_NAME, '')
UserDataLocal.clearUserData()
success(data)
}).catch((message: string) => {
fail(message)
...
...
Please
register
or
login
to post a comment