点击tabbar

This commit is contained in:
XiuYun CHEN 2025-06-05 14:10:30 +08:00
parent ca5ab146b7
commit efcb4be65a
11 changed files with 37 additions and 6 deletions

View File

@ -2,6 +2,7 @@ import { BasicConstant } from '../constants/BasicConstant'
export class HdListController {
loaded: () => void = () => {
}
finished: () => void = () => {
}
@ -96,6 +97,7 @@ export struct HdList {
}
this.loading = true
this.onLoad()
})
.scrollBar(BarState.Off)
.nestedScroll({

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -43,7 +43,7 @@ export struct ItemComp {
{
Stack()
{
Image(BasicConstant.urlHtml+this.item.liveimg).width('100%').height(162)
Image(BasicConstant.urlHtml+this.item.liveimg).width('100%').height(162).alt($r('app.media.home_scroll_default1'))
.objectFit(ImageFit.Fill)
if(this.status!=''&&(this.status!='已结束'&&this.status!='回访中'))
{

View File

@ -41,7 +41,7 @@ export struct ItemCompBack {
{
Stack()
{
Image(BasicConstant.urlHtml+this.item.liveimg).width('100%').height(162)
Image(BasicConstant.urlHtml+this.item.liveimg).width('100%').height(162).alt($r('app.media.home_scroll_default1'))
.objectFit(ImageFit.Fill)
Image($r('app.media.bofang')).width(40).height(40)
}

View File

@ -18,7 +18,7 @@ export struct ItemCompVideo {
build() {
Column() {
Image(BasicConstant.urlHtml+this.item.imgpath).width('100%').height(102)
Image(BasicConstant.urlHtml+this.item.imgpath).alt($r('app.media.default_video')).width('100%').height(102)
.objectFit(ImageFit.Fill)
Text(this.item.name).maxLines(2).fontSize(15).fontColor('app.color.666666').textAlign(TextAlign.Start).height(36)

View File

@ -13,6 +13,9 @@ export struct ListComp {
@State
list: ItemModel[] = []
controller = new HdListController()
scroller: Scroller = new Scroller()
@Consume@Watch('gotoTop')
toTop:boolean;
@State
page: number = 1
@State
@ -128,6 +131,7 @@ export struct ListComp {
HdList({
lw: 1,
controller: this.controller,
scroller:this.scroller,
onRefresh: () => {
this.onRefresh()
},
@ -145,5 +149,10 @@ export struct ListComp {
}
}
gotoTop()
{
this.scroller.scrollToIndex(0);
}
}

View File

@ -11,12 +11,16 @@ import HashMap from '@ohos.util.HashMap';
export struct ListCompGandan {
@State isEmptyViewVisible: boolean = false; // 控制显隐的状态变量
@Prop@Watch('onUpdate') sort:string='2'
@Consume@Watch('gotoTop')
toTop:boolean;
@Prop@Watch('onUpdate')
type_uuid:string=''
@Prop@Watch('onUpdate') keywords:string=''
@State
list: VideoMore[] = []
controller = new HdListController()
scroller: Scroller = new Scroller()
@State
page: number = 1
@ -92,6 +96,7 @@ export struct ListCompGandan {
}
build() {
if (this.isEmptyViewVisible){
EmptyViewComp({promptText:'暂无数据',isVisibility:this.isEmptyViewVisible})
.width('100%')
@ -100,6 +105,7 @@ export struct ListCompGandan {
HdGrid({
lw: 1,
controller: this.controller,
scroller:this.scroller,
onRefresh: () => {
this.onRefresh()
},
@ -115,4 +121,9 @@ export struct ListCompGandan {
}
}
}
gotoTop()
{
this.scroller.scrollToIndex(0);
}
}

View File

@ -75,7 +75,7 @@ export struct FourSection {
abilityName: 'com.huawei.hmos.settings.MainAbility',
uri: 'application_info_entry',
parameters: {
pushParams: 'com.example.expert'
pushParams: 'cn.shangyu.gdxzExprt'
}
};
const context = getContext(this) as common.UIAbilityContext;

View File

@ -36,7 +36,8 @@ export struct HeaderView {
@State myPageData:object = new Object;
@State heroArray:Array<object> = [];
@State clickHeroId:string = '';
@Consume@Watch('gotoTop')
toTop:boolean;
private scrollerForList: Scroller = new Scroller()
dialogController: CustomDialogController = new CustomDialogController({
@ -162,4 +163,10 @@ export struct HeaderView {
.backgroundImage(this.myPageData["myInfoBackGround"]).backgroundImageSize(ImageSize.Cover)
}
// }
gotoTop()
{
this.photoPath = BasicConstant.urlImage+authStore.getUser().photo;
}
}

View File

@ -14,7 +14,8 @@ export struct TabBarComp {
@State
isLandscape: boolean = false
listenerScreen = mediaquery.matchMediaSync('(orientation: landscape) and (device-type: tablet)')
@Provide
toTop:boolean=false;
aboutToAppear() {
this.listenerScreen.on('change', (mediaQueryResult) => {
this.isLandscape = mediaQueryResult.matches
@ -53,6 +54,7 @@ export struct TabBarComp {
.barPosition(this.isLandscape ? BarPosition.Start : BarPosition.End)
.onTabBarClick((index) => {
this.activeIndex = index
this.toTop=!this.toTop
})
.barHeight(this.isLandscape ? $r('app.float.tab_bar_item_height_lg') : $r('app.float.tab_bar_item_height_sm'))
.scrollable(false)