wangliang_wd

feat:优化人民号-关注点击,优化人民号主页显示

import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent'
import { RmhRecommendDTO } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
@Component
export struct PeopleShipRecommendComponent {
... ... @@ -63,10 +64,13 @@ export struct PeopleShipRecommendComponent {
ForEach(this.rmhList, (item: RmhRecommendDTO) => {
GridItem() {
PeopleShipRecommendHeadComponent({
rmhInfo: item
rmhInfo: item,
clickCallback:()=>{
this.clickRecommendHeadSelected(item)
}
})
.onClick(() => {
this.clickRecommendHeadSelected(item)
ProcessUtils.gotoPeopleShipHomePage(item.creatorId,1,1,item.userId,item.userType)
})
}
}, (item: RmhRecommendDTO) => item.creatorId)
... ...
... ... @@ -6,7 +6,8 @@ export struct PeopleShipRecommendHeadComponent {
@State isSelected: boolean = true
@Consume rmhSelectedList: string[]
@State rmhInfo: RmhRecommendDTO = {} as RmhRecommendDTO
clickCallback: () => void = () => {
}
build() {
Column(){
Stack({ alignContent: Alignment.BottomEnd }) {
... ... @@ -27,7 +28,9 @@ export struct PeopleShipRecommendHeadComponent {
.objectFit(ImageFit.Cover)
.margin({
right: '-3vp'
})
}).onClick(()=>{
this.clickCallback()
})
}.margin({ top: 4, bottom: 8 })
Row() {
... ...
... ... @@ -28,7 +28,7 @@ export struct PeopleShipHomePageTopComponent {
@State collapseTxt: string = '…展开';
private subTxt: string = '';
@State content: string = ''
@State topFixedHeight: number = 190
@State topFixedHeight: number = 195
@State lineInNum: number = 1
@Link topHeight: number
@State provinceName: string = ''
... ... @@ -36,14 +36,6 @@ export struct PeopleShipHomePageTopComponent {
build() {
Column() {
Stack({ alignContent: Alignment.TopStart }) {
// 顶部图片
// Image($r('app.media.home_page_bg'))
// .width('100%')
// .height(120)
// .objectFit(ImageFit.Auto)
// .objectRepeat(ImageRepeat.NoRepeat)
// .objectFit(ImageFit.Auto)
// .backgroundColor(Color.White)
// 头像和名称
Row() {
// 头像
... ... @@ -262,6 +254,11 @@ export struct PeopleShipHomePageTopComponent {
.backgroundColor($r('app.color.color_F5F5F5'))
.width('100%')
.height('6vp')
///计算顶部视图高度
.onAreaChange((oldArea: Area, newArea: Area) => {
this.topHeight = Number(newArea.position.y)+6
this.topFixedHeight = Number(newArea.position.y)+6
})
}
.width('100%')
.backgroundColor($r('app.color.color_transparent'))
... ... @@ -322,49 +319,51 @@ export struct PeopleShipHomePageTopComponent {
this.content = this.subTxt
}
}
if (this.detailModel) {
this.topFixedHeight = 190
if (this.detailModel.region && this.detailModel.region.length > 0) {
this.provinceName = this.detailModel.region
} else {
this.provinceName = await this.computeIPRegion(this.detailModel.province)
}
if (this.detailModel.authId == 1 && this.detailModel.categoryAuth.length > 0) {
this.topFixedHeight += this.getTextLineNum(this.detailModel.categoryAuth, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12')) * 18
this.topFixedHeight += 12
}
else if (this.detailModel.authId == 2) {
if (this.detailModel.authTitle && this.detailModel.authTitle.length > 0) {
this.topFixedHeight += this.getTextLineNum(this.detailModel.authTitle, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12')) * 18
if (this.detailModel.authPersonal && this.detailModel.authPersonal.length > 0){
this.topFixedHeight += 8
}else{
this.topFixedHeight += 12
}
}
if (this.detailModel.authPersonal && this.detailModel.authPersonal.length > 0) {
this.topFixedHeight += this.getTextLineNum(this.detailModel.authPersonal, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12')) * 18
this.topFixedHeight += 12
}
}
// IP归属地
if (this.provinceName && this.provinceName.length > 0) {
this.topFixedHeight += 28
this.topHeight = this.topFixedHeight
}
// 简介
if (this.detailModel.introduction && this.detailModel.introduction.length > 0 ) {
this.lineInNum = this.getTextLineNum(`简介:${this.detailModel.introduction}`, DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
if (this.lineInNum <= 3) {
this.topHeight = this.topFixedHeight + (21 * this.lineInNum)
} else {
this.lineInNum = this.getTextLineNum(`简介:${this.detailModel.introduction}` + '收起', DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
this.topHeight = this.topFixedHeight + (this.isCollapse ? 21 * 3 : 21 * this.lineInNum)
}
}
}
// if (this.detailModel) {
// this.topFixedHeight = 160
// if (this.detailModel.region && this.detailModel.region.length > 0) {
// this.provinceName = this.detailModel.region
// } else {
// this.provinceName = await this.computeIPRegion(this.detailModel.province)
// }
// if (this.detailModel.authId == 1 && this.detailModel.categoryAuth.length > 0) {
// this.topFixedHeight += this.getTextLineNum(this.detailModel.categoryAuth, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12')) * 18
// this.topFixedHeight += 12
// } else if (this.detailModel.authId == 2) {
// if (this.detailModel.authTitle && this.detailModel.authTitle.length > 0) {
// this.topFixedHeight += this.getTextLineNum(this.detailModel.authTitle, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12')) * 18
// if (this.detailModel.authPersonal && this.detailModel.authPersonal.length > 0){
// this.topFixedHeight += 8
// }else{
// this.topFixedHeight += 12
// }
// }
// if (this.detailModel.authPersonal && this.detailModel.authPersonal.length > 0) {
// this.topFixedHeight += this.getTextLineNum(this.detailModel.authPersonal, DisplayUtils.getDeviceWidth() - 90, 22, $r('app.float.vp_12')) * 18
// this.topFixedHeight += 12
// }
// }else {
// this.topFixedHeight += 10
// }
//
// // IP归属地
// if (this.provinceName && this.provinceName.length > 0) {
// this.topFixedHeight += 30
// }
//
// // 简介
// if (this.detailModel.introduction && this.detailModel.introduction.length > 0 ) {
// this.lineInNum = this.getTextLineNum(`简介:${this.detailModel.introduction}`, DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
// if (this.lineInNum <= 3) {
// this.topHeight = this.topFixedHeight + (21 * this.lineInNum)
// } else {
// this.lineInNum = this.getTextLineNum(`简介:${this.detailModel.introduction}` + '收起', DisplayUtils.getDeviceWidth() - 32, 21, $r('app.float.vp_14'))
// this.topHeight = this.topFixedHeight + (this.isCollapse ? 21 * 3 : 21 * this.lineInNum)
// }
// }
//
// this.topHeight = this.topFixedHeight
// }
}
private computeShowNum(count: number) {
... ...