douaojie

Merge remote-tracking branch 'origin/main'

# Conflicts:
#	sight_harmony/features/wdComponent/src/main/ets/components/cardCommon/CardSourceInfo.ets
... ... @@ -133,10 +133,15 @@ export class NetworkManager {
* 同步获取网络类型,耗时
*/
public getNetTypeSync(): NetworkType {
let netHandle = connection.getDefaultNetSync();
let netCapabilities = connection.getNetCapabilitiesSync(netHandle)
this.reset(netCapabilities.bearerTypes)
return this.networkType;
try {
let netHandle = connection.getDefaultNetSync();
let netCapabilities = connection.getNetCapabilitiesSync(netHandle)
this.reset(netCapabilities.bearerTypes)
return this.networkType;
} catch (e) {
Logger.error(TAG, 'getNetTypeSync e: ' + JSON.stringify(e))
}
return NetworkType.TYPE_UNKNOWN
}
private parseData(data: connection.NetCapabilityInfo) {
... ...
... ... @@ -43,7 +43,7 @@ export class NetworkUtil {
*/
static isNetConnected(): boolean {
let type = NetworkManager.getInstance().getNetType()
if (type == NetworkType.TYPE_NONE) {
if (type == NetworkType.TYPE_UNKNOWN || type == NetworkType.TYPE_NONE) {
return false
}
return true
... ...
... ... @@ -28,13 +28,19 @@ export struct CardSourceInfo {
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
if (((this.contentDTO.rmhPlatform === 1 && this.contentDTO.rmhInfo?.rmhName &&
this.contentDTO.rmhInfo?.rmhName != '') || (this.contentDTO.source && this.contentDTO.source != '')) &&
(this.getContentDtoBean()?.interactData?.commentNum ||
DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)) != '')) {
if (((this.contentDTO.rmhPlatform === 1 && this.contentDTO.rmhInfo?.rmhName && this.contentDTO.rmhInfo?.rmhName != '') || (this.contentDTO.source && this.contentDTO.source != '')) && (this.getContentDtoBean()?.interactData?.commentNum
// || DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)) != ''
|| (this.contentDTO.isSearch || this.contentDTO.isCollection ||
!this.contentDTO.isSearch && DateTimeUtils.getCommentTime
(Number
.parseFloat(this
.contentDTO.publishTime))
.indexOf
('-') === -1)
)) {
Image($r("app.media.point"))
.width(16)
.height(16)
.width(11)
.height(11)
}
// 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间
// if (this.contentDTO.isSearch || this.contentDTO.isCollection ||
... ...
... ... @@ -54,6 +54,7 @@ export struct Card9Component {
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 10, bottom: 10 })
.fontWeight(400)
}
// 大图
Stack() {
... ...
... ... @@ -17,10 +17,10 @@ export struct ZhSingleRow04 {
//顶部
Row() {
Row() {
Image($r("app.media.local_selection"))
.width(24)
.height(24)
.margin({ right: 4 })
// Image($r("app.media.local_selection"))
// .width(24)
// .height(24)
// .margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
... ...
... ... @@ -44,7 +44,7 @@ export struct ZhSingleRow06 {
const commentInfo = this.compDTO.operDataList[0]?.commentInfo as commentInfo;
// commentLikeChange(this.item)
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser.likeStatus === '1' ? '0' : '1';
// this.newsStatusOfUser.likeStatus = this.newsStatusOfUser.likeStatus === '1' ? '0' : '1';
const commentLikeParam = {
targetId: commentInfo.newsId || '',
id: commentInfo.commentId,
... ... @@ -52,8 +52,9 @@ export struct ZhSingleRow06 {
api_status: this.newsStatusOfUser?.likeStatus == '1' ? false : true
} as commentItemModel;
commentViewModel.commentLike(commentLikeParam).then(() => {
}).catch(() => {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser.likeStatus === '1' ? '0' : '1';
}).catch((err: Error) => {
console.log('06-err', JSON.stringify(err))
})
}
... ...
... ... @@ -34,7 +34,7 @@ export struct ChildCommentComponent {
.borderRadius(50)
}.width('89lpx')
.height('89lpx')
.margin({ right: '15lpx' })
.margin({ right: '3lpx' })
Column() {
Text(this.data.fromUserName)
... ...
... ... @@ -255,7 +255,7 @@ export struct PageComponent {
this.pageModel.channelId = this.channelId;
this.pageModel.currentPage = 1;
this.pageModel.pageTotalCompSize = 0;
// TODO PageHelper.getInitCacheData(this.pageModel, this.pageAdvModel)
PageHelper.getInitCacheData(this.pageModel, this.pageAdvModel)
PageHelper.getInitData(this.pageModel, this.pageAdvModel)
}, 100)
}
... ...
import router from '@ohos.router'
import { StringUtils } from 'wdKit';
import { NetworkUtil, StringUtils } from 'wdKit';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
import { editModelParams } from '../model/EditInfoModel';
import { HomePageBottomCommentComponent } from '../components/mine/home/HomePageBottomCommentComponent';
import { HomePageBottomFollowComponent } from '../components/mine/home/HomePageBottomFollowComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
import { EmptyComponent } from '../components/view/EmptyComponent';
import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
const TAG = "MineHomePage"
... ... @@ -33,6 +35,7 @@ struct MineHomePage {
scroller: Scroller = new Scroller();
@State params:Record<string, string> = router.getParams() as Record<string, string>;
@State isCommentEnter:string = "";
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
onPageShow(): void {
this.getUserInfo()
... ... @@ -47,216 +50,235 @@ struct MineHomePage {
}
build() {
Stack({ alignContent: Alignment.Top }){
Image($r('app.media.title_bg'))
.width('100%')
.height('355lpx')
.objectFit(ImageFit.Cover)
if(this.isConnectNetwork){
Stack({ alignContent: Alignment.Top }){
Image($r('app.media.title_bg'))
.width('100%')
.height('355lpx')
.objectFit(ImageFit.Cover)
Column(){
Stack({ alignContent: Alignment.Top }){
this.MineHomeTitleTransparent()
this.MineHomeTitleWhite()
}
Column(){
Stack({ alignContent: Alignment.Top }){
this.MineHomeTitleTransparent()
this.MineHomeTitleWhite()
}
Scroll(this.scroller) {
Column() {
//用户信息区域
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('115lpx')
.height('115lpx')
.objectFit(ImageFit.Auto)
.clip(new Circle({ width: '115lpx', height: '115lpx' }))
Image(this.levelHead)
.width('165lpx')
.height('165lpx')
.objectFit(ImageFit.Auto)
}.onClick(()=>{
let params = {'headPhotoUrl': this.headPhotoUrl} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage,params)
}).width('165lpx')
.height('165lpx')
Scroll(this.scroller) {
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 = {'headPhotoUrl': this.headPhotoUrl} as Record<string, string>;
WDRouterRule.jumpWithPage(WDRouterPage.showUserHeaderPage,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')
.onClick(()=>{
let params: editModelParams = {
editContent: this.userName
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params)
})
if(this.levelId>0){
Text(`等级${this.levelId}`)
.fontColor($r('app.color.color_ED2800'))
.fontSize('23lpx')
.fontWeight(500)
.margin({ left: '10lpx' })
.backgroundImage($r("app.media.my_grade_bg"))
.backgroundImageSize(ImageSize.Cover)
.padding({left:"17lpx",right:"8lpx"})
.height('35lpx')
}
Blank()
}.width('507lpx')
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: StringUtils.isEmpty(this.levelHead)?'32lpx':"3lpx" })
}
.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
}
this.tileOpacity = persent
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '6lpx' })
//用户简介区域
Column() {
Row() {
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
Text(this.isHasIntroduction?"简介:"+this.desc:this.desc)
.fontSize('27lpx')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
.lineHeight('40lpx')
.fontWeight('400lpx')
.fontColor(this.isHasIntroduction?$r('app.color.color_222222'):$r('app.color.color_999999'))
.textAlign(TextAlign.Start)
.onClick(()=>{
let params: editModelParams = {
editContent: this.userName
editContent: this.isHasIntroduction?this.desc:''
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserNikeNamePage,params)
WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params)
})
if(this.levelId>0){
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' })
if(!this.isHasIntroduction){
Image($r('app.media.user_info_edit_icon'))
.width('27lpx')
.height('27lpx')
.interpolation(ImageInterpolation.High)
.objectFit(ImageFit.Auto)
}
}
Blank()
}.width('507lpx')
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
}
this.tileOpacity = persent
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
//用户简介区域
Column() {
Row() {
Text(this.isHasIntroduction?"简介:"+this.desc:this.desc)
.fontSize('27lpx')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.lineHeight('40lpx')
Text(`来到人民日报${this.registerTimeForDay}天`)
.fontSize('23lpx')
.lineHeight('25lpx')
.fontWeight('400lpx')
.fontColor(this.isHasIntroduction?$r('app.color.color_222222'):$r('app.color.color_999999'))
.fontColor($r('app.color.color_999999'))
.textAlign(TextAlign.Start)
.onClick(()=>{
let params: editModelParams = {
editContent: this.isHasIntroduction?this.desc:''
}
WDRouterRule.jumpWithPage(WDRouterPage.editUserIntroductionPage,params)
})
if(!this.isHasIntroduction){
Image($r('app.media.user_info_edit_icon'))
.width('27lpx')
.height('27lpx')
.interpolation(ImageInterpolation.High)
.objectFit(ImageFit.Auto)
}
}
.margin({ top: '15lpx' })
Text(`来到人民日报${this.registerTimeForDay}天`)
.fontSize('23lpx')
.lineHeight('25lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_999999'))
.textAlign(TextAlign.Start)
.margin({ top: '15lpx' })
}.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'})
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.width('100%')
.backgroundColor($r('app.color.white'))
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomCommentComponent({commentNum:$commentNum})
}
TabContent() {
HomePageBottomFollowComponent()
}
}
}.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'})
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.width('100%')
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight("77lpx")
//间隔符
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
HomePageBottomCommentComponent({commentNum:$commentNum})
}
TabContent() {
HomePageBottomFollowComponent()
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight("77lpx")
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.justifyContent(FlexAlign.Start)
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('100%')
.padding({left:'31lpx'})
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.alignItems(VerticalAlign.Bottom)
.width('100%')
.padding({left:'31lpx'})
}
.alignItems(VerticalAlign.Bottom)
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
}.width("100%")
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.layoutWeight(1)
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.layoutWeight(1)
}.width('100%')
.layoutWeight(1)
}else{
Column(){
CustomTitleUI({ titleName: "" })
EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => {
this.isConnectNetwork = NetworkUtil.isNetConnected()
if(this.isConnectNetwork){
this.getUserInfo()
}
},})
.layoutWeight(1)
.width('100%')
}
}.width('100%')
.layoutWeight(1)
}
}
@Builder MineHomeTitleTransparent() {
... ...
import router from '@ohos.router'
import { Params } from 'wdBean';
import { StringUtils } from 'wdKit';
import { NetworkUtil, StringUtils } from 'wdKit';
import { OtherHomePageBottomCommentComponent } from '../components/mine/home/OtherHomePageBottomCommentComponent';
import { OtherHomePageBottomFollowComponent } from '../components/mine/home/OtherHomePageBottomFollowComponent';
import { CustomTitleUI } from '../components/reusable/CustomTitleUI';
import { EmptyComponent } from '../components/view/EmptyComponent';
import MinePageDatasModel from '../model/MinePageDatasModel';
import { OtherUserDetailRequestItem } from '../viewmodel/OtherUserDetailRequestItem';
... ... @@ -39,6 +41,7 @@ struct OtherNormalUserHomePage {
@State attentionNum:number = 0//关注数
@State desc:string = ""
userType:string = "1"
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
aboutToAppear(){
this.getUserInfo()
... ... @@ -47,185 +50,202 @@ struct OtherNormalUserHomePage {
build() {
Stack({ alignContent: Alignment.Top }){
Image($r('app.media.title_bg'))
.width('100%')
.height('355lpx')
.objectFit(ImageFit.Cover)
Column(){
Stack({ alignContent: Alignment.Top }){
this.MineHomeTitleTransparent()
this.MineHomeTitleWhite()
}
if(this.isConnectNetwork){
Stack({ alignContent: Alignment.Top }){
Image($r('app.media.title_bg'))
.width('100%')
.height('355lpx')
.objectFit(ImageFit.Cover)
Column(){
Stack({ alignContent: Alignment.Top }){
this.MineHomeTitleTransparent()
this.MineHomeTitleWhite()
}
Scroll() {
Column() {
//用户信息区域
Row() {
Stack(){
Image(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)
}
Scroll() {
Column() {
//用户信息区域
Row() {
Stack(){
Image(this.headPhotoUrl)
.alt($r('app.media.default_head'))
.width('115lpx')
.height('115lpx')
.objectFit(ImageFit.Cover)
.clip(new Circle({ width: '115lpx', height: '115lpx' }))
Image(this.levelHead)
.width('165lpx')
.height('165lpx')
.objectFit(ImageFit.Cover)
}
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() {
Text(`${this.browseNum}`)
.textStyle()
Text("阅读")
.textStyle2()
}
.margin({ right: '15lpx' })
Divider()
.height('19lpx')
.width('2lpx')
.color($r('app.color.white'))
.vertical(true)
.opacity(0.4)
Column() {
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)
Text(`${this.userName}`)
.fontColor($r('app.color.white'))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('38lpx')
.lineHeight('50lpx')
.fontWeight('500lpx')
if(this.levelId>0){
Text(`等级${this.levelId}`)
.fontColor($r('app.color.color_ED2800'))
.fontSize('23lpx')
.fontWeight(500)
.margin({ left: '10lpx' })
.backgroundImage($r("app.media.my_grade_bg"))
.backgroundImageSize(ImageSize.Cover)
.padding({left:"17lpx",right:"8lpx"})
.height('35lpx')
}
Blank()
}.width('507lpx')
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
}
this.tileOpacity = persent
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: StringUtils.isEmpty(this.levelHead)?'32lpx':"3lpx" })
}
})
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '35lpx' })
//用户简介区域
if(StringUtils.isNotEmpty(this.desc)){
Column() {
Row() {
Text(this.desc)
.fontSize('27lpx')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.lineHeight('40lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.textAlign(TextAlign.Start)
}
}.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'})
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.width('100%')
.backgroundColor($r('app.color.white'))
}
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Stack({ alignContent: Alignment.Top }){
Tabs({controller: this.controller}) {
TabContent() {
OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum})
}
TabContent() {
OtherHomePageBottomFollowComponent({curUserId:this.curUserId})
.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
}
this.tileOpacity = persent
}
}
.backgroundColor($r('app.color.white'))
.animationDuration(0)
.onChange((index: number) => {
this.currentIndex = index
})
.vertical(false)
.barHeight('77lpx')
.backgroundColor($r('app.color.color_transparent'))
.height('184lpx')
.width('100%')
.padding({ left: '6lpx' })
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
//用户简介区域
if(StringUtils.isNotEmpty(this.desc)){
Column() {
Row() {
Text(this.desc)
.fontSize('27lpx')
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.lineHeight('40lpx')
.fontWeight('400lpx')
.fontColor($r('app.color.color_222222'))
.textAlign(TextAlign.Start)
}
}.padding({ left: '31lpx',right:'31lpx',top:'19lpx',bottom:'31lpx'})
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Center)
.width('100%')
.backgroundColor($r('app.color.white'))
}
//间隔符
Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx')
//tab 页面
Stack({ alignContent: Alignment.Top }){
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('77lpx')
Column() {
// 页签
Row({ space: 7 }) {
Scroll() {
Row() {
this.TabBuilder(0,"评论")
this.TabBuilder(1,"关注")
}
.justifyContent(FlexAlign.Start)
}
.justifyContent(FlexAlign.Start)
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
}
.align(Alignment.Start)
.scrollable(ScrollDirection.Horizontal)
.scrollBar(BarState.Off)
.width('90%')
.padding({left:'31lpx'})
.alignItems(VerticalAlign.Bottom)
.width('100%')
}
.alignItems(VerticalAlign.Bottom)
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
.backgroundColor($r('app.color.white'))
.alignItems(HorizontalAlign.Start)
.width('100%')
.height('77lpx')
}
}.width("100%")
}.width("100%")
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.layoutWeight(1)
}
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.width('100%')
.layoutWeight(1)
}.width('100%')
.layoutWeight(1)
}else{
Column(){
CustomTitleUI({ titleName: "" })
EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => {
this.isConnectNetwork = NetworkUtil.isNetConnected()
if(this.isChangeToUserEdit){
this.getUserInfo()
}
},})
.layoutWeight(1)
.width('100%')
}
}.width('100%')
.layoutWeight(1)
}
}
@Builder MineHomeTitleTransparent() {
... ...
import { CompDTO, ContentDTO, InteractDataDTO, LiveReviewDTO, LiveRoomDataBean, PageDTO, PageInfoDTO } from 'wdBean';
import { CompStyle, ViewType } from 'wdConstant/Index';
import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, NetworkUtil, StringUtils } from 'wdKit';
import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, NetworkUtil, StringUtils, ToastUtils } from 'wdKit';
import { closeRefresh } from '../utils/PullDownRefresh';
import PageModel from './PageModel';
import PageViewModel from './PageViewModel';
... ... @@ -33,9 +33,16 @@ export class PageHelper {
* 刷新数据
*/
async refreshUI(pageModel: PageModel, pageAdvModel: PageAdModel) {
let netStatus = NetworkUtil.isNetConnected()
if (!netStatus) {
ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
setTimeout(() => {
closeRefresh(pageModel, false)
}, 500)
return
}
pageModel.loadStrategy = 2
pageModel.pageTotalCompSize = 0;
// TODO 下拉刷新,是否加载缓存
this.getPageInfo(pageModel, pageAdvModel)
}
... ... @@ -43,6 +50,11 @@ export class PageHelper {
* 分页加载
*/
async loadMore(pageModel: PageModel) {
let netStatus = NetworkUtil.isNetConnected()
if (!netStatus) {
ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
return
}
pageModel.loadStrategy = 3
// 暂只支持comp分页加载,节目分页加载的得完善框架(如直播回看节目数据分页)
this.compLoadMore(pageModel)
... ... @@ -52,55 +64,20 @@ export class PageHelper {
* 进页面请求数据
*/
async getInitCacheData(pageModel: PageModel, pageAdvModel: PageAdModel) {
Logger.error('zzzz', 'getInitCacheData')
Logger.debug(TAG, 'getInitCacheData')
PageViewModel.getPageInfoCache(pageModel.pageId).then(pageInfo => {
Logger.debug(TAG, 'getInitCacheData back: ' + pageInfo)
if (pageInfo == null) {
return;
}
pageModel.pageInfo = pageInfo;
pageModel.cachePageInfoMd5 = pageInfo.md5
//解析页面挂角广告资源
pageAdvModel.analysisAdvSource(pageInfo);
this.parseCacheGroup(pageModel)
this.parseGroup(pageModel, true)
})
}
async parseCacheGroup(pageModel: PageModel) {
Logger.error('zzzz', 'parseCacheGroup')
let pageInfo: PageInfoDTO = pageModel.pageInfo
pageModel.groupList = []
pageInfo.pageAdList = []
pageInfo.oneRequestPageGroupCompList = new ArrayList()
pageModel.groupList.push(...pageInfo.groups)
for (const group of pageInfo.groups) {
pageModel.groupId = group.id;
pageModel.groupData = group
// await,确保groups接口顺序执行
let pageDto = await PageViewModel.getPageGroupCacheData(pageModel.bizCopy()) as PageDTO
let index = pageInfo.groups.indexOf(group)
if (index == 0) {
// 清空comp列表
pageModel.compList.clear()
}
this.analysisPageGroupCompData(pageDto, pageInfo)
}
// 收集页面所有楼层的组件信息,同步完成广告投放计算,异步完成稿件批查,
pageModel.pageTotalCompSize = pageInfo.oneRequestPageGroupCompList.length + pageModel.pageTotalCompSize
// 处理页面广告数据,投放到页面的位置
// TODO 缓存数据不加载广告
// this.handlePageCompAdvPostion(pageInfo.oneRequestPageGroupCompList, pageModel, pageInfo.pageAdList);
//遍历所有组件和稿件数据 push到页面
for (let element of pageInfo.oneRequestPageGroupCompList) {
pageModel.compList.push(CompDTO.createNewsBean(element))
}
pageModel.currentPage++
pageModel.viewType = ViewType.LOADED
closeRefresh(pageModel, true)
}
/**
* 进页面请求数据
*/
... ... @@ -134,33 +111,51 @@ export class PageHelper {
promptAction.showToast({ message: err });
})
} else {
Logger.debug(TAG, 'getPageInfo')
PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
Logger.debug(TAG, 'getPageInfo back: ' + JSON.stringify(pageInfo))
if (pageInfo == null) {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoContent1;
return;
}
pageModel.pageInfo = pageInfo;
//解析页面挂角广告资源
pageAdvModel.analysisAdvSource(pageInfo);
this.parseGroup(pageModel)
// if (pageModel.currentPage == 1) {
// // 保存缓存
// CacheData.saveCacheData(CacheData.comPageInfoCacheKey + pageModel.pageId, pageInfo, pageInfo.md5)
// }
if (pageInfo.md5 == pageModel.cachePageInfoMd5) {
// 缓存一致,不解析
Logger.debug(TAG, 'getPageInfo 与缓存一致,不解析广告。。。')
} else {
Logger.debug(TAG, 'getPageInfo 要解析广告')
if (pageModel.currentPage == 1) {
// 保存缓存
CacheData.saveCacheData(CacheData.comPageInfoCacheKey + pageModel.pageId, pageInfo, pageInfo.md5)
}
//解析页面挂角广告资源
pageAdvModel.analysisAdvSource(pageInfo);
}
Logger.debug(TAG, 'getPageInfo go on')
this.parseGroup(pageModel, false)
}).catch(() => {
if (this.isPageLoaded(pageModel)) {
return
}
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_ContentFailed;
})
}
}
private isPageLoaded(pageModel: PageModel) {
if (pageModel.compList.size() > 0) {
return true
}
return false
}
/**
* 解析信息流页面楼层数据
* @param pageModel
*/
async parseGroup(pageModel: PageModel) {
async parseGroup(pageModel: PageModel, isCache: boolean) {
let pageInfo: PageInfoDTO = pageModel.pageInfo
pageModel.groupList = []
pageInfo.pageAdList = []
... ... @@ -177,8 +172,26 @@ export class PageHelper {
pageModel.groupData = group
//Logger.error("ZZZXXXXX", '楼层id-start--》' + pageModel.groupId);
let pageDto: PageDTO
Logger.debug(TAG, 'parseGroup isCache: ' + isCache)
if (isCache) {
pageDto = await PageViewModel.getPageGroupCacheData(pageModel.bizCopy()) as PageDTO
pageModel.cacheGroupInfoMd5 = pageDto.md5
} else {
pageDto = await PageViewModel.getPageGroupCompData(pageModel.bizCopy()) as PageDTO
if (pageDto.md5 == pageModel.cacheGroupInfoMd5) {
Logger.debug(TAG, 'parseGroup cache load, return: ' + pageDto.md5)
// 缓存数据一致,不再刷新
return
}
Logger.debug(TAG, 'parseGroup cache load, save: ')
// 保存缓存
CacheData.saveCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId, pageDto,
pageDto.md5)
}
Logger.debug(TAG, 'parseGroup go on')
// await,确保groups接口顺序执行
let pageDto = await PageViewModel.getPageGroupCompData(pageModel.bizCopy()) as PageDTO
// let pageDto = page
let index = pageInfo.groups.indexOf(group)
// 解析楼层组件
... ... @@ -197,9 +210,6 @@ export class PageHelper {
} else {
pageInfo.lastCompSourceType = 0
}
// // 保存缓存
// CacheData.saveCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId, pageDto,
// pageDto.md5)
}
}
... ...
... ... @@ -63,6 +63,10 @@ export default class PageModel {
pageType: number = 0;
extra: string = ''
// 缓存数据相关
cachePageInfoMd5: string = ''
cacheGroupInfoMd5: string = ''
/**
* 简单复制业务数据
*/
... ...
... ... @@ -16,6 +16,7 @@ import { HostEnum, HostManager, WDHttp } from 'wdNetwork/Index'
import { registerRouter } from 'wdRouter/Index'
import { TrackingModule } from 'wdTracking/Index'
import { JSON } from '@kit.ArkTS'
import app from '@system.app'
const TAG = "[StartupManager]"
... ... @@ -36,6 +37,8 @@ export class StartupManager {
appOnCreate(want: Want, launchParam: AbilityConstant.LaunchParam, context: common.UIAbilityContext) {
Logger.debug(TAG, "App onCreate: " + `\nwant: ${want}\nlaunchParam: ${launchParam}`)
this.context = context
// 设置图片文件数据缓存上限为200MB (200MB=200*1024*1024B=209715200B)
app.setImageFileCacheSize(209715200)
// KV存储
SPHelper.init(context);
... ...