王士厅
Showing 33 changed files with 534 additions and 255 deletions
... ... @@ -38,6 +38,10 @@ export class ContentConstants {
*/
static readonly TYPE_NINE: string = "9";
/**
* 11:频道跳转
*/
static readonly TYPE_CHANNEL: string = "11";
/**
* 13:音频详情
*/
static readonly TYPE_AUDIO: string = "13";
... ...
... ... @@ -134,6 +134,10 @@ export class ProcessUtils {
// 专题详情,跳转h5
ProcessUtils.gotoSpecialTopic(content);
break;
case ContentConstants.TYPE_CHANNEL:
// 频道跳转
HomeChannelUtils.jumpChannelTab(content.objectId, content.pageId, content.newsTitle)
break;
//动态详情页(动态图文)
case ContentConstants.TYPE_FOURTEEN:
ProcessUtils.gotoDynamicDetailPage(content);
... ...
... ... @@ -104,7 +104,7 @@ export class ContentDTO implements BaseDTO {
//底部导航栏 id(用于频道跳转)
bottomNavId: string = '';
// 链接类型: 0:无链接;1:内链(文章);2:外链
openType: string = '';
openType: string = '1';
extra: string = ''
sameContentList:ContentDTO[] = []
sameContentListJson:string = ""
... ...
... ... @@ -38,6 +38,7 @@ export struct CompParser {
@State pageId: string = '';
@State pageName: string = '';
@ObjectLink compDTO: CompDTO
@State nextCompDTO: CompDTO = new CompDTO
@State compIndex: number = 0;
@State private pageModel: PageModel = new PageModel();
@State audioItems: ContentDTO[] = [];
... ... @@ -83,17 +84,14 @@ export struct CompParser {
this.compDTO.operDataList[0]?.objectType !== '13') { //暂时屏蔽活动和音频详情入口
if (this.compDTO.compStyle === CompStyle.Label_03) {
LabelComponent({ compDTO: this.compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Carousel_Layout_01) {
if (this.compDTO.operDataList.length > this.audioItems.length) {
ZhCarouselLayout01({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_01 &&
this.compDTO.imageScale === 2) { // && compDTO.name ==="横划卡"
LiveHorizontalCardComponent({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_01 && this.compDTO.imageScale === 3) {
if (this.compDTO.operDataList.length > 1) {
HorizontalStrokeCardThreeTwoRadioForMoreComponent({
... ... @@ -108,17 +106,13 @@ export struct CompParser {
pageName: this.pageName
})
}
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_02) {
ZhSingleRow02({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_03) {
ZhSingleRow03({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) { //双列流小视频,一行两图卡 ->标题
//ZhGridLayout02({ compDTO: this.compDTO })
CompNormalTitle({ compDTO: this.compDTO })
// Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 })
} else if (this.compDTO.compStyle === CompStyle.Card_Comp_Zh_Grid_Layout_02) { //双列流小视频,一行两图卡
ZhGridLayout02NewsContent({
... ... @@ -130,16 +124,12 @@ export struct CompParser {
} else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
ZhGridLayout03({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_04) {
ZhSingleRow04({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_05) {
// ZhSingleRow05({ compDTO })
// Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_06) {
ZhSingleRow06({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_02) {
//头图卡 和comStyle 2相同,
Card5Component({
... ... @@ -149,7 +139,6 @@ export struct CompParser {
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_03) {
// 大图卡
Card2Component({
... ... @@ -158,7 +147,6 @@ export struct CompParser {
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Card_09) {
//时间链卡
Card9Component({
... ... @@ -167,7 +155,6 @@ export struct CompParser {
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Card_13) {
Card6Component({
compDTO: this.compDTO,
... ... @@ -175,7 +162,6 @@ export struct CompParser {
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Card_03) {
Card3Component({
compDTO: this.compDTO,
... ... @@ -183,20 +169,15 @@ export struct CompParser {
pageId: this.pageId,
pageName: this.pageName
})
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_04) {
ZhSingleColumn04({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_05) {
// ZhSingleColumn05({ compDTO: compDTO })
// Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 0, right: 0 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_09) {
ZhSingleColumn09({ compDTO: this.compDTO, pageId: this.pageId, pageName: this.pageName })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Card_Comp_Adv) { // 广告
AdvCardParser({ pageModel: this.pageModel, compDTO: this.compDTO })
//Text(`compIndex = ${compIndex}`).width('100%').fontSize('12fp').fontColor(Color.Red).padding({ left: 0, right: 0 })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (!Number.isNaN(Number(this.compDTO.compStyle)) || this.compDTO.compType === 'appStyle') {
CardParser({
contentDTO: this.compDTO.operDataList[0],
... ... @@ -205,7 +186,6 @@ export struct CompParser {
pageName: this.pageName,
compIndex: this.compIndex
});
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else {
// Text(this.compDTO.compStyle)
// .width(CommonConstants.FULL_PARENT)
... ... @@ -215,9 +195,43 @@ export struct CompParser {
// WDRouterRule.jumpWithPage(WDRouterPage.QualityCommentsPage)
// }
// })
// Divider().strokeWidth(8).color('#f5f5f5').padding({ left: 0, right: 0 })
}
if (
this.compDTO.compStyle === CompStyle.Card_09 ||
this.compDTO.compStyle === CompStyle.Zh_Single_Column_09 ||
this.compDTO.compStyle === CompStyle.Zh_Single_Row_04 ||
this.compDTO.compStyle === CompStyle.Zh_Single_Row_06
) {
if (this.compDTO.compStyle === this.nextCompDTO.compStyle) {
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else {
Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 16, right: 16 })
}
} else if (this.compDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10) {
// 大专题
if (this.nextCompDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10) {
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else {
Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 16, right: 16 })
}
} else if (this.compDTO.compType === 'appStyle') {
if (
this.nextCompDTO.compStyle === CompStyle.Card_09 ||
this.nextCompDTO?.operDataList?.[0]?.appStyle === CompStyle.Card_10 ||
this.nextCompDTO.compStyle === CompStyle.Zh_Single_Column_09 ||
this.nextCompDTO.compStyle === CompStyle.Zh_Single_Row_04 ||
this.nextCompDTO.compStyle === CompStyle.Zh_Single_Row_06
) {
Divider().strokeWidth(5).color('#f5f5f5').padding({ left: 16, right: 16 })
} else {
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}
} else {
// Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ import {
PageInfoBean,
ContentDTO,
contentListParams,
InteractDataDTO
InteractDataDTO, TopicInfo
} from 'wdBean';
import { DateTimeUtils, Logger, SPHelper, WindowModel } from 'wdKit/Index';
import { PaperReaderSimpleDialog } from '../../dialog/PaperReaderDialog';
... ... @@ -61,6 +61,7 @@ export struct MorningEveningPaperComponent {
@Provide title: string = ''
@Provide subTitle: string = ''
@Provide audioTitle: string = ''
@Provide topicInfo: TopicInfo = {} as TopicInfo
@Provide isAudioPlaying: boolean = false
@Provide status: number = PlayerConstants.STATUS_START;
@Provide currentTime: string = "00:00";
... ... @@ -142,6 +143,7 @@ export struct MorningEveningPaperComponent {
viewColumInsightIntentShare(context,String(dailyPaperTopicPageId), this.pageInfoBean)
this.title = this.pageInfoBean?.topicInfo?.title
this.topicInfo = this.pageInfoBean?.topicInfo
let dateTime = DateTimeUtils.parseDate(this.pageInfoBean?.topicInfo?.topicDate ?? '', DateTimeUtils.PATTERN_DATE_HYPHEN)
const dateShow = new Date(dateTime)
this.subTitle = `${dateShow.getFullYear()}年\n${(dateShow.getMonth() + 1)}月${dateShow.getDate()}日`
... ... @@ -314,7 +316,7 @@ export struct MorningEveningPaperComponent {
@Builder
topPaperTitle(){
Column(){
PaperTitleComponent({topicInfo:this.pageInfoBean?.topicInfo})
PaperTitleComponent()
.margin({top:this.topSafeHeight})
}
.height(44+this.topSafeHeight)
... ...
... ... @@ -12,7 +12,7 @@ import { TrackConstants } from 'wdTracking/Index';
export struct PaperTitleComponent {
@Consume title?: string
@Consume subTitle?: string
topicInfo: TopicInfo = {} as TopicInfo
@Consume topicInfo: TopicInfo
aboutToAppear() {
}
... ... @@ -98,18 +98,18 @@ export struct PaperTitleComponent {
})
.margin({ right: 16 })
// Image($r('app.media.icon_share'))
// .height($r('app.float.top_arrow_size'))
// .width($r('app.float.top_arrow_size'))
// .alignRules({
// right: { anchor: "img_close", align: HorizontalAlign.Start },
// center: { anchor: "__container__", align: VerticalAlign.Center }
// })
// .id('img_share')
// .margin({ right: 16 })
// .onClick(() => {
// this.share()
// })
Image($r('app.media.icon_share'))
.height($r('app.float.top_arrow_size'))
.width($r('app.float.top_arrow_size'))
.alignRules({
right: { anchor: "img_close", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center }
})
.id('img_share')
.margin({ right: 16 })
.onClick(() => {
this.share()
})
}
// .margin({ left: 14, right: 14 })
.height($r('app.float.top_bar_height'))
... ...
... ... @@ -54,7 +54,8 @@ export struct Card5Component {
bottomRight: $r('app.float.image_border_radius')
}
)
.aspectRatio(343 / 225)
// .aspectRatio(343 / 225)
.autoResize(true)
if (!!this.titleShowPolicy || this.titleShowPolicy === null ) {
Row()
.borderRadius(
... ...
... ... @@ -94,7 +94,7 @@ export struct Card6Component {
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textIndent((this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) > 2 &&
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? 58 :
(this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) < 5 ? (12 + (this.contentDTO.newTags?.length || this.contentDTO.seoTags?.length) * 11) :
((this.contentDTO.newTags?.length > 0 || this.contentDTO.seoTags?.length > 0) || this.contentDTO.objectType == '5' || this.contentDTO.top === 1) ? 35 :
0 )
}.alignContent(Alignment.TopStart)
... ...
... ... @@ -138,8 +138,8 @@ export struct ZhSingleColumn09 {
.textAlign(TextAlign.Center)
.fontColor(0xffffff)
Image($r('app.media.icon_selected'))
.width(19)
.height(19)
.width(14)
.height(14)
.opacity(this.activeIndexs.includes(index) ? 1 : 0)
.objectFit(ImageFit.Contain)
}
... ...
... ... @@ -21,7 +21,7 @@ export default struct MinePageUserSimpleInfoUI {
///已登录状态,先获取本地数据
this.userName = SPHelper.default.getSync(SpConstants.USER_NAME,"") as string
this.headPhotoUrl = SPHelper.default.getSync(SpConstants.USER_HEAD_PHOTO_URL,"") as string
this.userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string
this.getUserInfo()
}else{
this.headPhotoUrl = ""
... ... @@ -33,8 +33,8 @@ export default struct MinePageUserSimpleInfoUI {
Row(){
//头像
Stack(){
Image(this.headPhotoUrl==""?$r('app.media.default_head'):this.headPhotoUrl)
.alt($r('app.media.default_head'))
Image(this.headPhotoUrl)
.alt(this.userType === '1'?$r('app.media.default_head'):$r('app.media.AccountOwner_DefaultIcon'))
.width(`${this.calcHeight(100)}lpx`)
.height(`${this.calcHeight(100)}lpx`)
.objectFit(ImageFit.Cover)
... ...
... ... @@ -37,7 +37,7 @@ export struct AppointmentListUI {
if (this.isGetRequest == true) {
if(this.isConnectNetwork){
EmptyComponent({ emptyType: 10 })
.height('100%')
.height('80%')
.width('100%')
}else{
EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => {
... ...
import { TopNavDTO } from 'wdBean';
import curves from '@ohos.curves';
import { Logger } from 'wdKit/Index';
import { Logger, SPHelper } from 'wdKit/Index';
import { SpConstants } from 'wdConstant/Index';
const INDEX_SETTING_TITLE: string = '首页设置'
const INDEX_SETTING_SUBTITLE: string = '将指定频道设置为首页'
... ... @@ -43,7 +44,6 @@ struct ChannelSubscriptionLayout {
@State isEditIng: boolean = false
// 顶部导航栏是否有临时跳转频道数据不
@Prop haveTempTabData: boolean
changeTab: (index: number) => void = () => {
}
... ... @@ -67,9 +67,14 @@ struct ChannelSubscriptionLayout {
delChannelItem(index: number) {
let item = this.myChannelList.splice(index, 1)[0]
this.channelIds.splice(index, 1)
// this.channelIds.splice(index, 1)
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
// 本地频道特殊处理
let provinceName = SPHelper.default.getSync(SpConstants.LOCATION_PROVINCE_NAME, '') as string
if (provinceName && provinceName.includes(item.name) && item.localChannel == '0') {
item.localChannel = '1'
}
/*
删除的频道信息回到原栏目中去
*/
... ... @@ -130,8 +135,8 @@ struct ChannelSubscriptionLayout {
this.myChannelList.push(item)
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
let storageChannelIds: string = AppStorage.get<string>('channelIds') || ''
console.debug('TopNavigationComponent', 'addChannelItem==>' + storageChannelIds)
// let storageChannelIds: string = AppStorage.get<string>('channelIds') || ''
// console.debug('TopNavigationComponent', 'addChannelItem==>' + storageChannelIds)
}
itemMove(index: number, newIndex: number): void {
... ... @@ -570,7 +575,7 @@ struct ChannelSubscriptionLayout {
.backgroundColor(Color.White)
.onClick(() => {
this.isShow = true
if(this.haveTempTabData){
if (this.haveTempTabData) {
// 存储数据
AppStorage.setOrCreate('channelIds', this.channelIds.join(','))
this.haveTempTabData = false
... ... @@ -578,18 +583,23 @@ struct ChannelSubscriptionLayout {
})
.bindContentCover(this.isShow, this.sheetBuilder(), {
modalTransition: ModalTransition.DEFAULT,
onWillAppear: () => {console.log("BindContentCover onWillAppear.")},
onAppear: () => {console.log("BindContentCover onAppear.")},
onWillDisappear: () => {console.log("BindContentCover onWillDisappear.")
onWillAppear: () => {
console.log("BindContentCover onWillAppear.")
},
onAppear: () => {
console.log("BindContentCover onAppear.")
},
onWillDisappear: () => {
console.log("BindContentCover onWillDisappear.")
this.isShow = false
this.isEditIng = false},
onDisappear: () => {console.log("BindContentCover onDisappear.")
this.isEditIng = false
},
onDisappear: () => {
console.log("BindContentCover onDisappear.")
}
})
}
/**
* 改变我的频道栏目中频道id数据
*/
... ...
... ... @@ -47,7 +47,7 @@ struct MyCollectionListPage {
},
title:this.isAllSelect?'是否确认清空?':'确认删除'+this.deleteNum.toString()+'条收藏',
tipShow: false ,
leftTextColor:$r('app.color.color_648DF2'),
leftTextColor:$r('app.color.color_333333')
}),
autoCancel: true,
alignment: DialogAlignment.Center,
... ... @@ -108,8 +108,10 @@ struct MyCollectionListPage {
this.allSelectDatas(isAllSelect)
},
confirmCallback:()=>{
if(this.deleteNum > 0){
this.dialogController.open()
}
}
})
}
.backgroundColor(Color.White)
... ...
... ... @@ -95,7 +95,15 @@ export struct PageComponent {
LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => {
ListItem() {
Column() {
CompParser({ pageModel: this.pageModel, compDTO: compDTO, compIndex: compIndex, pageId: this.pageId });
CompParser(
{
pageModel: this.pageModel,
nextCompDTO: compIndex === this.pageModel.compList.getDataArray().length - 1 ? new CompDTO() : this.pageModel.compList.get(compIndex + 1) as CompDTO,
compDTO: compDTO,
compIndex: compIndex,
pageId: this.pageId
}
);
}
}
},
... ...
import { ContentDTO , Action,GoldenPositionExtraBean, CompDTO} from 'wdBean';
import { CommonConstants ,ViewType} from 'wdConstant';
import { Action, CompDTO, ContentDTO } from 'wdBean';
import { CommonConstants, ViewType } from 'wdConstant';
import PageViewModel from '../../viewmodel/PageViewModel';
import PageModel from '../../viewmodel/PageModel';
import { DateTimeUtils, LazyDataSource } from 'wdKit/Index';
import router from '@ohos.router';
import { CardParser } from '../CardParser';
import { channelSkeleton } from '../skeleton/channelSkeleton'
import { channelSkeleton } from '../skeleton/channelSkeleton';
import { ErrorComponent } from '../view/ErrorComponent';
import { EmptyComponent } from '../view/EmptyComponent';
import { listTouchEvent } from '../../utils/PullDownRefresh';
... ... @@ -14,13 +13,21 @@ import { RefreshLayoutBean } from '../refresh/RefreshLayoutBean';
import RefreshLayout from '../refresh/RefreshLayout';
import PageNoMoreLayout from './PageNoMoreLayout';
import { NoMoreBean } from './NoMoreBean';
import CommonPageTitle from './CommonPageTitle';
import TemplatePageComponent from './template/TemplatePageComponent';
import { TemplatePageConstant } from './template/TemplatePageConstant';
const TAG: string = 'ThemeListPage';
/**
* 金刚卡位聚合页
*/
@Entry
@Component
struct ThemeListPage {
@State private pageModel: PageModel = new PageModel();
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
// @State private pageModel: PageModel = new PageModel();
sort: number = 1;
currentPage: number = 1;
pageSize: number = 20;
... ... @@ -29,129 +36,27 @@ struct ThemeListPage {
@State private pageAdvModel: PageAdModel = new PageAdModel();
aboutToAppear(): void {
let par:Action = router.getParams() as Action;
let par: Action = router.getParams() as Action;
let params = par?.params;
this.extra = params?.extra?.extra || '';
this.title = params?.extra?.title || '';
this.pageModel.pageType = 1;
this.pageModel.extra = this.extra;
PageViewModel.postThemeList(this.currentPage, this.pageSize,this.extra).then((liveReviewDTO) => {
console.log(`postThemeList${JSON.stringify(liveReviewDTO)}`)
this.pageModel.compList.addItems(liveReviewDTO.list)
if(this.pageModel.compList.getDataArray().length > 0){
this.pageModel.viewType = ViewType.LOADED;
}else{
this.pageModel.viewType = ViewType.EMPTY
}
})
}
build() {
Column() {
this.TabbarNormal()
if (this.pageModel.viewType == ViewType.LOADING) {
this.LoadingLayout()
} else if (this.pageModel.viewType == ViewType.ERROR) {
ErrorComponent()
} else if (this.pageModel.viewType == ViewType.EMPTY) {
EmptyComponent()
} else {
this.ListLayout()
}
}
.padding({
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.onTouch((event: TouchEvent | undefined) => {
if (event) {
if (this.pageModel.viewType === ViewType.LOADED) {
listTouchEvent(this.pageModel, this.pageAdvModel, event);
}
}
})
}
@Builder
LoadingLayout() {
channelSkeleton()
}
/*导航栏*/
@Builder
TabbarNormal() {
RelativeContainer() {
//标题栏目
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.objectFit(ImageFit.Auto)
.id("back_icon")
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
left: { anchor: "__container__", align: HorizontalAlign.Start }
})
.onClick(() => {
router.back()
})
Text(this.title)// .height('42lpx')
.maxLines(1)
.id("title")
.fontSize('35lpx')
.fontWeight(400)
.fontColor($r('app.color.color_222222'))
.lineHeight('42lpx')
.alignRules({
center: { anchor: "__container__", align: VerticalAlign.Center },
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
//常见标题
CommonPageTitle({ title: this.title })
// 通用模板组件
TemplatePageComponent({ pageDataSourceType: TemplatePageConstant.THEME_LIST_PAGE, extra: this.extra })
}
.height(44)
.width('100%')
.height('100%')
.backgroundColor(Color.White)
.padding({
left: $r('app.float.card_comp_pagePadding_lf'),
right: $r('app.float.card_comp_pagePadding_lf'),
})
}
@Builder
ListLayout() {
List() {
// 下拉刷新
ListItem() {
RefreshLayout({
refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullDown, this.pageModel.load,
this.pageModel.offsetY)
})
}
LazyForEach(this.pageModel.compList, (contentDTO: ContentDTO, contentIndex: number) => {
ListItem() {
Column() {
CardParser({compDTO:new CompDTO, contentDTO });
}
}
},
(contentDTO: ContentDTO, contentIndex: number) => contentDTO.pageId + contentIndex.toString()
)
// 加载更多
ListItem() {
if (this.pageModel.hasMore) {
// LoadMoreLayout({
// refreshBean: new RefreshLayoutBean(this.pageModel.isVisiblePullUpLoad, this.pageModel.pullUpLoadImage,
// this.pageModel.pullUpLoadText, this.pageModel.pullUpLoadHeight)
// })
} else {
PageNoMoreLayout({ noMoreBean: new NoMoreBean(this.pageModel.pageInfo.baselineCopywriting) })
}
}
}
.scrollBar(BarState.Off)
.cachedCount(8)
.height(CommonConstants.FULL_PARENT)
.onScrollIndex((start: number, end: number) => {
this.pageModel.startIndex = start;
this.pageModel.endIndex = end;
top: px2vp(this.topSafeHeight),
bottom: px2vp(this.bottomSafeHeight)
})
}
}
\ No newline at end of file
... ...
import { BottomNavDTO, TopNavDTO } from 'wdBean';
import { SpConstants } from 'wdConstant';
import { BottomNavDTO, NavigationDetailDTO, TopNavDTO } from 'wdBean';
import { Logger, NetworkUtil, SPHelper, ToastUtils } from 'wdKit';
import { ProcessUtils, WDRouterPage, WDRouterRule } from 'wdRouter';
import { PageComponent } from './PageComponent';
... ... @@ -422,7 +421,6 @@ export struct TopNavigationComponentNew {
async aboutToAppear() {
if (CompUtils.isNews(this.navItem)) {
// 请求顶导网络数据
... ... @@ -619,20 +617,51 @@ export struct TopNavigationComponentNew {
//请求顶导数据
async getTopNavList(id: number) {
Logger.debug(TAG, 'getTopNavList=存储=>' + this.storageChannelIds)
// 1 、使用存储数据
let bottomDetailCache = await ChannelViewModel.getBottomNavDetailCacheData(id)
if (bottomDetailCache != null && bottomDetailCache.topNavChannelList.length > 0) {
Logger.debug(TAG, '使用缓存数据')
this.processTopNewsTapData(bottomDetailCache, false)
}
// 2、请求网络数据
let bottomNavDetail = await ChannelViewModel.getBottomNavDetailData(id, this.storageChannelIds)
if (bottomNavDetail != null) {
// 3、 接口数据md5和存储数据md5对比,一致不更新
if (bottomNavDetail.md5 == bottomDetailCache?.md5) {
Logger.debug(TAG, '不使用接口数据')
} else {
Logger.debug(TAG, '使用接口数据')
this.processTopNewsTapData(bottomNavDetail, true)
//存储
ChannelViewModel.saveBottomDetailData(bottomNavDetail)
}
}
}
/**
* 加工新闻tab 顶导数据
* @param bottomNavDetail
*/
private processTopNewsTapData(bottomNavDetail: NavigationDetailDTO, isNetData: boolean) {
let topNavList = bottomNavDetail?.topNavChannelList || []
//let provinceName = SPHelper.default.getSync(SpConstants.LOCATION_PROVINCE_NAME, '') as string
let _myChannelList: TopNavDTO [] = []
this.homeChannelList = []
this.moreChannelList = []
this.localChannelList = []
topNavList.forEach(item => {
if (item.defaultPermitted === 1) {
console.debug('TopNavigationComponent', '--homeChannelList--->' + item.name)
this.homeChannelList.push(item)
}
//TODO 暂时隐藏播报
if (item.name !== '播报') {
if (item.myChannel === '1') {
... ... @@ -645,6 +674,33 @@ export struct TopNavigationComponentNew {
}
})
//根据缓存数组排序
if (this.storageChannelIds && !isNetData) {
Logger.debug(TAG, '根据存储内容')
let sortedyChannelList: TopNavDTO [] = []
let _storageChannelIds = this.storageChannelIds.split(',')
_storageChannelIds.forEach((channelId) => {
for (let a of _myChannelList) {
if (channelId == String(a.channelId)) {
let startIndex = _myChannelList.findIndex(b => b.channelId == a.channelId)
_myChannelList.splice(startIndex, 1)
sortedyChannelList.push(a)
break;
}
}
})
// 依据存储的我的频道中频道id集合,过滤出符合条件频道,剩余的频道,针对本地频道处理,每次删除,再次进入存储的频道详情信息里面我的频道栏目的信息集合都有本地频道
if (_myChannelList.length > 0) {
_myChannelList.forEach((localChannelBean) => {
localChannelBean.localChannel = '1'
})
this.localChannelList.unshift(..._myChannelList)
}
_myChannelList = sortedyChannelList
}
this.myChannelList = _myChannelList
//缓存首页频道
... ... @@ -653,7 +709,9 @@ export struct TopNavigationComponentNew {
this.currentTopNavSelectedIndex = index
}
if (isNetData) {
// 存储我的频道栏目中的频道id信息
Logger.debug(TAG, '存储我的频道栏目数据')
let channelIds: number [] = []
this.myChannelList.forEach(item => {
if (item != undefined && item.channelId != undefined) {
... ... @@ -662,4 +720,6 @@ export struct TopNavigationComponentNew {
})
AppStorage.setOrCreate('channelIds', channelIds.join(','))
}
}
}
\ No newline at end of file
... ...
import { CompDTO, ContentDTO, LiveRoomDataBean, ReserveBean, ReserveItemBean } from 'wdBean/Index'
import { DateTimeUtils, Logger } from 'wdKit/Index'
import { HttpUtils } from 'wdNetwork/Index'
import { CompDTO,
ContentBean,
ContentDTO,
InteractDataDTO,
InteractParam, LiveRoomDataBean, ReserveBean, ReserveItemBean } from 'wdBean/Index'
import { BaseDTO } from 'wdBean/src/main/ets/bean/component/BaseDTO'
import { CollectionUtils, DateTimeUtils, LazyDataSource, Logger, StringUtils } from 'wdKit/Index'
import { HttpUtils, ResponseDTO } from 'wdNetwork/Index'
import { PageRepository } from '../../../repository/PageRepository'
import { LiveModel } from '../../../viewmodel/LiveModel'
import PageViewModel from '../../../viewmodel/PageViewModel'
... ... @@ -64,7 +70,6 @@ export class BasePageHelp {
* 请求获取直播房间的动态数据
* @param compList
*/
getLiveRoomDataInfo(compList: CompDTO[]) {
let list: ContentDTO[] = []
... ... @@ -110,4 +115,143 @@ export class BasePageHelp {
});
return idList.join(',')
}
/**
* 批查稿件的互动数据,如 评论人数等
* @param compList
* @returns
*/
async getInteractData(compList: CompDTO[]) {
let param: InteractParam = this.getInteractParams(compList);
const SIZE = 20;
// 批查接口,参数size限制20,这里截断分批查询,0,20;20,40...
let count = Math.ceil(param.contentList.length / SIZE);
let promises: Array<Promise<InteractDataDTO[]>> = new Array;
if (count == 1) {
let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(param);
promises.push(promise);
} else {
for (let i = 1; i <= count; i++) {
// 将查询参数截断(参数限制20个),分批请求接口
let subList = new Array<ContentBean>();
let start = 0;
let end = 0;
if (i == count) {
start = (i - 1) * SIZE;
end = param.contentList.length;
subList = CollectionUtils.getSubElements(param.contentList, start, end)
} else {
start = (i - 1) * SIZE;
end = start + SIZE;
subList = CollectionUtils.getSubElements(param.contentList, start, end)
}
let subParam: InteractParam = {} as InteractParam;
subParam.contentList = subList;
let promise: Promise<InteractDataDTO[]> = this.createInteractDataPromise(subParam);
promises.push(promise);
}
}
return new Promise<InteractDataDTO[]>((success, error) => {
Promise.all(promises).then((result) => {
if (!CollectionUtils.isArray(result)) {
success(new Array<InteractDataDTO>());
return;
}
let allInteractDataList: Array<InteractDataDTO> = new Array();
result.forEach((value: InteractDataDTO[]) => {
if (value != null && value.length > 0) {
allInteractDataList.push(...value);
}
})
// 批查全部完成,统一设置到comp里
// this.resetInteract(allInteractDataList, compList);
success(allInteractDataList);
})
})
}
private getInteractParams(compList: CompDTO[]): InteractParam {
if (compList == null || compList.length == 0) {
return {} as InteractParam;
}
let param: InteractParam = {} as InteractParam;
param.contentList = new Array<ContentBean>();
compList.forEach((value) => {
let contentList = value.operDataList;
let letBatch = false
// 只有稿件才能批查
if (!Number.isNaN(Number(value.compStyle))) {
letBatch = true
}
if (letBatch) {
if (contentList != null && contentList.length == 1) { // 对只有一条数据的稿件参与批查
contentList.forEach((v) => {
if (StringUtils.isNotEmpty(v.objectId)) {
let bean = {} as ContentBean;
bean.contentId = v.objectId;
bean.contentType = v.objectType;
param.contentList.push(bean);
}
})
}
}
})
return param;
}
private createInteractDataPromise(param: InteractParam) {
return new Promise<InteractDataDTO[]>((success, error) => {
PageRepository.fetchInteractData(param).then((resDTO: ResponseDTO<InteractDataDTO[]>) => {
if (!resDTO || !resDTO.data) {
Logger.info(TAG, "getInteractData then,resDTO.timeStamp:" + resDTO.timestamp);
success([]);
return;
}
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `getInteractData catch, error.name : ${err.name}, error.message:${err.message}`);
// 无论是否成功(暂不做重试),都回调结果,通知刷新数据
success([]);
})
});
}
/**
* 刷新互动数据到compList
* @param interact 批查互动数据结果
* @param compList comp list
*/
resetInteract(interact: InteractDataDTO[], compList: BaseDTO[]) {
if (interact == null || interact.length == 0) {
return
}
let time = DateTimeUtils.getTimeStamp().toString()
interact.forEach((interactData) => {
let id = interactData.contentId;
outer: for (let i = 0; i < compList.length; i++) {
let comp = compList[i] as CompDTO;
if (comp == null || comp.operDataList == null || comp.operDataList.length == 0) {
continue;
}
for (let j = 0; j < comp.operDataList.length; j++) {
let content = comp.operDataList[j];
if (content == null) {
continue;
}
if (id == content.objectId) {
content.interactData = interactData;
comp.timestamp = time
break outer;
}
}
}
})
}
}
\ No newline at end of file
... ...
... ... @@ -23,6 +23,7 @@ const TAG: string = 'TemplatePageComponent';
*/
@Component
export default struct TemplatePageComponent {
// 模板页面的数据驱动对象
@State private templatePage: TemplatePageModel = new TemplatePageModel
// 此内容主要因CustomPullToRefresh需要,目前没任何业务意义要求
... ... @@ -31,11 +32,14 @@ export default struct TemplatePageComponent {
private templateScroller: Scroller = new Scroller()
//识别不同页面的业务类型
pageDataSourceType: string = ''
@State listColor: Resource = $r('app.color.color_fff')
// 埋点字段
pageId: string = ''
pageName: string = ''
extra: string = ''
async aboutToAppear() {
Logger.debug(TAG, 'aboutToAppear')
this.requestPageData()
... ... @@ -81,8 +85,6 @@ export default struct TemplatePageComponent {
if (this.templatePage.pageCompType === TemplatePageStateType.LOADING) {
this.LoadingLayout()
} else if (this.templatePage.pageCompType === TemplatePageStateType.LOADED) {
CustomPullToRefresh({
alldata: this.pageData,
scroller: this.templateScroller,
... ... @@ -123,6 +125,7 @@ export default struct TemplatePageComponent {
CompParser({
compDTO: compDTO,
nextCompDTO: index === this.templatePage.compList.getDataArray().length - 1 ? new CompDTO() : this.templatePage.compList.get(index + 1) as CompDTO,
compIndex: index,
pageId: this.pageId,
pageName: this.pageName
... ... @@ -167,6 +170,7 @@ export default struct TemplatePageComponent {
}
this.templatePage.pageDataSourceType = this.pageDataSourceType
this.templatePage.extra = this.extra
TemplatePageHelp.requestPageData(this.templatePage)
}
... ...
... ... @@ -18,4 +18,10 @@ export class TemplatePageConstant {
public static LIVE_PORTEND_PAGE :string = 'live_portend_page'
/**
* 金刚卡位聚会页
*/
public static THEME_LIST_PAGE :string = 'theme_list_page'
}
\ No newline at end of file
... ...
import { CompDTO } from 'wdBean/Index';
import { CompDTO, InteractDataDTO } from 'wdBean/Index';
import { CompStyle } from 'wdConstant/Index';
import { DateTimeUtils, NetworkUtil } from 'wdKit/Index';
import PageViewModel from '../../../viewmodel/PageViewModel';
... ... @@ -40,8 +40,8 @@ export class TemplatePageHelp extends BasePageHelp {
// 加载缓存数据了,不用无网络提示
} else {
// 无网情况
pageModel.pageCompType = TemplatePageStateType.OTHER;
pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork
this.pageModel.pageCompType = TemplatePageStateType.OTHER
this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork
}
}
... ... @@ -61,6 +61,9 @@ export class TemplatePageHelp extends BasePageHelp {
} else if (this.pageModel.pageDataSourceType === TemplatePageConstant.LIVE_PORTEND_PAGE) {
// 直播预告
this.requestLivePortendData(this.pageModel.resolve)
} else if (this.pageModel.pageDataSourceType === TemplatePageConstant.THEME_LIST_PAGE) {
// 金刚卡位聚合页
this.requestThemeListData(this.pageModel.resolve)
}
}
... ... @@ -171,15 +174,80 @@ export class TemplatePageHelp extends BasePageHelp {
this.pageModel.isLoading = false
}
/**
* 请求金刚卡位聚合页数据
*/
private async requestThemeListData(resolve?: (value: string | PromiseLike<string>) => void) {
this.pageModel.isLoading = true
const liveReviewDTO =
await PageViewModel.postThemeList(this.pageModel.currentPage, this.pageModel.pageSize, this.pageModel.extra)
if (liveReviewDTO && liveReviewDTO.list && liveReviewDTO.list.length > 0) {
if (liveReviewDTO.list.length === this.pageModel.pageSize) {
this.pageModel.hasMore = true
} else {
this.pageModel.hasMore = false
}
// 依据业务请求获取的数据,转换成compDTO数据
let time = DateTimeUtils.getTimeStamp().toString()
let pageContentList: CompDTO[] = [] // 收集页面组件、稿件和本地组件容器
for (let contentDto of liveReviewDTO.list) {
let compDTO: CompDTO = new CompDTO()
compDTO.compType = 'appStyle'
contentDto.appStyle = contentDto.appStyle
if (this.pageModel.isEmitter) {
contentDto.timestamp = time
}
compDTO.operDataList.push(contentDto)
pageContentList.push(compDTO)
}
// 推送数据到懒加载机制
this.pushDataToPage(pageContentList)
// 批查
this.allCompBatchRequest(pageContentList)
} else {
this.pageModel.hasMore = false
if (this.pageModel.currentPage === 1) {
// 无业务数据
this.pageNoHaveData()
this.pageModel.pageCompType = TemplatePageStateType.OTHER
this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoContent2
}
}
this.resolveEnd(resolve)
// 完成业务请求加载
this.pageModel.isLoading = false
}
/**
* 处理页面批查业务方法
* @param list
*/
private allCompBatchRequest(compList: CompDTO[]) {
// 获取直播房间的动态数据
// 获取直播房间的动态数据 如直播观看人数
this.getLiveRoomDataInfo(compList)
// 获取互动数据,如评论数量等
this.getInteractData(compList).then((data: InteractDataDTO[]) => {
// 刷新,替换所有数据
this.resetInteract(data, compList)
})
}
... ... @@ -207,9 +275,10 @@ export class TemplatePageHelp extends BasePageHelp {
*/
private pageNoHaveData() {
this.pageModel.pageCompType = TemplatePageStateType.OTHER
this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoNetwork
this.pageModel.noNormalState = WDViewDefaultType.WDViewDefaultType_NoListContent
}
/**
* 解析结束
* @param resolve
... ...
... ... @@ -33,6 +33,9 @@ export default class TemplatePageModel {
haveDataShow: boolean = false
// 接收Emitter事件,需要刷新界面,此时就需要对展示业务进行驱动更新
isEmitter: boolean = false
// 扩展字段
extra :string = ''
/**
* 此字段可驱动组件展示不同业务的组件,
*/
... ... @@ -41,5 +44,6 @@ export default class TemplatePageModel {
* 异常状态 ——> 记录在获取数据中的不同状态,如无数据、无网络等情况
*/
noNormalState: WDViewDefaultType = WDViewDefaultType.WDViewDefaultType_Default
resolve?: (value: string | PromiseLike<string>) => void
}
\ No newline at end of file
... ...
... ... @@ -49,7 +49,7 @@ export struct MineSettingComponent {
title: "清理缓存",
tipValue:"是否确认清理此App的缓存",
tipShow:true,
leftTextColor:$r('app.color.color_648DF2')
leftTextColor:$r('app.color.color_333333')
}),
autoCancel: true,
alignment: DialogAlignment.Center,
... ...
... ... @@ -33,7 +33,7 @@ export struct CustomBottomFuctionUI {
Button('删除'+ (this.deleteNum === 0 ? '':'('+this.deleteNum.toString()+')'))
.type(ButtonType.Normal)
.fontColor(this.deleteNum === 0?$r('app.color.color_222222'):$r('app.color.color_ED2800'))
.fontColor(this.deleteNum === 0?$r('app.color.color_B0B0B0'):$r('app.color.color_ED2800'))
.backgroundColor(Color.White)
.id("delete_Button")
.alignRules({
... ...
... ... @@ -129,7 +129,7 @@ export struct EmptyComponent {
.fontWeight(FontWeight.Normal)
.opacity(this.TEXT_OPACITY)
.margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP })
.fontColor(this.emptyType !== 15 ? '#FFCCCCCC' : '#999999')
.fontColor('#666666')
.onClick((event: ClickEvent) => {
Logger.info(TAG, `noProgrammeData onClick event?.source: ${event.source}`);
})
... ...
... ... @@ -192,11 +192,11 @@ export class PageRepository {
/**
* 早晚报pageInfo请求
* */
static getMorningEveningPageInfoUrl(pageId: string,topicId:string) {
static getMorningEveningPageInfoUrl(pageId: string, topicId: string) {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.PAGE_INFO_PATH;
url = url + "?pageId=" + pageId;
if(!StringUtils.isEmpty(topicId)){
url = url+ "&topicId=" + topicId;
if (!StringUtils.isEmpty(topicId)) {
url = url + "&topicId=" + topicId;
}
Logger.info(TAG, "getMorningEveningPageInfoUrl url = " + url)
return url;
... ... @@ -237,10 +237,11 @@ export class PageRepository {
static fetchNavigationDetailDataApi(id: number = 210, myChannelIds?: string) {
let url = PageRepository.getBottomNavGroupDetailUrl() + `?id=${id}`;
// 310000 310100 310115120
let provinceCode = HttpUtils.getProvinceCode()
if (provinceCode) {
url = url + "&districtCode=" + HttpUtils.getDistrictCode()
+ "&provinceCode=" + HttpUtils.getProvinceCode()
+ "&provinceCode=" + provinceCode
+ "&cityCode=" + HttpUtils.getCityCode()
}
if (myChannelIds) {
... ... @@ -395,8 +396,8 @@ export class PageRepository {
/**
* 获取早晚报pageInfo
* */
static fetchMorningEveningPageInfo(pageId: string,topicId:string) {
let url = PageRepository.getMorningEveningPageInfoUrl(pageId,topicId)
static fetchMorningEveningPageInfo(pageId: string, topicId: string) {
let url = PageRepository.getMorningEveningPageInfoUrl(pageId, topicId)
return WDHttp.get<ResponseDTO<PageInfoBean>>(url)
};
... ... @@ -421,7 +422,7 @@ export class PageRepository {
* 获取播报pageInfo
* */
static fetchBroadcastPageInfo(pageId: string) {
let url = PageRepository.getMorningEveningPageInfoUrl(pageId,'')
let url = PageRepository.getMorningEveningPageInfoUrl(pageId, '')
return WDHttp.get<ResponseDTO<PageInfoBean>>(url)
};
... ...
... ... @@ -58,7 +58,7 @@ export class ChannelViewModel {
}
/**
* 保存导详情数据到缓存
* 保存顶部导详情数据到缓存
*/
saveBottomDetailData(data: NavigationDetailDTO) {
CacheData.saveCacheData(CacheData.channelCacheDataKey + data?.id, data, data.md5)
... ... @@ -75,7 +75,7 @@ export class ChannelViewModel {
/**
* 获取底导详情(顶导)接口数据
*/
async getBottomNavDetailData(id: number, myChannelIds?: string): Promise<NavigationDetailDTO> {
async getBottomNavDetailData(id: number, myChannelIds?: string): Promise<NavigationDetailDTO|null> {
Logger.info(TAG, `getBottomNavDetailData start`);
return this.getNavDetailData(id,myChannelIds);
}
... ... @@ -111,18 +111,18 @@ export class ChannelViewModel {
* @param myChannelIds
* @returns
*/
private getNavDetailData(id: number, myChannelIds?: string): Promise<NavigationDetailDTO> {
return new Promise<NavigationDetailDTO>((success, error) => {
private getNavDetailData(id: number, myChannelIds?: string): Promise<NavigationDetailDTO|null> {
return new Promise<NavigationDetailDTO|null>((success, error) => {
Logger.info(TAG, `getNavData start`);
PageRepository.fetchNavigationDetailDataApi(id,myChannelIds).then((navResDTO: ResponseDTO<NavigationDetailDTO>) => {
if (!navResDTO || !navResDTO.data) {
Logger.error(TAG, 'getNavData then navResDTO is empty');
error('navResDTO is empty');
success(null);
return
}
if (navResDTO.code != 0) {
Logger.error(TAG, `getNavData then code:${navResDTO.code}, message:${navResDTO.message}`);
error('navResDTO Response Code is failure');
success(null);
return
}
// let navResStr = JSON.stringify(navResDTO);
... ... @@ -131,7 +131,7 @@ export class ChannelViewModel {
success(navResDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `fetchNavigationDataApi catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
success(null);
})
})
}
... ...
... ... @@ -77,9 +77,9 @@ export class PageHelper {
* 进页面请求数据
*/
async getInitCacheData(pageModel: PageModel, pageAdvModel: PageAdModel) {
Logger.debug(TAG, 'getInitCacheData')
// Logger.debug(TAG, 'getInitCacheData')
PageViewModel.getPageInfoCache(pageModel.pageId).then(pageInfo => {
Logger.debug(TAG, 'getInitCacheData back: ' + pageInfo)
// Logger.debug(TAG, 'getInitCacheData back: ' + pageInfo)
if (pageInfo == null) {
return;
}
... ... @@ -125,9 +125,9 @@ export class PageHelper {
this.refreshUIEnd(pageModel, false)
})
} else {
Logger.debug(TAG, 'getPageInfo')
// Logger.debug(TAG, 'getPageInfo')
PageViewModel.getPageInfo(pageModel.pageId).then(pageInfo => {
Logger.debug(TAG, 'getPageInfo back: ' + JSON.stringify(pageInfo))
// Logger.debug(TAG, 'getPageInfo back: ' + JSON.stringify(pageInfo))
if (pageInfo == null) {
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoContent1;
... ... @@ -137,9 +137,9 @@ export class PageHelper {
pageModel.pageInfo = pageInfo;
if (pageInfo.md5 == pageModel.displayPageInfoMd5) {
// 缓存一致,不解析
Logger.debug(TAG, 'getPageInfo 与缓存一致,不解析广告。。。')
// Logger.debug(TAG, 'getPageInfo 与缓存一致,不解析广告。。。')
} else {
Logger.debug(TAG, 'getPageInfo 要解析广告')
// Logger.debug(TAG, 'getPageInfo 要解析广告')
if (pageModel.currentPage == 1) {
// 保存缓存
CacheData.saveCacheData(CacheData.comPageInfoCacheKey + pageModel.pageId, pageInfo, pageInfo.md5)
... ... @@ -148,7 +148,7 @@ export class PageHelper {
//解析页面挂角广告资源
pageAdvModel.analysisAdvSource(pageInfo);
}
Logger.debug(TAG, 'getPageInfo go on')
// Logger.debug(TAG, 'getPageInfo go on')
this.parseGroup(pageModel, false)
}).catch(() => {
this.refreshUIEnd(pageModel, false)
... ... @@ -190,14 +190,14 @@ export class PageHelper {
//Logger.error("ZZZXXXXX", '楼层id-start--》' + pageModel.groupId);
let pageDto: PageDTO
Logger.debug(TAG, 'parseGroup isCache: ' + isCache)
//Logger.debug(TAG, 'parseGroup isCache: ' + isCache)
if (isCache) {
pageDto = await PageViewModel.getPageGroupCacheData(pageModel.bizCopy()) as PageDTO
pageModel.displayGroupInfoMd5 = pageDto.md5
} else {
pageDto = await PageViewModel.getPageGroupCompData(pageModel.bizCopy()) as PageDTO
if (pageDto.md5 == pageModel.displayGroupInfoMd5) {
Logger.debug(TAG, 'parseGroup cache load, return: ' + pageDto.md5)
// Logger.debug(TAG, 'parseGroup cache load, return: ' + pageDto.md5)
// 下拉刷新场景,数据没变,拦截刷新UI,重置相关参数
if (pageModel.loadStrategy === 2) {
// 缓存数据一致,不再刷新
... ... @@ -211,17 +211,17 @@ export class PageHelper {
return
}
pageModel.displayGroupInfoMd5 = pageDto.md5
Logger.debug(TAG, 'parseGroup cache load, save: ' + pageDto.md5)
// Logger.debug(TAG, 'parseGroup cache load, save: ' + pageDto.md5)
// 保存缓存
CacheData.saveCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId, pageDto,
pageDto.md5)
}
Logger.debug(TAG, 'parseGroup go on')
// Logger.debug(TAG, 'parseGroup go on')
// await,确保groups接口顺序执行
// let pageDto = page
let index = pageInfo.groups.indexOf(group)
Logger.debug(TAG, 'yyyy parseGroup print')
// Logger.debug(TAG, 'yyyy parseGroup print')
this.printComp(pageDto)
// 解析楼层组件
this.analysisPageGroupCompData(pageDto, pageInfo)
... ... @@ -268,7 +268,7 @@ export class PageHelper {
if (pageModel.compList.isEmpty()) {
// 没数据,展示空页面
Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.');
//Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.');
pageModel.viewType = ViewType.EMPTY;
pageModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoContent1;
... ... @@ -296,7 +296,7 @@ export class PageHelper {
pageInfo.pageAdList.push(...pageDto.compAdList)
}
// TODO 待删除
Logger.debug(TAG, 'yyyy analysisPageGroupCompData size, '+pageInfo?.oneRequestPageGroupCompList?.length)
// Logger.debug(TAG, 'yyyy analysisPageGroupCompData size, '+pageInfo?.oneRequestPageGroupCompList?.length)
}
}
... ... @@ -343,7 +343,7 @@ export class PageHelper {
pageModel.currentPage++;
pageModel.hasMore = true;
Logger.debug(TAG, 'yyyy compLoadMore print')
// Logger.debug(TAG, 'yyyy compLoadMore print')
this.printComp(data)
//移除音频 和 活动
this.loadMorePageComp(pageModel, data)
... ... @@ -372,7 +372,7 @@ export class PageHelper {
pageModel.pageInfo.oneRequestPageGroupCompList.add(comp)
})
// TODO 待删除
Logger.debug(TAG, 'yyyy loadMorePageComp size, ' + pageModel.pageInfo.oneRequestPageGroupCompList?.length)
// Logger.debug(TAG, 'yyyy loadMorePageComp size, ' + pageModel.pageInfo.oneRequestPageGroupCompList?.length)
// 记录
pageModel.pageTotalCompSize = pageCompList.length + pageModel.pageTotalCompSize
... ... @@ -398,7 +398,7 @@ export class PageHelper {
let contentInfo: ContentDTO = CollectionUtils.getElement(element.operDataList, 0);
//移除音频 和 活动
if (contentInfo && (contentInfo.objectType === '13' || contentInfo.objectType === '3')) {
Logger.debug(TAG, 'getGroupData 移除音频 和 活动');
//Logger.debug(TAG, 'getGroupData 移除音频 和 活动');
} else {
// 暂时屏蔽活动和音频详情入口
if (element.operDataList[0]?.objectType === '3' || element.operDataList[0]?.objectType === '13') {
... ... @@ -843,7 +843,7 @@ export class PageHelper {
* 删除分页数据,保留第一页的数据。(下拉刷新场景用到)
*/
deleteMorePage(pageModel: PageModel) {
Logger.debug(TAG, 'deleteMorePage endindex: ' + pageModel.firstPageEndIndex)
//Logger.debug(TAG, 'deleteMorePage endindex: ' + pageModel.firstPageEndIndex)
if (pageModel.firstPageEndIndex < 0) {
return
}
... ... @@ -855,7 +855,7 @@ export class PageHelper {
* 临时打印comp相关信息,用于问题定位。TODO 待删除
*/
private printComp(pageDto: PageDTO) {
Logger.debug(TAG, 'yyyy printComp pageDto.compList.size: ' + pageDto?.compList?.length)
//Logger.debug(TAG, 'yyyy printComp pageDto.compList.size: ' + pageDto?.compList?.length)
new Promise<void>(() => {
let tmpCompList: CompDTO[] = Array.from(pageDto.compList)
tmpCompList.forEach((v, k) => {
... ... @@ -863,10 +863,10 @@ export class PageHelper {
Logger.warn(TAG, 'yyyy printComp comp forEach, ' + v.compStyle)
v.operDataList.forEach((cv, ci) => {
if (cv) {
Logger.debug(TAG, 'yyyy printComp ContentDTO print, ' + v.compStyle)
Logger.debug(TAG, 'yyyy printComp ContentDTO xxxx newsTitle, ' + cv.newsTitle)
// Logger.debug(TAG, 'yyyy printComp ContentDTO print, ' + v.compStyle)
// Logger.debug(TAG, 'yyyy printComp ContentDTO xxxx newsTitle, ' + cv.newsTitle)
} else {
Logger.warn(TAG, 'yyyy printComp ContentDTO is null, ' + v.compStyle)
// Logger.warn(TAG, 'yyyy printComp ContentDTO is null, ' + v.compStyle)
}
})
} else {
... ...
... ... @@ -296,22 +296,28 @@ export class PageViewModel extends BaseViewModel {
})
})
}
async postThemeList(pageNum: number, pageSize: number, extra: string): Promise<LiveReviewDTO> {
/**
* 金刚卡聚合页
* @param pageNum
* @param pageSize
* @param extra
* @returns
*/
async postThemeList(pageNum: number, pageSize: number, extra: string): Promise<LiveReviewDTO | null> {
let bean: GoldenPositionExtraBean = JSON.parse(extra)
bean.pageNum = pageNum
bean.pageSize = pageSize
return new Promise<LiveReviewDTO>((success, error) => {
return new Promise<LiveReviewDTO| null>((success, error) => {
Logger.info(TAG, `postThemeList pageInfo start`);
PageRepository.postThemeList(bean).then((resDTO) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'postThemeList then navResDTO is empty');
error('resDTO is empty');
success(null);
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `postThemeList then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
success(null);
return
}
// let navResStr = JSON.stringify(navResDTO);
... ... @@ -319,7 +325,7 @@ export class PageViewModel extends BaseViewModel {
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `postThemeList catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
success(null);
})
})
}
... ...
... ... @@ -68,7 +68,9 @@ export struct DetailPlayShortVideoPage {
this.queryNewsInfoOfUser()
if (this.switchVideoStatus && this.isPlay && this.onlyWifiLoadVideo) {
await this.playerController.play()
await this.playerController.startRenderFrame(() => {
this.imageVisible = false
})
}
}
}
... ... @@ -81,7 +83,9 @@ export struct DetailPlayShortVideoPage {
if (this.currentIndex === this.index) {
if (this.switchVideoStatus && this.isPlay && this.onlyWifiLoadVideo) {
await this.playerController.play()
await this.playerController.startRenderFrame(() => {
this.imageVisible = false
})
} else {
this.playerController.pause()
}
... ... @@ -106,14 +110,18 @@ export struct DetailPlayShortVideoPage {
this.playerController.onCanplay = async () => {
this.ratio = this.playerController.videoWidth / this.playerController.videoHeight
await this.playerController.play()
await this.playerController.startRenderFrame(() => {
this.imageVisible = false
})
}
} else {
if (!this.onlyWifiLoadVideo) {
await this.playerController.pause()
} else {
await this.playerController.play()
await this.playerController.startRenderFrame(() => {
this.imageVisible = false
})
}
}
}
... ... @@ -186,7 +194,9 @@ export struct DetailPlayShortVideoPage {
await this.playerController.pause()
} else {
await this.playerController.play()
await this.playerController.startRenderFrame(() => {
this.imageVisible = false
})
}
}
}
... ... @@ -363,8 +373,10 @@ export struct DetailPlayShortVideoPage {
this.onlyWifiLoadVideo = true
this.toastTextVisible = false
this.playerController?.play()
this.playerController.startRenderFrame(() => {
this.imageVisible = false
})
})
}
.width('100%')
.height(64)
... ...
... ... @@ -142,6 +142,16 @@ export struct PlayerFullScreenView {
.margin({ left: 16, right: 8 })
PlayerProgressFullScreenView({ playerController: this.playerController }).layoutWeight(1)
.onTouch((event?: TouchEvent) => {
if (event) {
if (event.type === TouchType.Down) {
clearInterval(this.timer)
}
if (event.type === TouchType.Up) {
this.restartTimer();
}
}
})
Text(DateTimeUtils.secondToTime(this.videoDuration))
.fontSize(12)
... ...
... ... @@ -250,6 +250,13 @@ export class WDPlayerController {
this.avPlayer?.play();
}
async startRenderFrame(cb: Function) {
this.avPlayer?.on('startRenderFrame', () => {
cb && cb();
console.info('startRenderFrame success')
})
}
async stop() {
// if (this.avPlayer == null) {
// await this.initPromise;
... ...
... ... @@ -24,17 +24,17 @@ export class Tracking {
// Logger.error('yyyy','event track failed')
// })
let publicParams = new PublicParams()
publicParams.getPublicParams().then((pubParams) => {
if (params) {
for (const obj of Object.entries(params)) {
// Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`);
pubParams[obj[0]] = obj[1]
}
}
sensors.track(eventId, pubParams)
})
// let publicParams = new PublicParams()
// publicParams.getPublicParams().then((pubParams) => {
//
// if (params) {
// for (const obj of Object.entries(params)) {
// // Logger.info(TAG, ` ${obj[0]} => ` + `${obj[1]}`);
// pubParams[obj[0]] = obj[1]
// }
// }
// sensors.track(eventId, pubParams)
// })
}
}
... ...
... ... @@ -9,6 +9,8 @@ const TAG = 'DefaultWebPage'
@Entry
@Component
struct DefaultWebPage {
@State topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
scroller: Scroller = new Scroller();
action: Action = {} as Action
... ... @@ -24,10 +26,10 @@ struct DefaultWebPage {
isPageEnd: $isPageEnd
})
}.layoutWeight(1)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP])
Row() {
Button({type: ButtonType.Normal}) {
Button({ type: ButtonType.Normal }) {
Image($r("app.media.back_icon_black"))
.width(20).height(25)
}.height(44).width(44)
... ... @@ -35,13 +37,17 @@ struct DefaultWebPage {
.onClick(() => {
router.back()
})
Blank()
}.width("100%").height(44)
.alignItems(VerticalAlign.Center)
.expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM])
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.height(CommonConstants.FULL_HEIGHT).padding({
top: px2vp(this.topSafeHeight),
bottom: px2vp(this.bottomSafeHeight)
})
}
aboutToAppear() {
... ...