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-18 10:52:35 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aac1a9ea2e56bb510a565d7aa9e57b220040dac4
aac1a9ea
1 parent
229ebc06
desc:搜索跳转 和 登录注销处理
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
233 additions
and
256 deletions
sight_harmony/commons/wdKit/src/main/ets/utils/SPHelper.ets
sight_harmony/commons/wdRouter/src/main/ets/router/WDRouterPage.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/MinePagePersonFunctionUI.ets
sight_harmony/features/wdComponent/src/main/ets/components/mine/MinePageUserSimpleInfoUI.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/MinePageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
sight_harmony/features/wdComponent/src/main/ets/pages/MineHomePage.ets
sight_harmony/features/wdComponent/src/main/ets/pages/OtherNormalUserHomePage.ets
sight_harmony/features/wdComponent/src/main/ets/pages/SearchCreatorPage.ets
sight_harmony/features/wdComponent/src/main/resources/base/profile/main_pages.json
sight_harmony/commons/wdKit/src/main/ets/utils/SPHelper.ets
View file @
aac1a9e
...
...
@@ -101,4 +101,9 @@ export class SPHelper {
// preferences.clearSync()
// preferences.flush()
// }
public getPreferences(){
let preferences = data_preferences.getPreferences(SPHelper.context, SPHelper.spFilename);
return preferences;
}
}
\ No newline at end of file
...
...
sight_harmony/commons/wdRouter/src/main/ets/router/WDRouterPage.ets
View file @
aac1a9e
...
...
@@ -97,4 +97,6 @@ export class WDRouterPage {
static broadcastPage = new WDRouterPage("phone", "ets/pages/broadcast/BroadcastPage");
//搜索主页
static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage");
//搜索人民号主页
static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage");
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/mine/MinePagePersonFunctionUI.ets
View file @
aac1a9e
import { WDRouterRule, WDRouterPage } from 'wdRouter'
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
import router from '@ohos.router'
@Component
export default struct MinePagePersonFunctionUI {
@Link personalData:MinePagePersonalFunctionsItem[]
@Prop isLogin:boolean
@Consume('isLogin')@Watch('loginChange') loginState:Record<string,string>
loginChange(){
if(this.loginState){
this.isLogin=true
}else{
this.isLogin=false
}
}
build() {
Grid(){
...
...
sight_harmony/features/wdComponent/src/main/ets/components/mine/MinePageUserSimpleInfoUI.ets
View file @
aac1a9e
import { Logger, UserDataLocal } from 'wdKit'
import { Logger,
StringUtils,
UserDataLocal } from 'wdKit'
import { WDRouterPage, WDRouterRule } from 'wdRouter'
import MinePageDatasModel from '../../model/MinePageDatasModel'
const TAG = "MinePageUserSimpleInfoUI"
...
...
@@ -12,20 +12,13 @@ export default struct MinePageUserSimpleInfoUI {
@State levelHead:string = ""
@State levelId:number = 0
@Consume('isLogin') @Watch('loginChange') loginState:Record<string,string>
loginChange(){
Logger.debug("isLogin",'MinePageUserSimpleInfoUI')
if(this.loginState){
this.isLogin=true
}else {
this.isLogin=false
}
}
loginStateChange(){
if(this.isLogin){
this.getUserInfo()
this.getUserLevel()
}else{
this.headPhotoUrl = ""
this.levelHead = ""
}
}
...
...
@@ -33,17 +26,20 @@ export default struct MinePageUserSimpleInfoUI {
Row(){
//头像
Stack(){
Image(this.headPhotoUrl)
Image(this.headPhotoUrl
==""?$r('app.media.default_head'):this.headPhotoUrl
)
.alt($r('app.media.default_head'))
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
if(StringUtils.isNotEmpty(this.levelHead)){
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
.borderRadius(50)
}
}.width('130lpx')
.height('130lpx')
.alignContent(Alignment.Center)
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/MinePageComponent.ets
View file @
aac1a9e
...
...
@@ -4,11 +4,10 @@ import MinePageMoreFunctionModel from '../../viewmodel/MinePageMoreFunctionModel
import MinePageDatasModel from '../../model/MinePageDatasModel'
import MinePageUserSimpleInfoUI from '../mine/MinePageUserSimpleInfoUI'
import MinePagePersonFunctionUI from '../mine/MinePagePersonFunctionUI'
import MinePageCardUI from '../mine/MinePageCardUI'
import MinePageCreatorFunctionUI from '../mine/MinePageCreatorFunctionUI'
import MinePageMoreFunctionUI from '../mine/MinePageMoreFunctionUI'
import { SPHelper, StringUtils } from 'wdKit'
import { SpConstants } from 'wdConstant'
import dataPreferences from '@ohos.data.preferences';
const TAG = 'MinePageComponent';
...
...
@@ -24,12 +23,29 @@ export struct MinePageComponent {
@State creatorData:MinePageCreatorFunctionsItem[] = []
@State moreData:MinePageMoreFunctionModel[] = []
scroller: Scroller = new Scroller()
preferences: dataPreferences.Preferences | null = null;
aboutToAppear(){
this.getUserLogin()
this.getFunctionData()
this.addLoginStatusObserver()
}
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
let observer = (key: string) => {
if(key == SpConstants.USER_ID){
if(StringUtils.isEmpty(SPHelper.default.getSync(SpConstants.USER_ID,""))){
this.isLogin = false
}else {
this.isLogin = true
}
}
}
this.preferences.on('change', observer);
}
getFunctionData(){
//个人功能数据
this.personalData = MinePageDatasModel.getPersonalFunctionsData()
...
...
sight_harmony/features/wdComponent/src/main/ets/components/search/SearchResultContentComponent.ets
View file @
aac1a9e
...
...
@@ -4,6 +4,7 @@ import { ContentDTO,
import { LiveInfoDTO } from 'wdBean/src/main/ets/bean/detail/LiveInfoDTO'
import { VoiceInfoDTO } from 'wdBean/src/main/ets/bean/detail/VoiceInfoDTO'
import { LazyDataSource, StringUtils, ToastUtils } from 'wdKit/Index'
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { CreatorDetailRequestItem } from '../../viewmodel/CreatorDetailRequestItem'
import { SearchResultContentData } from '../../viewmodel/SearchResultContentData'
...
...
@@ -20,9 +21,8 @@ export struct SearchResultContentComponent{
@State searchType:string = ""
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State data_rmh: SearchRmhDescription[] = []
@State count:number =
0
;
@State count:number =
-1
;
@State isLoading:boolean = false
@State isLoading2:boolean = false
@State hasMore:boolean = true
curPageNum:number = 1;
...
...
@@ -80,6 +80,7 @@ export struct SearchResultContentComponent{
}).catch((err:Error)=>{
console.log(TAG,JSON.stringify(err))
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
}
...
...
@@ -155,7 +156,7 @@ export struct SearchResultContentComponent{
vImageUrl: "",
screenType: "",
source: StringUtils.isEmpty(value.data.creatorName) ? value.data.sourceName : value.data.creatorName,
objectId:
""
,
objectId:
value.data.id
,
objectType: value.data.type,
channelId: value.data.channelId,
relId: value.data.relId,
...
...
@@ -196,6 +197,7 @@ export struct SearchResultContentComponent{
}).catch((err:Error)=>{
console.log(TAG,"请求失败")
this.isLoading = false
this.count = this.count===-1?0:this.count
})
}
...
...
@@ -235,16 +237,24 @@ export struct SearchResultContentComponent{
})
ListItem(){
Text("查看更多")
.height('180lpx')
.textAlign(TextAlign.Center)
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.fontColor($r('app.color.color_9E9E9E'))
.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
Column(){
Text("查看更多")
.width('19lpx')
.fontSize('19lpx')
.fontWeight('400lpx')
.lineHeight('27lpx')
.fontColor($r('app.color.color_9E9E9E'))
}.borderRadius({topLeft:'4lpx',bottomLeft:'4lpx'})
.height('180lpx')
.width('77lpx')
.backgroundColor($r('app.color.color_EDEDED'))
.justifyContent(FlexAlign.Center)
}.height('100%')
.margin({left:'23lpx'})
.onClick(()=>{
WDRouterRule.jumpWithPage(WDRouterPage.searchCreatorPage)
})
}
.cachedCount(6)
.edgeEffect(EdgeEffect.Spring)
...
...
@@ -252,14 +262,6 @@ export struct SearchResultContentComponent{
.listDirection(Axis.Horizontal)
.width('100%')
.height('219lpx')
.onReachEnd(()=>{
if(!this.isLoading2){
this.isLoading2 = true
//进入更多关注页
ToastUtils.shortToast("进入更多关注页")
}
})
Divider()
.width('100%')
...
...
sight_harmony/features/wdComponent/src/main/ets/pages/MineHomePage.ets
View file @
aac1a9e
...
...
@@ -2,7 +2,6 @@ import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { CardParser } from '../components/CardParser';
import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
...
...
@@ -53,100 +52,100 @@ struct MineHomePage {
Scroll() {
Column() {
//用户信息区域
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Auto)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
}.onClick(()=>{
let params: Params = {
pageID: "531267787833221"//sit 测试用 512157124138245
}
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
}).width('135lpx')
.height('135lpx')
Column() {
Row() {
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
.fontSize('19lpx')
.width('96lpx')
.height('35lpx')
.margin({ left: '10lpx' })
Blank()
}.width('507lpx')
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('100lpx')
.height('100lpx')
.objectFit(ImageFit.Auto)
.borderRadius(50)
Image(this.levelHead)
.width('130lpx')
.height('130lpx')
.objectFit(ImageFit.Cover)
}.onClick(()=>{
let params: Params = {
pageID: "531267787833221"//sit 测试用 512157124138245
}
WDRouterRule.jumpWithPage(WDRouterPage.otherNormalUserHomePagePage,params)
}).width('135lpx')
.height('135lpx')
Column() {
Row() {
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
Text(`等级${this.levelId}`)
.textAlign(TextAlign.Center)
.fontColor($r('app.color.color_ED2800'))
.backgroundColor($r('app.color.white'))
.fontSize('19lpx')
.width('96lpx')
.height('35lpx')
.margin({ left: '10lpx' })
Blank()
}.width('507lpx')
Row() {
Row() {
Row() {
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
}
.margin({ right: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.commentNum}`)
.textStyle()
Text("评论")
.textStyle2()
}.margin({ right: '15lpx', left: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.attentionNum}`)
.textStyle()
Text("关注")
.textStyle2()
}.margin({ left: '15lpx' })
}.margin({ top: '23lpx' })
}.alignItems(HorizontalAlign.Start)
.margin({ left: '32lpx' })
}
.onAreaChange((oldValue: Area, newValue: Area) => {
if (this.firstPositionY === 0) {
this.firstPositionY = newValue.globalPosition.y as number
}else{
let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3)
if(persent > 1){
persent = 1
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
}
this.tileOpacity = persent
.margin({ right: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.commentNum}`)
.textStyle()
Text("评论")
.textStyle2()
}.margin({ right: '15lpx', left: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Row() {
Text(`${this.attentionNum}`)
.textStyle()
Text("关注")
.textStyle2()
}.margin({ left: '15lpx' })
}.margin({ top: '23lpx' })
}.alignItems(HorizontalAlign.Start)
.margin({ left: '32lpx' })
}
.onAreaChange((oldValue: Area, newValue: Area) => {
if (this.firstPositionY === 0) {
this.firstPositionY = newValue.globalPosition.y as number
}else{
let persent = (this.firstPositionY - Number(newValue.globalPosition.y)) / (this.firstPositionY * 0.3)
if(persent > 1){
persent = 1
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
this.tileOpacity = persent
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
//用户简介区域
Column() {
Row() {
...
...
@@ -183,46 +182,21 @@ struct MineHomePage {
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
Column(){
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.alignItems(HorizontalAlign.Start)
.width('100%')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0})
}
TabContent() {
HomePageBottomComponent({style:1})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight(0)
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomComponent({style:0})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
HomePageBottomComponent({style:1})
}.tabBar(this.TabBuilder(1,"关注"))
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
...
...
@@ -232,8 +206,8 @@ struct MineHomePage {
}
}.width('100%')
.layoutWeight(1)
}
}
@Builder MineHomeTitleTransparent() {
RelativeContainer() {
//标题栏目
...
...
@@ -291,35 +265,35 @@ struct MineHomePage {
.onClick(() => {
router.back()
})
Image(`${this.headPhotoUrl}`)
.alt($r('app.media.default_head'))
.width('60lpx')
.height('60lpx')
.objectFit(ImageFit.Auto)
.id("head_icon")
.borderRadius(50)
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "back_icon", align: HorizontalAlign.End }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
Text(`${this.userName}`)
.height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "head_icon", align: HorizontalAlign.End }
})
.margin({ left: '12lpx' })
Image(`${this.headPhotoUrl}`)
.alt($r('app.media.default_head'))
.width('60lpx')
.height('60lpx')
.objectFit(ImageFit.Auto)
.id("head_icon")
.borderRadius(50)
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "back_icon", align: HorizontalAlign.End }
})
.margin({ left: '31lpx' })
.onClick(() => {
router.back()
})
Text(`${this.userName}`)
.height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "head_icon", align: HorizontalAlign.End }
})
.margin({ left: '12lpx' })
Text("编辑资料")
.height('42lpx')
...
...
@@ -368,9 +342,9 @@ struct MineHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
}
/**
...
...
sight_harmony/features/wdComponent/src/main/ets/pages/OtherNormalUserHomePage.ets
View file @
aac1a9e
...
...
@@ -14,7 +14,7 @@ struct OtherNormalUserHomePage {
@State params:Params = router.getParams() as Params;
@Watch('change') @State curUserId: string = '-1';
onPageShow() {
onPageShow() {
this.curUserId = this.params?.pageID;
}
...
...
@@ -172,51 +172,24 @@ struct OtherNormalUserHomePage {
.width('100%')
.backgroundColor($r('app.color.white'))
}
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
Column(){
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight(0)
//tab 页面
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}.tabBar(this.TabBuilder(0,"评论"))
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
}.tabBar(this.TabBuilder(1,"关注"))
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
...
...
@@ -327,9 +300,9 @@ struct OtherNormalUserHomePage {
this.currentIndex = index
this.controller.changeIndex(this.currentIndex)
})
.height('77lpx')
.width('70lpx')
.margin({right:'29lpx'})
.height('100%')
.width('100%')
.margin({right:'9lpx'})
}
...
...
sight_harmony/features/wdComponent/src/main/ets/pages/SearchCreatorPage.ets
0 → 100644
View file @
aac1a9e
import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
@Entry
@Component
struct SearchCreatorPage {
build() {
Row() {
Column() {
CustomTitleUI({titleName:"全部结果"})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/resources/base/profile/main_pages.json
View file @
aac1a9e
...
...
@@ -13,6 +13,7 @@
"components/page/BrowsingHistoryPage"
,
"components/page/MyCollectionListPage"
,
"pages/OtherNormalUserHomePage"
,
"pages/SearchPage"
"pages/SearchPage"
,
"pages/SearchCreatorPage"
]
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment