王士厅
Showing 96 changed files with 2588 additions and 1158 deletions
... ... @@ -48,4 +48,8 @@ export class SpConstants{
//游客状态下首次评论时间
static FIRSTCOMMENTTIME = 'firstCommentTime'
static TOURIST_NICK_NAME = 'touristNickName'
// 个推推送
static GETUI_PUSH_CID = "cid"
static GETUI_PUSH_DEVICE_TOKEN = "deviceToken"
}
\ No newline at end of file
... ...
... ... @@ -39,7 +39,7 @@ export const enum CompStyle {
Zh_Single_Column_10 = 'Zh_Single_Column-10', //18 服务组合卡
Zh_Single_Column_11 = 'Zh_Single_Column-11', //19 问政组合卡
Zh_Grid_Layout_01 = 'Zh_Grid_Layout-01', //4 信息流组合卡
Zh_Grid_Layout_02 = 'Zh_Grid_Layout-02', //7 双列流小视频,一行两图卡
Zh_Grid_Layout_02 = 'Zh_Grid_Layout-02', //7 双列流小视频,一行两图卡 ->标题
Zh_Grid_Layout_03 = 'Zh_Grid_Layout-03', //11 金刚位卡
Card_01 = '1', // 小图卡
Card_02 = '2', // 大图卡
... ... @@ -80,5 +80,7 @@ export const enum CompStyle {
/**
* 本地稿件和组件样式
*/
Card_Comp_Adv = 'card_comp_adv', //
Card_Comp_Adv = 'card_comp_adv', // 信息流广告稿件
Card_Comp_Zh_Grid_Layout_02 = 'Card_Comp_Zh_Grid_Layout-02', // 一行两列卡业务内容
}
... ...
... ... @@ -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
... ...
... ... @@ -5,6 +5,10 @@ import { HostManager } from './HttpHostManager';
*/
export class HttpUrlUtils {
/**
* 查询直播参与人数
*/
static readonly GET_JOIN_PEOPLE_NUM: string = '/api/live-center-message/zh/a/live/room/number/batch/all'
/**
* 启动接口(底导接口)
*/
static readonly BOTTOM_NAV_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/bottomNavGroup";
... ... @@ -135,14 +139,6 @@ export class HttpUrlUtils {
*/
static readonly APPOINTMENT_ExecuteCollcet_PATH: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
/**
* 个人中心 - 消息
*/
static readonly APPOINTMENT_MessageList_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private";
/**
* 个人中心 - 消息 点赞数
*/
static readonly APPOINTMENT_getMessageLikeCount_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/getLikeCount";
/**
* 个人中心 我的评论列表
*/
static readonly MINE_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/myCommentList";
... ... @@ -324,10 +320,6 @@ export class HttpUrlUtils {
*/
static readonly FEEDBACK_TYPE_PATH: string = "/api/rmrb-interact/interact/c/user/optionClassify/list";
/**
* 查询点赞、回复我的、系统消息的未读数量以及回复/评论人
*/
static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime=";
/**
* 直播详情-直播人数
... ... @@ -515,16 +507,6 @@ export class HttpUrlUtils {
return url
}
static getMessageListDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_MessageList_PATH
return url
}
static getMessageLikeCount() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_getMessageLikeCount_PATH
return url
}
static getExecuteCollcetUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH
return url
... ... @@ -761,14 +743,9 @@ export class HttpUrlUtils {
return url;
}
//获取消息未读接口
static getMessageUnReadDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MESSAGE_UN_READ_DATA_PATH
return url
}
static reportDeviceInfo() {
let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push";
// 查询节目的参与人数
static getJoinPeopleNum() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.GET_JOIN_PEOPLE_NUM;
return url;
}
... ... @@ -796,4 +773,43 @@ export class HttpUrlUtils {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.ENTER_MESSAGE_PATH
return url
}
/**
* 个人中心 - 消息
*/
static readonly APPOINTMENT_MessageList_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private";
/**
* 个人中心 - 消息 点赞数
*/
static readonly APPOINTMENT_getMessageLikeCount_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/getLikeCount";
/**
* 查询点赞、回复我的、系统消息的未读数量以及回复/评论人
*/
static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime=";
static getMessageListDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_MessageList_PATH
return url
}
static getMessageLikeCount() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_getMessageLikeCount_PATH
return url
}
//获取消息未读接口
static getMessageUnReadDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MESSAGE_UN_READ_DATA_PATH
return url
}
static reportDeviceInfo() {
let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push";
return url;
}
static getUploadPushInfoUrl() {
let url = HttpUrlUtils.getHost() + "/api/rmrb-contact/contact/zh/c/push/device"
return url
}
}
... ...
... ... @@ -12,4 +12,6 @@ export { ProcessUtils } from './src/main/ets/utils/ProcessUtils'
export { AssignChannelParam } from './src/main/ets/utils/HomeChannelUtils';
export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor'
\ No newline at end of file
export { RouterJumpInterceptor, JumpInterceptorAction } from './src/main/ets/router/RouterJumpInterceptor'
export { AppInnerLink } from './src/main/ets/utils/AppInnerLink'
... ...
import { url } from '@kit.ArkTS'
import App from '@system.app'
import { Logger } from 'wdKit/Index'
const TAG = "AppInnerLink"
export class AppInnerLink {
static readonly INNER_LINK_PROTCOL = "rmrbapp:"
static readonly INNER_LINK_HOSTNAME = "rmrb.app"
static readonly INNER_LINK_PATHNAME = "openwith"
// 内链跳转
// 内链地址例如:rmrbapp://rmrb.app/openwith?type=article&subType=h5_template_article&contentId=30000762651&relId=500000038702&skipType=1&relType=1
static jumpWithLink(innerLink: string) {
let params = AppInnerLink.parseParams(innerLink)
if (!params) {
Logger.info(TAG, "跳转无效的链接地址 " + innerLink)
return
}
switch (params.skipType) {
case 1: {
AppInnerLink.jumpParams(params)
break
}
case 2: {
AppInnerLink.jumpNoParams(params)
break
}
case 3: {
AppInnerLink.jumpAppH5(params)
break
}
case 4: {
AppInnerLink.jumpOutH5(params)
break
}
case 5: {
AppInnerLink.jumpThirdApp(params)
break
}
default: {
Logger.info(TAG, "跳转无效的链接地址 " + innerLink)
}
}
}
private static jumpParams(params: InnerLinkParam) {
}
private static jumpNoParams(params: InnerLinkParam) {
}
private static jumpAppH5(params: InnerLinkParam) {
}
private static jumpOutH5(params: InnerLinkParam) {
}
private static jumpThirdApp(params: InnerLinkParam) {
}
static parseParams(link: string) : InnerLinkParam | undefined {
const that = url.URL.parseURL(link)
if (that.protocol !== AppInnerLink.INNER_LINK_PROTCOL) {
return
}
if (that.hostname !== AppInnerLink.INNER_LINK_HOSTNAME) {
return
}
if (that.pathname !== AppInnerLink.INNER_LINK_PATHNAME) {
return
}
let obj = {} as InnerLinkParam
const params = that.params
obj.type = params.get("type") as string
obj.subType = params.get("subType") as string
obj.contentId = params.get("contentId") as string
obj.relId = params.get("relId") as string
obj.relType = params.get("relType") as string
obj.pageId = params.get("pageId") as string
obj.url = params.get("url") as string
obj.activityId = params.get("activityId") as string
obj.activityType = params.get("activityType") as string
obj.creatorId = params.get("creatorId") as string
obj.firstChannelId = params.get("firstChannelId") as string
obj.skipType = Number(params.get("skipType"))
obj.isLogin = params.get("isLogin") as string
return obj
}
}
interface InnerLinkParam {
type?: string,
subType?: string,
contentId?: string,
relId?: string,
relType?: string
pageId?: string,
url?: string,
activityId?: string,
activityType?: string,
creatorId?: string,
firstChannelId?: string,
skipType: number,
isLogin?: string,
}
\ No newline at end of file
... ...
... ... @@ -238,7 +238,6 @@ export class ProcessUtils {
}
Logger.debug(TAG, `gotoWeb, ${content.objectId}`)
}
... ...
... ... @@ -7,10 +7,11 @@ import { VoiceInfoDTO } from '../detail/VoiceInfoDTO';
import { RmhInfoDTO } from '../detail/RmhInfoDTO';
import { commentInfo } from './commentInfo';
import { BaseDTO } from '../component/BaseDTO';
import { LiveRoomDataBean } from '../live/LiveRoomDataBean';
@Observed
export class ContentDTO implements BaseDTO {
shareFlag?:string='1';
shareFlag?: string = '1';
appStyle: string = '';
cityCode: string = '';
coverSize: string = '';
... ... @@ -62,8 +63,7 @@ export class ContentDTO implements BaseDTO {
videoInfo: VideoInfoDTO = {} as VideoInfoDTO; // 视频新闻信息【BFF聚合】,视频非原片+清晰度最高的
newsSummary: string = ''; //appstyle:2 ,新闻详情
contentText?: string ='';
contentText?: string = '';
// 二次请求接口,返回的数据,这里组装到content里;
interactData?: InteractDataDTO;
hasMore: number = -1;
... ... @@ -85,6 +85,10 @@ export class ContentDTO implements BaseDTO {
// 链接类型: 0:无链接;1:内链(文章);2:外链
openType: string = '';
extra: string = ''
/*
本地辅助字段
*/
liveRoomDataBean : LiveRoomDataBean = {} as LiveRoomDataBean// 批查获取到的直播观看人数
static clone(old: ContentDTO): ContentDTO {
let content = new ContentDTO();
... ...
... ... @@ -42,6 +42,16 @@ export interface PageInfoDTO {
pageAdList:CompAdvBean[]
md5:string
/*
信息流页面,最后一个楼层的最后一个组件的信息源
lastCompSourceType = 0 从楼层接口获取数据(compinfor)
= 1 表示 直播回看数据源
*/
lastCompSourceType: number
}
export interface ChannelInfoDTO {
... ...
... ... @@ -44,7 +44,7 @@ export struct CardParser {
} else if (contentDTO.appStyle === CompStyle.Card_04) {
Card4Component({ compDTO: this.compDTO, contentDTO })
} else if (contentDTO.appStyle === CompStyle.Card_05) {
Card5Component({ contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy, compDTO: this.compDTO })
Card5Component({ contentDTO, titleShowPolicy: this.compDTO.titleShowPolicy})
} else if (contentDTO.appStyle === CompStyle.Card_06 || contentDTO.appStyle === CompStyle
.Card_13) {
Card6Component({ compDTO: this.compDTO, contentDTO: this.contentDTO })
... ...
... ... @@ -7,7 +7,8 @@ import { Card2Component } from './cardview/Card2Component';
import { Card5Component } from './cardview/Card5Component';
import { AdvCardParser } from './cardViewAdv/AdvCardParser';
import { ZhCarouselLayout01 } from './compview/ZhCarouselLayout01';
import { ZhGridLayout02 } from './compview/ZhGridLayout02';
import { CompNormalTitle } from './compview/CompNormalTitle';
import { ZhGridLayout02NewsContent } from './compview/ZhGridLayout02NewsContent';
import { ZhGridLayout03 } from './compview/ZhGridLayout03';
import { ZhSingleColumn04 } from './compview/ZhSingleColumn04';
import { ZhSingleColumn05 } from './compview/ZhSingleColumn05';
... ... @@ -37,10 +38,8 @@ export struct CompParser {
build() {
Column() {
if (this.compDTO.name != "月度排行卡") {
this.componentBuilder();
}
this.componentBuilder();
}
}
... ... @@ -75,9 +74,14 @@ export struct CompParser {
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Row_03) {
ZhSingleRow03({ compDTO: this.compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_02) {
ZhGridLayout02({ compDTO: this.compDTO })
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(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Card_Comp_Zh_Grid_Layout_02) { //双列流小视频,一行两图卡
ZhGridLayout02NewsContent({ compDTO: this.compDTO, operDataList: this.compDTO.operDataList })
} else if (this.compDTO.compStyle === CompStyle.Zh_Grid_Layout_03) {
ZhGridLayout03({ compDTO: this.compDTO })
Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
... ... @@ -105,7 +109,7 @@ export struct CompParser {
// ZhSingleColumn05({ compDTO: compDTO })
// Divider().strokeWidth(1).color('#f5f5f5').padding({ left: 16, right: 16 })
} else if (this.compDTO.compStyle === CompStyle.Zh_Single_Column_09) {
Divider().strokeWidth(3).color('#ffffff').padding({ left: 16, right: 16 }).margin({top: -3})
Divider().strokeWidth(3).color('#ffffff').padding({ left: 16, right: 16 }).margin({ top: -3 })
Divider().strokeWidth(6).color('#f5f5f5')
ZhSingleColumn09({ compDTO: this.compDTO })
Divider().strokeWidth(6).color('#f5f5f5')
... ...
... ... @@ -41,6 +41,8 @@ import { publishCommentModel } from './comment/model/PublishCommentModel';
import { CommentComponent } from './comment/view/CommentComponent';
import { EmptyComponent } from './view/EmptyComponent';
import { detailedSkeleton } from './skeleton/detailSkeleton';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG = 'DynamicDetailComponent'
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
... ... @@ -602,6 +604,7 @@ export struct DynamicDetailComponent {
this.getInteractDataStatus()
this.makeJumpInfo()
this.interactDataV2()
this.viewBlogInsightIntentShare()
}
private async interactDataV2() {
... ... @@ -761,6 +764,14 @@ export struct DynamicDetailComponent {
console.log('点赞、取消点赞==', this.newsStatusOfUser?.likeStatus, this.interactDataDTO?.likeNum)
})
}
/**
* 意图上报
*/
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactDataDTO)
}
}
interface radiusType {
... ...
... ... @@ -145,6 +145,7 @@ export struct ENewspaperPageComponent {
.onClick(() => {
this.calendarDialogShow = !this.calendarDialogShow
if (this.calendarDialogShow) {
this.calendarDialogController.open()
} else {
this.calendarDialogController.close()
... ...
... ... @@ -210,23 +210,22 @@ export struct FeedBackActivity {
.padding({ bottom: 44 })
Column(){
Text($r('app.string.submit'))
.align(Alignment.Center)
.textAlign(TextAlign.Center)
.height(44)
.width('90%')
.fontColor(this.canSubmit?$r('app.color.color_9E9E9E_40'):$r('app.color.color_fff'))
.fontColor(this.canSubmit ? $r('app.color.color_fff') : $r('app.color.color_FFFFFF_40'))
.fontSize($r('app.float.font_size_18'))
.backgroundColor(this.canSubmit?$r('app.color.color_ED2800_99'):$r('app.color.color_EDEDED'))
.backgroundColor(this.canSubmit ? $r('app.color.color_ED2800') : $r('app.color.color_ED2800_99'))
.borderRadius(4)
.onClick(async (event: ClickEvent) => {
if(await FastClickUtil.isMinDelayTime()){
if (await FastClickUtil.isMinDelayTime()) {
return
}
this.reportCommit()
})
Blank().height(15).width('100%')
.margin({bottom:20})
}
.height(59)
}
}.margin({bottom:20})
}
}
... ...
... ... @@ -31,6 +31,8 @@ import { publishCommentModel } from '../components/comment/model/PublishCommentM
import { EmptyComponent } from '../components/view/EmptyComponent';
import { CommentComponent } from '../components/comment/view/CommentComponent'
import { HttpUtils } from 'wdNetwork/Index';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const PATTERN_DATE_CN_RN: string = 'yyyy年MM月dd日 HH:mm';
... ... @@ -56,7 +58,6 @@ export struct ImageAndTextPageComponent {
@State likeNum: number = 0
@State reachEndIncreament: number = 0
@State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
build() {
Stack({ alignContent: Alignment.Top }) {
Stack({ alignContent: Alignment.Bottom }) {
... ... @@ -189,11 +190,11 @@ export struct ImageAndTextPageComponent {
.alignItems(VerticalAlign.Bottom)
Row() {
Image($r('app.media.line'))
Image($r('app.media.ic_news_detail_division'))
.width('100%')
.height(6)
.objectFit(ImageFit.Cover)
.margin({ top: 10 })
.objectFit(ImageFit.Fill)
}
.padding({ left: 15, right: 15 })
.backgroundColor(Color.White)
... ... @@ -261,10 +262,20 @@ export struct ImageAndTextPageComponent {
} else {
this.operationButtonList = ['comment', 'collect', 'share']
}
//意图上报
this.viewBlogInsightIntentShare()
}
}
}
//意图上报
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData, this.interactData)
}
private async getRecommend() {
let params: postRecommendListParams = {
imei: HttpUtils.getImei(),
... ... @@ -341,6 +352,7 @@ export struct ImageAndTextPageComponent {
}
PageRepository.getContentInteract(params).then(res => {
if (res.data) {
this.interactData = res.data[0]
this.likeNum = Number(res.data[0]?.likeNum) || 0
}
})
... ...
... ... @@ -73,15 +73,17 @@ export struct InteractMComponent {
.height('12')
}.margin({top:10,bottom:15})
}.padding({left:10,right:10}).alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)
.onClick(()=>{
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.messageModel.InteractMsubM.contentType
contentDTO.objectId = this.messageModel.InteractMsubM.contentId
ProcessUtils.processPage(contentDTO)
})
}
}.padding({left:5,right:5}).alignItems(HorizontalAlign.Start).width('90%')
}.padding({top:10,left:16,right:16}).width('100%').alignItems(VerticalAlign.Top)
.onClick(()=>{
if(this.messageModel.contentType === '211') return
let contentDTO :ContentDTO = new ContentDTO();
contentDTO.objectType = this.messageModel.InteractMsubM.contentType
contentDTO.objectId = this.messageModel.InteractMsubM.contentId
ProcessUtils.processPage(contentDTO)
})
}
buildContentString(): string {
... ...
... ... @@ -22,6 +22,8 @@ import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { PageRepository } from '../repository/PageRepository';
import { SpConstants } from 'wdConstant/Index';
import { router } from '@kit.ArkUI';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG = 'MultiPictureDetailPageComponent';
... ... @@ -467,6 +469,7 @@ export struct MultiPictureDetailPageComponent {
this.getInteractBrowsOperate()
this.getBatchAttentionStatus()
}
this.viewBlogInsightIntentShare()
})
.catch((err: Error) => {
Logger.info(TAG, `fetchDetailData then,err: ${JSON.stringify(err)}`);
... ... @@ -544,4 +547,12 @@ export struct MultiPictureDetailPageComponent {
}
})
}
/**
* 意图上报
*/
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData)
}
}
\ No newline at end of file
... ...
... ... @@ -10,6 +10,8 @@ import DetailViewModel from '../viewmodel/DetailViewModel';
import { publishCommentModel } from '../components/comment/model/PublishCommentModel';
import { EmptyComponent } from '../components/view/EmptyComponent';
import { NetworkUtil, WindowModel } from 'wdKit';
import { viewBlogItemInsightIntentShare } from '../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG: string = 'SpacialTopicPageComponent'
... ... @@ -49,6 +51,12 @@ export struct SpacialTopicPageComponent {
})
}
//意图上报
private viewBlogInsightIntentShare(){
let context = getContext(this) as common.UIAbilityContext;
viewBlogItemInsightIntentShare(context,this.contentDetailData)
}
private async getDetail() {
this.isNetConnected = NetworkUtil.isNetConnected()
... ... @@ -71,6 +79,7 @@ export struct SpacialTopicPageComponent {
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans && detailBeans.length > 0) {
this.contentDetailData = detailBeans[0];
this.viewBlogInsightIntentShare()
// if (this.contentDetailData[0]?.openComment) {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId || '')
... ...
... ... @@ -103,6 +103,10 @@ export struct RMCalendar {
nowFontColor: this.nowFontColor,
disableClick: (item: RMCalendarBean) => {
if (this.disableCellClick) {
if (!NetworkUtil.isNetConnected()) {
ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
return
}
this.disableCellClick(item)
}
},
... ...
import { RMCalendarBean } from './RMCalendarBean';
import font from '@ohos.font';
import { ToastUtils, NetworkUtil } from 'wdKit/Index';
@Component
export struct RMCalenderCell {
... ... @@ -38,6 +38,12 @@ export struct RMCalenderCell {
}
getItemColor() {
if (!NetworkUtil.isNetConnected()) {
if (this.selectItem && this.selectItem.time == this.item.time) {
return this.selectFontColor
}
return this.disabledFontColor
}
if (!this.isShowSelectBg() && this.item.isNow) {
return this.nowFontColor
} else if (this.item.isPre) {
... ... @@ -136,9 +142,11 @@ export struct RMCalenderCell {
return
// }
}
this.selectItem = this.item
if (this.cellClick) {
this.cellClick(this.item)
if (NetworkUtil.isNetConnected()) {
this.selectItem = this.item
if (this.cellClick) {
this.cellClick(this.item)
}
}
})
}
... ...
... ... @@ -8,7 +8,7 @@ export struct CardSourceInfo {
@ObjectLink compDTO: CompDTO
build() {
Flex() {
Flex({ alignItems: ItemAlign.Center }) {
if (this.contentDTO.corner) {
Text(this.contentDTO.corner)
.fontSize($r("app.float.font_size_11"))
... ... @@ -28,31 +28,45 @@ 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 ||
!this.contentDTO.isSearch && DateTimeUtils.getCommentTime
(Number
.parseFloat(this
.contentDTO.publishTime))
.indexOf
('-') === -1) {
// if (this.contentDTO.isSearch || this.contentDTO.isCollection ||
// (!this.contentDTO.isSearch &&
// DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)).indexOf('-') === -1)) {
//
// Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
// .fontSize($r("app.float.font_size_11"))
// .fontColor($r("app.color.color_B0B0B0"))
// .flexShrink(0);
// }
if (this.contentDTO.source) {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime)))
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
.flexShrink(0);
}
if (this.getContentDtoBean()?.interactData?.commentNum) {
if (this.getContentDtoBean()?.interactData?.commentNum && this.contentDTO.source) {
Text(`${this.getContentDtoBean()?.interactData?.commentNum}评`)
.fontSize($r("app.float.font_size_11"))
.fontColor($r("app.color.color_B0B0B0"))
.flexShrink(0)
.margin({ left: 6 })
.visibility(Number(this.getContentDtoBean()?.interactData?.commentNum) === 0 ? Visibility.None : Visibility.Visible)
.visibility(Number(this.getContentDtoBean()?.interactData?.commentNum) === 0 ? Visibility.None :
Visibility.Visible)
}
}
.width(CommonConstants.FULL_WIDTH)
... ... @@ -67,7 +81,7 @@ export struct CardSourceInfo {
if (this.compDTO == undefined) {
return this.contentDTO
}
if(this.compDTO.operDataList.length == 0){
if (this.compDTO.operDataList.length == 0) {
return this.contentDTO
}
return this.compDTO.operDataList[0]
... ...
... ... @@ -38,9 +38,9 @@ export struct Card11Component {
Column() {
Stack() {
if (this.contentDTO.newTags) {
Notes({ newTags: this.contentDTO.newTags })
Notes({ newTags: this.contentDTO.newTags }).height(27).align(Alignment.Center)
} else if (this.contentDTO.objectType == '5') {
Notes({ objectType: this.contentDTO.objectType })
Notes({ objectType: this.contentDTO.objectType }).height(27).align(Alignment.Center)
}
Text() {
if (this.titleMarked) {
... ... @@ -52,6 +52,7 @@ export struct Card11Component {
Span(this.contentDTO.newsTitle)
}
}
.lineHeight(27)
.fontSize($r("app.float.font_size_18"))
.fontColor(this.clicked ? 0x848484 : $r("app.color.color_222222"))
.maxLines(3)
... ... @@ -59,7 +60,7 @@ export struct Card11Component {
.width(CommonConstants.FULL_WIDTH)
.textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 30 : 0)
this.contentDTO.objectType == '5' ? 35 : 0)
}.alignContent(Alignment.TopStart)
... ...
... ... @@ -48,12 +48,12 @@ export struct Card17Component {
Span(this.contentDTO.newsTitle)
}
}
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize($r('app.float.font_size_18'))
.fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
.lineHeight(25)
.maxLines(3)
.width(CommonConstants.FULL_WIDTH)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize($r('app.float.font_size_17'))
.fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
.lineHeight(25)
.maxLines(3)
.width(CommonConstants.FULL_WIDTH)
Stack({ alignContent: Alignment.BottomEnd }) {
// 三个图,
... ... @@ -120,7 +120,7 @@ export struct Card17Component {
})
// 评论等信息
CardSourceInfo({compDTO:this.compDTO, contentDTO: this.contentDTO })
CardSourceInfo({ compDTO: this.compDTO, contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ... @@ -131,11 +131,3 @@ export struct Card17Component {
})
}
}
// 全局公共样式
@Styles
function ImageSize() {
.padding({ right: 18, left: 18 })
.width('100%')
.margin({ top: 10 })
}
\ No newline at end of file
... ...
... ... @@ -62,20 +62,7 @@ export struct Card19Component {
}
// 图片-从无图到9图展示
createImg({ fullColumnImgUrls: this.contentDTO.fullColumnImgUrls })
.onClick(() => {
const photoList: PhotoListBean[] = this.contentDTO.fullColumnImgUrls.map(item => {
const photo: PhotoListBean = {
width: item.weight,
height: item.height,
picPath: item.fullUrl||item.url,
picDesc: '',
itemType:2,
id:0
}
return photo
})
ProcessUtils.gotoMultiPictureListPage(photoList, 0)
})
CarderInteraction({ contentDTO: this.contentDTO })
//TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件
}
... ... @@ -107,12 +94,12 @@ struct createImg {
@State loadImg: boolean = false;
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
if (this.fullColumnImgUrls.length === 4) { // 为了使用栅格布局以便于占用三分之二的宽度,加一个占位
this.fullColumnImgUrls.splice(2, 0, {
fullUrl: ''
} as FullColumnImgUrlDTO)
}
this.loadImg = await onlyWifiLoadImg();
console.log('card19-this.fullColumnImgUrls',JSON.stringify(this.fullColumnImgUrls))
}
... ... @@ -167,14 +154,14 @@ struct createImg {
alignContent: Alignment.BottomEnd
}) {
if (this.getPicType() === 1) {
Image(this.loadImg ? item.fullUrl||item.url : '')
Image(this.loadImg ? item.fullUrl || item.url : '')
.backgroundColor(0xf5f5f5)
.width('100%')
.height(172)
.autoResize(true)
.borderRadius(this.caclImageRadius(index))
} else if (this.getPicType() === 2) {
Image(this.loadImg ? item.fullUrl||item.url : '')
Image(this.loadImg ? item.fullUrl || item.url : '')
.width('100%')
.height(305)
.autoResize(true)
... ... @@ -291,6 +278,20 @@ struct createImg {
.padding({ bottom: 3 })
}
}
.onClick(() => {
const photoList: PhotoListBean[] = this.fullColumnImgUrls.map(item => {
const photo: PhotoListBean = {
width: item.weight,
height: item.height,
picPath: item.fullUrl||item.url,
picDesc: '',
itemType:2,
id:0
}
return photo
})
ProcessUtils.gotoMultiPictureListPage(photoList, index)
})
}
}
})
... ...
... ... @@ -6,6 +6,7 @@ import { CardMediaInfo } from '../cardCommon/CardMediaInfo';
import { CardSourceInfo } from '../cardCommon/CardSourceInfo';
import { Notes } from './notes';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
// import { persistentStorage, hasClicked } from '../../utils/persistentStorage';
const TAG: string = 'Card2Component';
... ... @@ -48,9 +49,9 @@ export struct Card2Component {
Stack() {
//新闻标题
if (this.contentDTO.newTags) {
Notes({ newTags: this.contentDTO.newTags })
Notes({ newTags: this.contentDTO.newTags })
} else if (this.contentDTO.objectType == '5') {
Notes({ objectType: this.contentDTO.objectType })
Notes({ objectType: this.contentDTO.objectType })
}
Text() {
... ... @@ -66,15 +67,16 @@ export struct Card2Component {
.fontSize($r('app.float.font_size_18'))
.fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.align(Alignment.Start)
.textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 30 : 0)
}.alignContent(Alignment.TopStart)
//.textIndent(this.contentDTO.objectType == '5' ? 35 : 0)
// }
// .alignContent(Alignment.TopStart)
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 35 : 0)
}.alignContent(Alignment.TopStart)
//.textIndent(this.contentDTO.objectType == '5' ? 35 : 0)
// }
// .alignContent(Alignment.TopStart)
//大图
Stack() {
... ...
... ... @@ -36,9 +36,9 @@ export struct Card3Component {
Column() {
Stack() {
if (this.contentDTO.newTags) {
Notes({ newTags: this.contentDTO.newTags })
Notes({ newTags: this.contentDTO.newTags }).height(27).align(Alignment.Center)
} else if (this.contentDTO.objectType == '5') {
Notes({ objectType: this.contentDTO.objectType })
Notes({ objectType: this.contentDTO.objectType }).height(27).align(Alignment.Center)
}
Text() {
if (this.titleMarked) {
... ... @@ -56,11 +56,11 @@ export struct Card3Component {
.width(CommonConstants.FULL_WIDTH)
.textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 30 : 0)
this.contentDTO.objectType == '5' ? 35 : 0)
}.alignContent(Alignment.TopStart)
// 评论等信息
CardSourceInfo({compDTO:this.compDTO, contentDTO: this.contentDTO })
CardSourceInfo({ compDTO: this.compDTO, contentDTO: this.contentDTO })
}
.width(CommonConstants.FULL_WIDTH)
.padding({
... ...
... ... @@ -3,8 +3,6 @@ import { CommonConstants } from 'wdConstant';
import { ProcessUtils } from 'wdRouter';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
import { Notes } from './notes';
import { viewBlogInsightIntentShare, ActionMode } from '../../utils/InsightIntentShare'
import { common } from '@kit.AbilityKit';
const TAG: string = 'Card5Component';
... ... @@ -15,7 +13,6 @@ const TAG: string = 'Card5Component';
export struct Card5Component {
@State contentDTO: ContentDTO = new ContentDTO();
@Prop titleShowPolicy: number | string
@Prop compDTO: CompDTO = {} as CompDTO
@State loadImg: boolean = false;
@State clicked: boolean = false;
@State titleMarked: boolean = false;
... ... @@ -75,13 +72,12 @@ export struct Card5Component {
.width(CommonConstants.FULL_WIDTH)
.fontColor(Color.White)
.fontSize($r('app.float.font_size_18'))
.fontWeight(FontWeight.Bold)
.maxLines(2)
.align(Alignment.TopStart)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 30 : 0)
this.contentDTO.objectType == '5' ? 35 : 0)
}.alignContent(Alignment.TopStart)
}
.justifyContent(FlexAlign.Start)
... ... @@ -100,8 +96,6 @@ export struct Card5Component {
.onClick((event: ClickEvent) => {
this.clicked = true;
ProcessUtils.processPage(this.contentDTO)
let context = getContext(this) as common.UIAbilityContext;
viewBlogInsightIntentShare(context, this.contentDTO?.channelId, [this.compDTO], ActionMode.EXECUTED)
})
}
... ...
... ... @@ -54,9 +54,9 @@ export struct Card6Component {
// }
Stack() {
if (this.contentDTO.newTags) {
Notes({ newTags: this.contentDTO.newTags })
Notes({ newTags: this.contentDTO.newTags }).height(27).align(Alignment.Center)
} else if (this.contentDTO.objectType == '5') {
Notes({ objectType: this.contentDTO.objectType })
Notes({ objectType: this.contentDTO.objectType }).height(27).align(Alignment.Center)
}
Text() {
... ... @@ -69,16 +69,16 @@ export struct Card6Component {
Span(this.contentDTO.newsTitle)
}
}
.fontColor(this.clicked ? 0x848484 : 0x222222)
.fontSize(18)
.lineHeight(27)
.fontWeight(FontWeight.Normal)
.maxLines(3)
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })// 超出的部分显示省略号。
.textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 30 : 0)
.fontColor(this.clicked ? 0x848484 : 0x222222)
.fontSize(18)
.lineHeight(27)
.fontWeight(FontWeight.Normal)
.maxLines(3)
.alignSelf(ItemAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
.textIndent(this.contentDTO?.newTags?.length < 5 && this.contentDTO?.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 35 : 0)
}.alignContent(Alignment.TopStart)
}
... ... @@ -86,7 +86,7 @@ export struct Card6Component {
//bottom 评论等信息
CardSourceInfo({ compDTO: this.compDTO,contentDTO:this.contentDTO })
CardSourceInfo({ compDTO: this.compDTO, contentDTO: this.contentDTO })
}
.alignItems(HorizontalAlign.Start)
.justifyContent(FlexAlign.Start)
... ... @@ -114,7 +114,7 @@ export struct Card6Component {
bottom: $r('app.float.card_comp_pagePadding_tb')
})
.width(CommonConstants.FULL_WIDTH)
.height(this.contentDTO.appStyle === CompStyle.Card_13 ? 107 : 217)
// .height(this.contentDTO.appStyle === CompStyle.Card_13 ? 107 : 217)
.justifyContent(FlexAlign.SpaceBetween)
}
}
\ No newline at end of file
... ...
... ... @@ -13,7 +13,7 @@ const TAG: string = 'Card9Component';
@Component
export struct Card9Component {
@State contentDTO: ContentDTO = new ContentDTO();
@State loadImg: boolean = true;
// @State loadImg: boolean = true;
@State clicked: boolean = false;
@State titleMarked: boolean = false;
@State str01: string = '';
... ... @@ -38,11 +38,6 @@ export struct Card9Component {
Column() {
// 顶部标题,最多两行
if (this.contentDTO.titleShow === 1 && this.contentDTO.newsTitle) {
if (this.contentDTO.newTags) {
Notes({ newTags: this.contentDTO.newTags })
} else if (this.contentDTO.objectType == '5') {
Notes({ objectType: this.contentDTO.objectType })
}
Text() {
if (this.titleMarked) {
Span(this.str01)
... ... @@ -56,18 +51,14 @@ export struct Card9Component {
.fontColor(this.clicked ? 0x848484 : 0x222222)
.width(CommonConstants.FULL_WIDTH)
.fontSize($r('app.float.font_size_18'))
.fontWeight(600)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ bottom: 19 })
.textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
(this.contentDTO.newTags?.length != 0 && this.contentDTO.newTags?.length) ||
this.contentDTO.objectType == '5' ? 30 : 0)
.margin({ top: 10, bottom: 10 })
.fontWeight(400)
}
// 大图
Stack() {
Image(this.loadImg ? this.contentDTO.coverUrl : '')
Image(this.contentDTO.coverUrl)
.backgroundColor(0xf5f5f5)
.width('100%')
.height(133)
... ...
... ... @@ -21,8 +21,9 @@ export struct Notes {
bottom: 3
})
.linearGradient({ angle: 90, colors: [['#FFFF2B00', 0.0], ['#FFFE6A00', 1.0]] })
.fontColor(Color.White)
.borderRadius($r('app.float.button_border_radius'))
.fontColor(Color.White)// .borderRadius($r('app.float.button_border_radius'))
.borderRadius(2)
.margin({ top: 1 })
}
}
... ...
... ... @@ -19,6 +19,9 @@ const testString = '因为读书的人\n是低着头向上看的人\n身处一
@Preview
@Component
export struct CommentComponent {
private onCloseClick = () => {
}
@Prop showCloseIcon?: boolean = false
@State hasMore: boolean = true;
@State currentPage: number = 1;
@State isComments: boolean = true
... ... @@ -29,13 +32,12 @@ export struct CommentComponent {
historyOffset: number = 0; // 上次浏览到列表距离顶端的偏移量offset
@State allDatas: LazyDataSource<commentItemModel> = new LazyDataSource();
@State dialogController: CustomDialogController | null = null;
// @State private browSingModel: commentListModel = new commentListModel()
// 是否为固定高度模式。true时,里面上拉加载更多生效,外层不能包Scroll。
// false时,外层实现加载更多,并通过reachEndIncreament通知开发加载更多,reachEndLoadMoreFinish 通知上层加载更多完成
fixedHeightMode: boolean = false
@Prop @Watch("parentOnReachEnd") reachEndIncreament : number = 0
@Prop @Watch("parentOnReachEnd") reachEndIncreament: number = 0
reachEndLoadMoreFinish?: () => void
// 在自定义组件即将析构销毁时将dialogControlle置空
... ... @@ -102,6 +104,7 @@ export struct CommentComponent {
/*标题:全部评论*/
@Builder
titleHeader() {
Row() {
Row() {
Image($r('app.media.redLine'))
... ... @@ -112,18 +115,29 @@ export struct CommentComponent {
.fontColor($r('app.color.color_222222'))
.fontWeight(FontWeight.Medium)
.margin({ left: 5 })
}
.margin({ left: 16 })
.onClick(() => {
// this.allDatas.push(new commentItemModel())
// this.allDatas.addFirstItem(new commentItemModel())
// this.allDatas.reloadData();
})
}.height(44)
Image($r('app.media.close_button'))
.height(16)
.width(16)
.margin({ right: 16 })
.visibility(this.showCloseIcon ? Visibility.Visible : Visibility.Hidden)
.onClick(() => {
this.onCloseClick()
})
}
.height(44)
.width('100%')
.justifyContent(FlexAlign.SpaceBetween);
.justifyContent(FlexAlign.SpaceBetween)
.onClick(() => {
// this.allDatas.push(new commentItemModel())
// this.allDatas.addFirstItem(new commentItemModel())
// this.allDatas.reloadData();
})
}
/*1级评论作为titleHeader*/
... ... @@ -200,7 +214,7 @@ export struct CommentComponent {
}
}
}
.margin({bottom: 10})
.margin({ bottom: 10 })
.onReachEnd(() => {
if (!this.fixedHeightMode) {
return
... ... @@ -209,7 +223,8 @@ export struct CommentComponent {
this.getData()
}
})
.enableScrollInteraction(this.fixedHeightMode ? true: false)
.enableScrollInteraction(this.fixedHeightMode ? true : false)
// .nestedScroll({
// scrollForward: NestedScrollMode.PARENT_FIRST,
// scrollBackward: NestedScrollMode.SELF_FIRST
... ...
import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { Logger } from 'wdKit/Index';
import { ProcessUtils } from 'wdRouter';
import PageViewModel from '../../viewmodel/PageViewModel';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
/**
* 通用标题组件
*
*/
@Component
export struct CompNormalTitle {
@State compDTO: CompDTO = new CompDTO
aboutToAppear() {
}
build() {
Column() {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
.justifyContent(FlexAlign.Start)
.margin({ top: 16, bottom: 10 })
.width(CommonConstants.FULL_WIDTH)
}
.width(CommonConstants.FULL_WIDTH)
.padding({ left: 16, right: 16 })
}
}
... ...
import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { Logger } from 'wdKit/Index';
import { ProcessUtils } from 'wdRouter';
import PageViewModel from '../../viewmodel/PageViewModel';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
const TAG = 'Zh_Grid_Layout-02';
const FULL_PARENT: string = '100%';
let listSize: number = 2;
/**
* 双图卡
* 枚举值Zh_Grid_Layout-02
* Zh_Grid_Layout-02
*
*/
@Component
export struct ZhGridLayout02 {
@State compDTO: CompDTO = {} as CompDTO
@State operDataList: ContentDTO[] = []
@State loadImg: boolean = false;
@State liveRoomList: LiveRoomDataBean[] = []
currentPage = 1
pageSize = 12
async aboutToAppear(): Promise<void> {
Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle)
this.currentPage = 1
PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {
this.operDataList = []
this.operDataList.push(...liveReviewDTO.list)
this.getLiveRoomDataInfo(this.operDataList)
})
this.loadImg = await onlyWifiLoadImg();
}
build() {
Column() {
Scroll() {
Column() {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(this.compDTO.objectTitle)
.fontSize($r("app.float.font_size_17"))
.fontColor($r("app.color.color_222222"))
.fontWeight(600)
}
.justifyContent(FlexAlign.Start)
.margin({ top: 16, bottom: 8 })
.width(CommonConstants.FULL_WIDTH)
GridRow({
gutter: { x: 12, y: 13 },
columns: { sm: listSize, md: 2 },
breakpoints: { value: ['320vp', '520vp', '840vp'] }
}) {
ForEach(this.operDataList, (item: ContentDTO, index: number) => {
GridCol() {
this.buildItemCard(item);
}
})
}
}
}
.width("100%")
.height("100%")
// .layoutWeight(1)
.edgeEffect(EdgeEffect.None)
.scrollBar(BarState.Off)
.onReachStart(() => {
Logger.debug(TAG, 'onReachStart')
})
.onReachEnd(() => {
Logger.debug(TAG, 'onReachEnd')
this.addItems()
})
.nestedScroll({
scrollForward: NestedScrollMode.PARENT_FIRST,
scrollBackward: NestedScrollMode.SELF_FIRST
})
}
.width(CommonConstants.FULL_WIDTH)
// .width("100%")
.height("100%")
.padding({ left: 16, right: 16 })
// .layoutWeight(1)
}
/**
* 组件项
*
* @param programmeBean item 组件项, 上面icon,下面标题
*/
@Builder
buildItemCard(item: ContentDTO) {
Column() {
Stack({ alignContent: Alignment.BottomEnd }) {
Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')
.backgroundColor(0xf5f5f5)
.width('100%')
.height(95)
.borderRadius(4)
if (this.getLiveRoomNumber(item).length > 0) {
Text(this.getLiveRoomNumber(item))
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
.margin({
right: '5vp',
bottom: '5vp'
})
}
}
Text(item.newsTitle)
.margin({top:'6'})
.fontSize(13)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
.width('100%')
.onClick(() => {
ProcessUtils.processPage(item)
})
}
// 获取评论数
async getLiveRoomDataInfo(list: ContentDTO[]) {
const reserveIds = this.getLiveDetailIds(list)
PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
if (result && result.length > 0) {
this.liveRoomList.push(...result)
}
}).catch(() => {
})
}
// 判断是否预约
getLiveRoomNumber(item: ContentDTO): string {
const objc = this.liveRoomList.find((element: LiveRoomDataBean) => {
return element.liveId.toString() == item.objectId
})
if (objc && objc.pv && objc.pv > 0) {
return this.computeShowNum(objc.pv)
}
return ''
}
addItems() {
Logger.debug(TAG, 'addItems')
this.currentPage++
PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {
this.operDataList.push(...liveReviewDTO.list)
this.getLiveRoomDataInfo(this.operDataList)
Logger.debug(TAG, 'addItems after: ' + this.operDataList.length)
})
}
private getLiveDetailIds(list: ContentDTO[]): string {
let idList: string[] = []
list.forEach(item => {
idList.push(item.objectId)
});
return idList.join(',')
}
private computeShowNum(count: number): string {
if (count >= 10000) {
let num = (count / 10000).toFixed(1)
if (Number(num.substring(num.length - 1)) == 0) {
num = num.substring(0, num.length - 2)
}
return num + '万人参加'
}
return `${count}人参加`
}
}
import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean';
import { CommonConstants } from 'wdConstant/Index';
import { Logger } from 'wdKit/Index';
import { ProcessUtils } from 'wdRouter';
import PageViewModel from '../../viewmodel/PageViewModel';
import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
let listSize: number = 2;
/**
* 双图卡 的标题组件
*
*/
@Component
export struct ZhGridLayout02NewsContent {
@ObjectLink compDTO: CompDTO
@State operDataList: ContentDTO[] = []
@State loadImg: boolean = false;
async aboutToAppear(): Promise<void> {
this.loadImg = await onlyWifiLoadImg();
}
build() {
GridRow({
gutter: { x: 9, y: 0 },
columns: { sm: listSize, md: listSize },
breakpoints: { value: ['320vp', '520vp', '840vp'] }
}) {
ForEach(this.operDataList, (item: ContentDTO, index: number) => {
GridCol() {
this.buildItemCard(item, index);
}
})
}.width("100%").padding({ left: 16, right: 16 })
}
@Builder
buildItemCard(item: ContentDTO, index: number) {
Column() {
Stack({ alignContent: Alignment.BottomEnd }) {
Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')
.backgroundColor(0xf5f5f5)
.width('100%')
.height(95)
.borderWidth(0.5)
.borderColor($r('app.color.color_0D000000'))
.borderRadius(4)
if (this.compDTO.operDataList[index].liveRoomDataBean != undefined
&& this.compDTO.operDataList[index].liveRoomDataBean?.pv != undefined) {
Text(this.computeShowNum(this.compDTO.operDataList[index].liveRoomDataBean))
.fontSize(12)
.fontWeight(400)
.fontColor(Color.White)
.textShadow({ radius: 2, color: 'rgba(0,0,0,0.3)', offsetX: 0, offsetY: 2 })
.margin({
right: '5vp',
bottom: '5vp'
})
}
}
Text(item.newsTitle)
.margin({ top: 8, bottom: 14 })
.fontSize(15)
.maxLines(2)
.lineHeight(21)
.width('100%')
.textAlign(TextAlign.Start)
.textOverflow({ overflow: TextOverflow.Ellipsis })
}
.width('100%')
.onClick(() => {
ProcessUtils.processPage(item)
})
}
private computeShowNum(bean: LiveRoomDataBean): string {
let count = bean.pv
if (count >= 10000) {
let num = (count / 10000).toFixed(1)
if (Number(num.substring(num.length - 1)) == 0) {
num = num.substring(0, num.length - 2)
}
return num + '万人参加'
}
return `${count}人参加`
}
}
... ...
... ... @@ -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"))
... ... @@ -36,7 +36,8 @@ export struct ZhSingleRow04 {
.width(14)
.height(14)
}
.visibility(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '' ? Visibility.None : Visibility.Visible)
.visibility(this.compDTO?.objectType === '0' || this.compDTO?.objectType === '' ? Visibility.None :
Visibility.Visible)
.onClick(() => {
if (this.compDTO?.objectType === '11') {
ProcessUtils.jumpChannelTab(this.compDTO.objectId, this.compDTO.pageId as string, this.compDTO.objectTitle)
... ... @@ -64,9 +65,11 @@ export struct ZhSingleRow04 {
operDataListItem: item
}
)
.margin({right: index === this.compDTO.operDataList.length - 1 ? 26 : 0, left:
index === 0 ? $r('app.float.card_comp_pagePadding_lf') : 0,
top: 6})
.margin({
right: index === this.compDTO.operDataList.length - 1 ? 26 : 0, left:
index === 0 ? $r('app.float.card_comp_pagePadding_lf') : 0,
top: 6
})
.onClick(() => {
ProcessUtils.processPage(item)
})
... ... @@ -106,8 +109,7 @@ struct localCard {
.align(Alignment.TopStart)
.maxLines(3)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.lineHeight(20)
.margin({bottom: 17})
.lineHeight(25)
.fontWeight(500)
Row() {
Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.operDataListItem.publishTime)))
... ... @@ -115,7 +117,7 @@ struct localCard {
.fontColor($r("app.color.color_B0B0B0"))
.margin({ right: 5 })
// 这里需要外部查询评论接口后,写入字段
if(this.operDataListItem.interactData?.commentNum) {
if (this.operDataListItem.interactData?.commentNum) {
Text(`${this.operDataListItem.interactData?.commentNum}评`)
.fontSize(12)
}
... ... @@ -139,7 +141,12 @@ struct localCard {
.border({
radius: 2,
})
.shadow({ radius: 6, color: '#1A000000', offsetX: 3, offsetY: 0 })
.shadow({
radius: 6,
color: '#1A000000',
offsetX: 0,
offsetY: 3
}) // 设置下方阴影
.margin({
right: 10
})
... ...
... ... @@ -30,6 +30,7 @@ export struct ZhSingleRow06 {
this.loadImg = await onlyWifiLoadImg();
}
/**
* 点赞、取消点赞
*/
... ... @@ -43,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,
... ... @@ -51,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))
})
}
... ... @@ -168,7 +170,7 @@ export struct ZhSingleRow06 {
? item.operDataList[0]?.commentInfo?.userHeaderUrl
? item.operDataList[0].commentInfo.userHeaderUrl
: $r('app.media.default_head')
: $r('app.media.comment_rmh_tag'))
: $r('app.media.icon_default_head_mater'))
.width(32)
.height(32)
.borderRadius(16)
... ...
... ... @@ -5,6 +5,8 @@ import { MineAppointmentItem } from '../../../viewmodel/MineAppointmentItem';
import { LazyDataSource, StringUtils } from 'wdKit';
import MinePageDatasModel from '../../../model/MinePageDatasModel';
import { EmptyComponent } from '../../view/EmptyComponent';
import { Action } from 'wdBean/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
const TAG = "AppointmentListUI"
... ... @@ -42,6 +44,17 @@ export struct AppointmentListUI {
}
.onClick(() => {
//TODO 跳转
let action = {
type:"2",
params:{
extra:{
relId:item.relId,
relType:item.relType.toString()
},
contentID:item.liveId.toString()
}
} as Action
WDRouterRule.jumpWithPage(WDRouterPage.detailPlayLiveCommon, action)
})
}, (item: MineAppointmentItem, index: number) => index.toString())
... ...
... ... @@ -34,7 +34,7 @@ export struct ChildCommentComponent {
.borderRadius(50)
}.width('89lpx')
.height('89lpx')
.margin({ right: '15lpx' })
.margin({ right: '3lpx' })
Column() {
Text(this.data.fromUserName)
... ...
... ... @@ -45,10 +45,11 @@ struct EditUserIntroductionPage {
Divider()
.margin(20)
Text('1、账号中(头像、昵称等)不允许含有违禁违规内容;\n2、最多60个字,只能输入中文、数字、英文字母。')
.fontSize(13)
.padding(12)
.fontColor(Color.Gray).lineHeight(25)
Row(){
Text('1、账号中(头像、昵称等)不允许含有违禁违规内容;\n2、最多16个字,只能输入中文、数字、英文字母。')
.fontSize(13)
.fontColor(Color.Gray).lineHeight(25)
}.padding({left:16}).width('100%')
Button('保存')
.type(ButtonType.Normal)
... ...
... ... @@ -47,10 +47,12 @@ struct EditUserNikeNamePage {
Divider()
.margin(20)
Text('1、账号中(头像、昵称等)不允许含有违禁违规内容;\n2、最多16个字,只能输入中文、数字、英文字母。')
.fontSize(13)
.padding(12)
.fontColor(Color.Gray).lineHeight(25)
Row(){
Text('1、账号中(头像、昵称等)不允许含有违禁违规内容;\n2、最多16个字,只能输入中文、数字、英文字母。')
.fontSize(13)
.fontColor(Color.Gray).lineHeight(25)
}.padding({left:16}).width('100%')
Button('保存')
.type(ButtonType.Normal)
... ...
... ... @@ -69,7 +69,15 @@ struct InteractMessagePage {
// 下拉刷新
ForEach(this.allDatas, (InteractM: InteractMessageModel, compIndex: number) => {
ListItem() {
InteractMComponent({messageModel:InteractM})
Column(){
InteractMComponent({messageModel:InteractM})
Divider()
.color('#f5f5f5')
.width('100%')
.strokeWidth(1)
.padding({left:16,right:16,top:16})
}
}
})
// 加载更多
... ...
import { ContentDTO, LiveRoomDataBean } from 'wdBean';
import { ProcessUtils } from 'wdRouter';
import { CommonConstants } from 'wdConstant/Index';
import PageViewModel from '../../viewmodel/PageViewModel';
import { DateTimeUtils, LazyDataSource, Logger } from 'wdKit/Index';
import { router } from '@kit.ArkUI';
... ... @@ -9,11 +8,16 @@ import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
import { EmptyComponent } from '../view/EmptyComponent';
import { ErrorComponent } from '../view/ErrorComponent';
import LoadMoreLayout from '../page/LoadMoreLayout'
import { LottieView } from '../../components/lottie/LottieView'
import LoadMoreLayout from '../page/LoadMoreLayout';
import { LottieView } from '../../components/lottie/LottieView';
import dataPreferences from '@ohos.data.preferences';
import { BusinessError } from '@ohos.base';
const TAG: string = 'LiveMorePage';
const PREFERENCES_NAME = 'rmrLiveMorePage.db'
let preferenceTheme: dataPreferences.Preferences | null = null
/**
* 直播更多:
* type=1 直播
... ... @@ -38,7 +42,13 @@ struct LiveMorePage {
@State viewType: ViewType = ViewType.LOADING
private scroller: Scroller = new Scroller()
@State liveRoomList: LiveRoomDataBean[] = []
aboutToAppear(): void {
// 点击过的数据
@State clickDatas: Array<string> = []
async aboutToAppear() {
await this.getPreferencesFromStorage()
this.getLivMoreClickPreference()
Logger.debug(TAG, '数据:' + JSON.stringify(this.clickDatas))
this.currentPage = 1
this.getData()
}
... ... @@ -94,10 +104,9 @@ struct LiveMorePage {
LoadingLayout() {
}
@Builder
ListLayout() {
List({scroller: this.scroller}) {
List({ scroller: this.scroller }) {
// 下拉刷新
LazyForEach(this.data, (contentDTO: ContentDTO) => {
ListItem() {
... ... @@ -121,7 +130,7 @@ struct LiveMorePage {
.height('calc(100% - 44vp)')
.onReachEnd(() => {
Logger.debug(TAG, "触底了");
if(!this.isLoading && this.hasMore){
if (!this.isLoading && this.hasMore) {
//加载分页数据
this.currentPage++;
this.getData()
... ... @@ -138,11 +147,12 @@ struct LiveMorePage {
buildItem(item: ContentDTO) {
Column() {
Text(item.newsTitle)
.fontSize(17)
.fontSize(18)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.margin({ top: 16, bottom: 8 })
.alignSelf(ItemAlign.Start)
.fontColor(this.isClicked(item.objectId) ? $r('app.color.color_848484') : $r('app.color.color_222222'))
Stack() {
if (item.fullColumnImgUrls && item.fullColumnImgUrls.length > 0) {
Image(item.fullColumnImgUrls[0].url)
... ... @@ -192,6 +202,7 @@ struct LiveMorePage {
}
.width('100%')
.onClick(() => {
this.clickRowBuildItem(item)
ProcessUtils.processPage(item)
})
}
... ... @@ -293,14 +304,14 @@ struct LiveMorePage {
}
this.data.push(...liveReviewDTO.list)
this.getLiveRoomDataInfo(liveReviewDTO.list)
} else {
} else {
this.hasMore = false;
}
this.resolveEnd(true, resolve)
if (liveReviewDTO.list.length == 0 && this.currentPage == 1) {
this.viewType = ViewType.EMPTY
}
}catch (exception) {
} catch (exception) {
this.resolveEnd(false, resolve)
}
// PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => {
... ... @@ -316,7 +327,7 @@ struct LiveMorePage {
if (resolve) {
if (this.currentPage == 1 && isTop) {
resolve('已更新至最新')
}else {
} else {
resolve('')
}
}
... ... @@ -335,23 +346,24 @@ struct LiveMorePage {
});
return idList.join(',')
}
// 获取评论数
async getLiveRoomDataInfo(list: ContentDTO[]) {
const reserveIds = this.getLiveDetailIds(list)
Logger.debug(TAG,'是否预约数据:' +` ${reserveIds}`)
Logger.debug(TAG, '是否预约数据:' + ` ${reserveIds}`)
PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(result)}`)
Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(result)}`)
if (result && result.length > 0) {
this.liveRoomList.push(...result)
this.data.reloadData()
}
}).catch(() =>{
}).catch(() => {
// this.data.push(...list)
})
}
// 判断是否预约
getLiveRoomNumber(item: ContentDTO): string {
getLiveRoomNumber(item: ContentDTO): string {
const objc = this.liveRoomList.find((element: LiveRoomDataBean) => {
return element.liveId.toString() == item.objectId
})
... ... @@ -363,14 +375,64 @@ struct LiveMorePage {
private computeShowNum(count: number): string {
if (count >= 10000) {
let num = ( count / 10000).toFixed(1)
if (Number(num.substring(num.length-1)) == 0) {
num = num.substring(0, num.length-2)
let num = (count / 10000).toFixed(1)
if (Number(num.substring(num.length - 1)) == 0) {
num = num.substring(0, num.length - 2)
}
return num + '万人参加'
}
return `${count}人参加`
}
isClicked(objectId: string) {
return this.clickDatas.includes(objectId)
}
clickRowBuildItem(item: ContentDTO) {
if (item.objectId && !this.clickDatas.includes(item.objectId)) {
Logger.debug(TAG, '数据:' + JSON.stringify(this.clickDatas))
this.clickDatas.push(item.objectId.toString())
this.putLiveMoreClickPreference()
}
}
async getPreferencesFromStorage() {
let context = getContext(this) as Context
preferenceTheme = await dataPreferences.getPreferences(context, PREFERENCES_NAME)
}
putLiveMoreClickPreference() {
Logger.info(TAG, `Put begin` + JSON.stringify(this.clickDatas))
if (preferenceTheme !== null && this.clickDatas.length > 0) {
// await
const arr: Array<string> = []
arr.push(...this.clickDatas)
preferenceTheme.put('liveMorePage', arr).then(() => {
Logger.debug(TAG,"Succeeded in putting value of 'startup'.");
}).catch((err: BusinessError) => {
Logger.debug(TAG, "Failed to put value of 'startup'. code =" + err.code + ", message =" + err.message);
})
// await preferenceTheme.flush()
preferenceTheme.flush((err: BusinessError) => {
if (err) {
Logger.debug(TAG, "Failed to flush. code =" + err.code + ", message =" + err.message);
return;
}
})
}
}
getLivMoreClickPreference() {
Logger.info(TAG, `Get begin`)
if (preferenceTheme !== null) {
preferenceTheme.get('liveMorePage', []).then((data: dataPreferences.ValueType) => {
if (data instanceof Array) {
this.clickDatas = data as Array<string>
}
}).catch((err: BusinessError) => {
console.error("Failed to get value of 'startup'. code =" + err.code + ", message =" + err.message);
})
}
}
}
\ No newline at end of file
... ...
... ... @@ -20,6 +20,7 @@ struct MyCollectionListPage {
@State private browSingModel: PageModel = new PageModel()
isloading : boolean = false
@Provide isEditState:boolean = false
@State isDisplayButton:boolean = false
@State allDatas :ContentDTO[] = [];
@State selectDatas :ContentDTO[] = [];
@Provide deleteNum :number = 0;
... ... @@ -48,7 +49,7 @@ struct MyCollectionListPage {
build() {
Column(){
CustomTitleAndEditUI({titleName:'我的收藏',isDisplayButton:this.browSingModel.viewType == ViewType.ERROR || this.browSingModel.viewType == ViewType.EMPTY?false:true,editCallback:()=>{
CustomTitleAndEditUI({titleName:'我的收藏',isDisplayButton:this.isDisplayButton,editCallback:()=>{
this.allSelectDatas(false)
this.isAllSelect = false
this.selectDatas = []
... ... @@ -159,16 +160,19 @@ struct MyCollectionListPage {
} else {
this.browSingModel.hasMore = true;
}
this.isDisplayButton = true;
} else {
if (this.currentPage === 1) {
this.browSingModel.viewType = ViewType.EMPTY;
this.browSingModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoCollection
this.isDisplayButton = false;
}
}
})
} else {
this.browSingModel.viewType = ViewType.EMPTY;
this.browSingModel.emptyType = WDViewDefaultType.WDViewDefaultType_NoNetwork;
this.isDisplayButton = false;
}
}
... ... @@ -231,6 +235,7 @@ struct MyCollectionListPage {
if (this.allDatas.length === 0) {
this.browSingModel.viewType = ViewType.EMPTY;
this.browSingModel.hasMore === true
this.isDisplayButton = false;
}
}
... ...
... ... @@ -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)
}
... ...
... ... @@ -5,6 +5,7 @@
import { BottomNavDTO, TopNavDTO } from 'wdBean/Index'
import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index';
import { PageComponent } from './PageComponent';
import { WDRouterPage, WDRouterRule } from 'wdRouter';
const TAG = 'VideoChannelPage'
... ... @@ -67,44 +68,66 @@ export struct VideoChannelPage {
@Builder
topNavView() {
Row() {
ForEach(this.topNavList, (item: TopNavDTO, index: number) => {
Column() {
Text(item.name)
.fontSize($r('app.float.selected_text_size'))
.fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal)
.fontColor(this.getTopNavFontColor(item, index))
.padding({
top: $r('app.float.top_tab_item_padding_top'),
bottom: $r('app.float.top_tab_item_padding_bottom')
})
.maxLines(this.MAX_LINE)
Stack({alignContent: Alignment.TopEnd}) {
Row() {
ForEach(this.topNavList, (item: TopNavDTO, index: number) => {
Column() {
Text(item.name)
.fontSize($r('app.float.selected_text_size'))
.fontWeight(this.currentTopNavSelectedIndex === index ? FontWeight.Bold : FontWeight.Normal)
.fontColor(this.getTopNavFontColor(item, index))
.padding({
top: $r('app.float.top_tab_item_padding_top'),
bottom: $r('app.float.top_tab_item_padding_bottom')
})
.maxLines(this.MAX_LINE)
Row()
.width(20)
.height(3)
.backgroundImage($r('app.media.icon_channel_active'), ImageRepeat.NoRepeat)
.backgroundImageSize(ImageSize.Contain)
.visibility(this.currentTopNavSelectedIndex === index ? Visibility.Visible : Visibility.Hidden)
Row()
.width(20)
.height(3)
.backgroundImage($r('app.media.icon_channel_active'), ImageRepeat.NoRepeat)
.backgroundImageSize(ImageSize.Contain)
.visibility(this.currentTopNavSelectedIndex === index ? Visibility.Visible : Visibility.Hidden)
}
.padding({
left: $r('app.float.top_tab_item_padding_horizontal'),
right: $r('app.float.top_tab_item_padding_horizontal'),
})
.onClick(() => {
if (this.currentTopNavSelectedIndex === index) {
this.autoRefresh++
}
this.currentTopNavSelectedIndex = index
this.swiperController.changeIndex(index, true)
.padding({
left: $r('app.float.top_tab_item_padding_horizontal'),
right: $r('app.float.top_tab_item_padding_horizontal'),
})
.onClick(() => {
if (this.currentTopNavSelectedIndex === index) {
this.autoRefresh++
}
this.currentTopNavSelectedIndex = index
this.swiperController.changeIndex(index, true)
})
}, (item: TopNavDTO) => item.channelId + '')
}
.width('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(this.currentTopNavSelectedIndex === 0 ? Color.Transparent : Color.White)
// 搜索按钮
Row() {
Image($r('app.media.icon_search'))
.width('24vp')
.height('24vp')
}
.width('40vp')
.margin({
right: '10vp',
top: '3vp',
})
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.onClick(() => {
WDRouterRule.jumpWithPage(WDRouterPage.searchPage)
})
.backgroundColor(Color.Transparent)
})
}, (item: TopNavDTO) => item.channelId + '')
}
.width('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(this.currentTopNavSelectedIndex === 0 ? Color.Transparent : Color.White)
}
@Builder
... ...
import { PeopleShipRecommendHeadComponent } from './PeopleShipRecommendHeadComponent'
import { RmhRecommendDTO } from 'wdBean';
import { faceDetector } from '@kit.CoreVisionKit';
@Component
export struct PeopleShipRecommendComponent {
... ... @@ -75,8 +74,8 @@ export struct PeopleShipRecommendComponent {
}
.columnsTemplate('1fr 1fr 1fr')
.columnsGap(20)
.rowsGap(20)
.height(Math.ceil(this.rmhList.length / 3.0) * 136)
.rowsGap(16)
.height(Math.ceil(this.rmhList.length / 3.0) * 132)
.backgroundColor(Color.Transparent)
.margin({
right: '20vp',
... ... @@ -86,7 +85,7 @@ export struct PeopleShipRecommendComponent {
// 为你推荐
Button(this.rmhSelectedList.length == 0 ? '一键关注' : `一键关注 (${this.rmhSelectedList.length})`, { type: ButtonType.Normal, stateEffect: this.rmhSelectedList.length != 0 })
.margin({
top: '24vp',
top: '10vp',
bottom: '10vp'
})
.width('120vp')
... ... @@ -105,6 +104,8 @@ export struct PeopleShipRecommendComponent {
})
}
.width('100%')
.justifyContent(FlexAlign.Start)
}
// 选中
... ...
... ... @@ -115,6 +115,7 @@ export struct PeopleShipHomeAttentionComponent {
.onClick(() => {
ToastUtils.showToast('分享为公共方法,待开发', 1000);
})
.visibility(Visibility.Hidden)
}
... ...
... ... @@ -28,7 +28,7 @@ const TAG: string = 'ReserveMorePage';
@Component
struct ReserveMorePage {
@State data: LazyDataSource<ContentDTO> = new LazyDataSource();
@State reserveList: ReserveItemBean[] = []
private reserveList: ReserveItemBean[] = []
topSafeHeight: number = AppStorage.get<number>('topSafeHeight') as number;
type: number = 2;
pageSize: number = 20;
... ... @@ -130,7 +130,10 @@ struct ReserveMorePage {
Image(item.fullColumnImgUrls[0]?.url)
.width('100%')
.objectFit(ImageFit.Contain)
.borderRadius(4)
.borderRadius({
topLeft: '4vp',
topRight: '4vp'
})
this.LiveImage()
}
... ... @@ -312,8 +315,15 @@ struct ReserveMorePage {
Logger.debug(TAG,'是否关注元数据2:' +` ${JSON.stringify(element.subscribe)}`)
element.subscribe = !element.subscribe
Logger.debug(TAG,'是否关注元数据3:' +` ${JSON.stringify(element.subscribe)}`)
this.data.reloadData()
this.isShow = true
if (element.subscribe) {
this.reservedIds.push(element.liveId.toString())
}else {
const num = this.reservedIds.indexOf(element.liveId.toString())
if (num >= 0 && num < this.reservedIds.length) {
this.reservedIds.splice(num, 1)
}
}
}
}
})
... ... @@ -349,6 +359,7 @@ struct ReserveMorePage {
if (this.currentPage == 1) {
this.data.clear()
this.reserveList = []
this.reservedIds = []
}
this.data.push(...liveReviewDTO.list)
//批量查询关注状态
... ... @@ -396,7 +407,12 @@ struct ReserveMorePage {
Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(result)}`)
if (result && result.length > 0) {
this.reserveList.push(...result)
this.data.reloadData()
// this.reserveStatus = res;
result.map((item: ReserveItemBean) => {
if (item.subscribe) {
this.reservedIds.push(item.liveId.toString())
}
})
}
}).catch(() =>{
// this.data.push(...list)
... ... @@ -409,11 +425,7 @@ struct ReserveMorePage {
// 判断是否预约
isReserved(item: ContentDTO) {
const objc = this.getAttentionItem(item)
if (objc) {
return objc.subscribe
}
return false
return this.reservedIds.includes(item.objectId)
}
getAttentionItem(item: ContentDTO) {
... ... @@ -460,9 +472,17 @@ struct ReserveMorePage {
Logger.debug(TAG,'是否关注元数据:' +` ${JSON.stringify(element.subscribe)}`)
element.subscribe = !element.subscribe
Logger.debug(TAG,'是否关注元数据1:' +` ${JSON.stringify(element.subscribe)}`)
this.data.reloadData()
if (element.subscribe) {
this.reservedIds.push(element.liveId.toString())
}else {
const num = this.reservedIds.indexOf(element.liveId.toString())
if (num >= 0 && num < this.reservedIds.length) {
this.reservedIds.splice(num, 1)
}
}
}
})
}
this.isLoadingAttention = false
this.liveId = ''
... ... @@ -487,15 +507,12 @@ struct ReserveMorePage {
const eventMinutes = eventDateTime.getMinutes();
const eventTimeStr = `${eventHour}:${eventMinutes.toString().padStart(2, '0')}开始`; // 格式化时间,确保分钟是两位数
// 计算时间差
const timeDifference = eventDateTime.getTime() - currentDateTime.getTime();
// 如果事件在24小时内
if (type === 1) {
if (timeDifference > 0 && timeDifference <= 24 * 60 * 60 * 1000) {
// 如果是今天
if (eventDateTime.setHours(0,0,0,0) === currentDateTime.setHours(0,0,0,0)) {
return `今天`;
} else {
// 如果事件不在24小时内
// 如果事件不在今天
const month = eventDateTime.getMonth() + 1; // 月份从0开始
const date = eventDateTime.getDate();
return `${month}月${date}日`;
... ...
import lottie, { AnimationItem } from '@ohos/lottie';
import { PullToRefresh, PullToRefreshConfigurator } from '@ohos/pulltorefresh';
import { LazyDataSource } from 'wdKit';
import { LazyDataSource, Logger } from 'wdKit/Index';
@Component
export struct CustomPullToRefresh {
export struct CustomPullToRefresh {
@Link alldata: Object[] | LazyDataSource<Object>;
scroller: Scroller = new Scroller();
@BuilderParam customList: () => void;
... ... @@ -12,28 +13,238 @@ export struct CustomPullToRefresh {
}
///是否存在上拉更多
@Prop @Watch('hasMoreChange') hasMore: boolean = true
refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator().setHasLoadMore(this.hasMore);
refreshConfigurator: PullToRefreshConfigurator = new PullToRefreshConfigurator()
.setHasLoadMore(this.hasMore)
.setAnimDuration(500);
private refreshSettings: RenderingContextSettings = new RenderingContextSettings(true)
private refreshContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.refreshSettings)
private loadMoreSettings: RenderingContextSettings = new RenderingContextSettings(true)
private loadMoreContext: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.loadMoreSettings)
private refreshAnimation: AnimationItem | null = null;
private loadMoreAnimation: AnimationItem | null = null;
private refreshAnimName: string = "refresh";
private refreshingAnimName: string = "refreshing";
private loadMoreAnimName: string = "loadMore";
private refreshAnimationDestroy = true
// refresh-1,refreshing-2,refreshed-3,idle-4
@State @Watch('stateChange') private refreshState: number = 4;
build() {
Column(){
Column() {
PullToRefresh({
data:$alldata,
scroller:this.scroller,
refreshConfigurator:this.refreshConfigurator,
customList:()=>{
this.customList();
data: $alldata,
scroller: this.scroller,
refreshConfigurator: this.refreshConfigurator,
customList: () => {
this.customList();
},
onRefresh:()=>{
return new Promise<string>((resolve, reject) => {
this.onRefresh(resolve)
onRefresh: () => {
return new Promise<string>((success, error) => {
new Promise<string>((resolve) => {
this.onRefresh(resolve)
}).then((text) => {
setTimeout(()=>{
// 延时500,展示第二段动画 TODO 是否去掉?
this.refreshState = 3
this.refreshDestroy()
setTimeout(() => {
success(text)
}, 500)
setTimeout(() => {
this.refreshState = 4
// 延时将状态改为空闲,组件closeRefresh做了延时,不能配置,这里配合延时
}, 1200)
},500)
})
});
},
onLoadMore:()=>{
onLoadMore: () => {
return new Promise<string>((resolve, reject) => {
this.onLoadMore(resolve)
this.onLoadMore(resolve)// TODO 加层promise处理,延长动画时间
});
},
customLoad: null,
customRefresh: null,
customLoad: () => {
this.customLoadMoreView()
},
// 可选项,自定义下拉刷新动画布局
customRefresh: () => {
this.customRefreshView()
},
// 可选项,下拉中回调
onAnimPullDown: (value, width, height) => {
this.refreshState = 1
// Logger.error('zzzz', 'onAnimPullDown, ' + value + ', ' + width + ', ' + height)
this.refreshAnim(value)
},
// 可选项,刷新中回调
onAnimRefreshing: (value, width, height) => {
if (this.refreshState < 2) {
this.refreshState = 2
}
// Logger.error('zzzz', 'onAnimRefreshing, ' + value + ', ' + width + ', ' + height)
this.refreshingAnim()
},
})
}
}
/**
* 销毁所有动画
*/
private refreshDestroy() {
lottie.destroy(this.refreshAnimName);
lottie.destroy(this.refreshingAnimName);
this.refreshAnimation?.removeEventListener('DOMLoaded')
this.refreshAnimation?.removeEventListener('destroy')
this.refreshAnimation = null
}
@Builder
private customRefreshView() {
Stack({ alignContent: Alignment.Center }) {
Canvas(this.refreshContext)
.width(60)
.height(60)
.backgroundColor(Color.Transparent)
.onReady(() => {
// 可在此生命回调周期中加载动画,可以保证动画尺寸正确
//抗锯齿的设置
this.refreshContext.imageSmoothingEnabled = true;
this.refreshContext.imageSmoothingQuality = 'medium'
})
.onDisAppear(() => {
lottie.destroy(this.refreshAnimName);
lottie.destroy(this.refreshingAnimName);
})
.visibility((this.refreshState == 1 || this.refreshState == 2) ? Visibility.Visible : Visibility.Hidden)
Text('已更新至最新')
.fontSize(14)
.textAlign(TextAlign.Center)
.fontColor('#676767')
.backgroundColor('#f6f6f6')
.borderRadius(20)
.padding({
left: 19,
right: 19,
top: 10,
bottom: 10
})
.visibility(this.refreshState == 3 ? Visibility.Visible : Visibility.Hidden)
}.padding({ top: 20 })
}
@Builder
private customLoadMoreView() {
Row() {
Canvas(this.loadMoreContext)
.width(14)
.height(14)
.backgroundColor(Color.Transparent)
.onReady(() => {
// 可在此生命回调周期中加载动画,可以保证动画尺寸正确
//抗锯齿的设置
this.loadMoreContext.imageSmoothingEnabled = true;
this.loadMoreContext.imageSmoothingQuality = 'medium'
this.loadMoreAnimate()
})
.onDisAppear(() => {
// Logger.error('zzzz', 'CustomLoadMoreLayout onDisAppear')
lottie.destroy(this.loadMoreAnimName);
})
Text('努力加载中')
.margin({
left: 7,
bottom: 1
})
.fontSize(14)
.fontColor('#888888')
.textAlign(TextAlign.Center)
}
.clip(true)
.width('100%')
.justifyContent(FlexAlign.Center)
.height(60)
}
private refreshAnim(percent: number) {
if (this.refreshAnimation == null || this.refreshAnimation.name != this.refreshAnimName ||
this.refreshAnimationDestroy) {
this.refreshAnimation?.destroy(this.refreshAnimName)
this.refreshAnimation?.destroy(this.refreshingAnimName)
this.refreshAnimation = lottie.loadAnimation({
container: this.refreshContext,
renderer: 'canvas', // canvas 渲染模式
loop: 1,
autoplay: true,
name: this.refreshAnimName,
path: "lottie/refresh_step1.json", // 路径加载动画只支持entry/src/main/ets 文件夹下的相对路径
})
this.refreshAnimation?.goToAndStop(1)
this.addRefreshAnimListener()
}
this.refreshAnimation?.goToAndStop(this.getFramesByProgress(percent), true);
}
/**
* 获取动画帧
*
* @param percent 百分比,如0.76
* @returns
*/
private getFramesByProgress(percent: number): number {
if (this.refreshAnimation == null) {
return 1;
}
let total = this.refreshAnimation.totalFrames;
let frame = Math.floor(total * percent);
if (frame >= total - 1) {
frame = total - 1
}
return frame;
}
private refreshingAnim() {
// Logger.error('zzzz', 'animate2, 1')
// 先销毁之前的动画
if (this.refreshAnimation == null || this.refreshAnimation.name != this.refreshingAnimName ||
this.refreshAnimationDestroy) {
this.refreshAnimation?.destroy(this.refreshAnimName)
this.refreshAnimation?.destroy(this.refreshingAnimName)
this.refreshAnimation = lottie.loadAnimation({
container: this.refreshContext,
renderer: 'canvas', // canvas 渲染模式
loop: 10,
autoplay: true,
name: this.refreshingAnimName,
path: "lottie/refresh_step2.json", // 路径加载动画只支持entry/src/main/ets 文件夹下的相对路径
})
this.addRefreshAnimListener()
}
// Logger.error('zzzz', 'animate2, 2')
}
private addRefreshAnimListener() {
this.refreshAnimation?.addEventListener('DOMLoaded', (args: Object): void => {
// Logger.error('zzzz', "lottie DOMLoaded");
this.refreshAnimationDestroy = false
}); //动画加载完成,播放之前触发
this.refreshAnimation?.addEventListener('destroy', (args: Object): void => {
// Logger.error('zzzz', "lottie destroy");
this.refreshAnimationDestroy = true
});
}
loadMoreAnimate() {
if (this.loadMoreAnimation == null) {
this.loadMoreAnimation = lottie.loadAnimation({
container: this.loadMoreContext,
renderer: 'canvas', // canvas 渲染模式
loop: 50,
autoplay: true,
name: this.loadMoreAnimName,
path: "lottie/loading_more.json", // 路径加载动画只支持entry/src/main/ets 文件夹下的相对路径
})
}
}
... ... @@ -41,4 +252,8 @@ export struct CustomPullToRefresh {
hasMoreChange() {
this.refreshConfigurator.setHasLoadMore(this.hasMore)
}
stateChange() {
// Logger.error('zzzz', 'stateChange ' + this.refreshState)
}
}
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@ import router from '@ohos.router'
export struct CustomTitleAndEditUI {
imgBack:boolean = true
titleName:string = "默认标题"
isDisplayButton:boolean = false
@Link isDisplayButton:boolean
@Consume isEditState:boolean
editCallback: () => void = () => {
}
... ...
... ... @@ -39,6 +39,11 @@ export struct SearchComponent {
SearcherAboutDataModel.searchHistoryData = []
//获取搜索历史
this.getSearchHistoryData()
let intervalID = setInterval(() => {
sendEventByKey("searchId", 10, "")
clearInterval(intervalID);
}, 1000);
}
getRelatedSearchContent() {
... ... @@ -56,12 +61,18 @@ export struct SearchComponent {
while (tempValue.indexOf(this.searchText) != -1){
let index = tempValue.indexOf(this.searchText)
if(index === 0){
tempArr.push(this.searchText)
tempValue = tempValue.substring(this.searchText.length,tempValue.length)
try {
tempArr.push(this.searchText)
tempValue = tempValue.substring(this.searchText.length,tempValue.length)
} catch (e) {
}
}else {
tempArr.push(tempValue.substring(0,index))
tempArr.push(this.searchText)
tempValue = tempValue.substring(index+this.searchText.length,tempValue.length)
try {
tempArr.push(tempValue.substring(0,index))
tempArr.push(this.searchText)
tempValue = tempValue.substring(index+this.searchText.length,tempValue.length)
} catch (e) {
}
}
}
if(StringUtils.isNotEmpty(tempValue)){
... ... @@ -99,6 +110,10 @@ export struct SearchComponent {
this.searchHistoryData = SearcherAboutDataModel.getSearchHistoryData()
}
stopInput(){
this.controller.stopEditing()
}
build() {
Column() {
this.searchInputComponent()
... ... @@ -106,7 +121,7 @@ export struct SearchComponent {
Scroll(this.scroller) {
Column() {
if(this.searchHistoryData!=null && this.searchHistoryData.length>0){
SearchHistoryComponent({ searchHistoryData: $searchHistoryData, onDelHistory: (): void => this.getSearchHistoryData(),onGetSearchRes: (item,index): void => this.getSearchHistoryResData(item,index) })
SearchHistoryComponent({ searchHistoryData: $searchHistoryData, onDelHistory: (): void => this.getSearchHistoryData(),onGetSearchRes: (item,index): void => this.getSearchHistoryResData(item,index),onCloseInput : (): void => this.stopInput() })
}
if(this.searchHistoryData.length>0){
... ... @@ -129,7 +144,13 @@ export struct SearchComponent {
} else {
if (this.hasChooseSearch) {
//搜索结果
SearchResultComponent({count:this.count,searchText:this.searchText,isGetRequest:this.isGetRequest})
SearchResultComponent({count:this.count,searchText:this.searchText,isGetRequest:this.isGetRequest,onClickTryAgain: (): void => {
if(StringUtils.isNotEmpty(this.searchText)){
SearcherAboutDataModel.putSearchHistoryData(this.searchText)
this.getSearchHistoryData()
this.getSearchInputResData(this.searchText)
}
}})
} else {
//联想搜索
SearchRelatedComponent({relatedSearchContentData:$relatedSearchContentsData,onGetSearchRes: (item): void => this.getSearchRelatedResData(item),searchText:this.searchText})
... ... @@ -218,7 +239,7 @@ export struct SearchComponent {
.textAlign(TextAlign.Start)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Clip })
.margin({ left: '70lpx' })
.margin({ left: '40lpx' })
})
}
.loop(true)
... ... @@ -238,7 +259,14 @@ export struct SearchComponent {
.height('69lpx')
.backgroundColor($r('app.color.color_transparent'))
.textFont({ size: "27lpx", weight: "400lpx" })
.defaultFocus(true)
// .defaultFocus(true)
.id("searchId")
.searchIcon({
size:0
})
.cancelButton({
style:CancelButtonStyle.INVISIBLE
})
.caretStyle({color:Color.Pink})
.onSubmit((value: string) => {
if(StringUtils.isNotEmpty(this.searchText)){
... ... @@ -278,9 +306,20 @@ export struct SearchComponent {
}
}
})
}.padding({right:'30lpx'})
}.padding({right:'70lpx'})
.layoutWeight(1)
Image($r('app.media.search_input_del_icon'))
.width("31lpx")
.height("31lpx")
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.Medium)
.margin({left:"495lpx"})
.onClick(()=>{
this.searchText = ""
})
.visibility(StringUtils.isEmpty(this.searchText) ? Visibility.Hidden : Visibility.Visible)
}
.backgroundImage($r('app.media.search_page_input_bg'))
.backgroundImageSize(ImageSize.Cover)
... ...
... ... @@ -8,11 +8,14 @@ import { MyCustomDialog } from '../reusable/MyCustomDialog'
@Component
export struct SearchHistoryComponent{
@Link searchHistoryData:SearchHistoryItem[]
onCloseInput?: () => void;
onDelHistory?: () => void;
onGetSearchRes?: (item:string,index:number) => void;
dialogController: CustomDialogController = new CustomDialogController({
builder: MyCustomDialog({
cancel: this.onCancel,
cancel: () => {
this.onCancel()
},
confirm: () => {
this.onAccept()
},
... ... @@ -33,6 +36,9 @@ export struct SearchHistoryComponent{
}
onCancel() {
if (this.onCloseInput !== undefined) {
this.onCloseInput()
}
console.info('Callback when the first button is clicked')
}
... ...
import { CompDTO, ContentDTO } from 'wdBean/Index'
import { LazyDataSource, UserDataLocal } from 'wdKit/Index'
import { LazyDataSource, NetworkUtil, UserDataLocal } from 'wdKit/Index'
import { HttpUtils } from 'wdNetwork/Index'
import SearcherAboutDataModel from '../../model/SearcherAboutDataModel'
import { SearchSuggestRequestItem } from '../../viewmodel/SearchSuggestRequestItem'
... ... @@ -26,6 +26,8 @@ export struct SearchResultComponent {
@State suggest_count: number = 0;
@State isLoading: boolean = false
scroller: Scroller = new Scroller()
onClickTryAgain?: () => void;
@State isConnectNetwork : boolean = NetworkUtil.isNetConnected()
aboutToAppear(): void {
if (this.count.length === 0 && this.isGetRequest == true) {
... ... @@ -67,9 +69,22 @@ export struct SearchResultComponent {
List() {
ListItem() {
//缺省图
EmptyComponent({emptyType:4})
.height('612lpx')
.width('100%')
if(this.isConnectNetwork){
EmptyComponent({emptyType:4})
.height('612lpx')
.width('100%')
}else{
EmptyComponent({ emptyType: 1,emptyHeight:"100%" ,retry: () => {
this.isConnectNetwork = NetworkUtil.isNetConnected()
if(this.isConnectNetwork){
if (this.onClickTryAgain !== undefined) {
this.onClickTryAgain()
}
}
}})
.height("100%")
.width('100%')
}
}
if(this.suggest_count > 0){
ListItem() {
... ...
... ... @@ -20,7 +20,6 @@ export struct channelSkeleton {
}
.RightStyle()
Column() {
textArea('35%', 78)
}
... ... @@ -70,7 +69,6 @@ function textArea(width: number | Resource | string = '100%', height: number | R
.height(height)
.backgroundColor('#FFF2F3F4')
.margin({ top: 10 })
.borderRadius(4)
}
// 全局公共样式
... ...
... ... @@ -18,13 +18,12 @@ export struct detailedSkeleton {
.alignItems(HorizontalAlign.Start)
Column() {
textArea('40%', 12)
textArea('40%', 12)
textArea('30%', 12)
textArea('30%', 12)
}
.SkeletonStyle()
.alignItems(HorizontalAlign.Start)
Column() {
textArea('100%', 12)
textArea('100%', 12)
... ... @@ -59,7 +58,7 @@ function textArea(width: number | Resource | string = '100%', height: number | R
Row()
.width(width)
.height(height)
.backgroundColor('#FFF2F3F4')
.backgroundColor('#FFF5F5F5')
.margin({ top: 10 })
// .borderRadius(5)
}
... ...
... ... @@ -131,8 +131,7 @@ export struct EmptyComponent {
// .height(this.EMPTY_IMAGE_HEIGHT)
Text(this.emptyType !== 8 ? this.buildNoDataTip() : `${this.buildNoDataTip()}(${this.timeNum}s)`)
.fontSize($r('app.float.font_size_14'))
.fontColor('#FF999999')
.fontSize($r('app.float.font_size_14'))// .fontColor('#FF999999')
.fontWeight(FontWeight.Normal)
.opacity(this.TEXT_OPACITY)
.margin({ top: this.EMPTY_TIP_TEXT_MARGIN_TOP })
... ... @@ -230,10 +229,10 @@ export struct EmptyComponent {
this.emptyType === WDViewDefaultType.WDViewDefaultType_NoHistory) {
imageString = $r('app.media.icon_no_collection')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoMessage) {
imageString = $r('app.media.icon_no_message1')
imageString = $r('app.media.icon_no_message')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoComment ||
this.emptyType === WDViewDefaultType.WDViewDefaultType_NoComment1) {
imageString = $r('app.media.icon_no_comment')
imageString = $r('app.media.icon_no_comment1')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoSearchResult) {
imageString = $r('app.media.icon_no_result1')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoNetwork) {
... ... @@ -243,7 +242,7 @@ export struct EmptyComponent {
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoCreation) {
imageString = $r('app.media.icon_no_works1')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoBooking) {
imageString = $r('app.media.icon_no_appointmentMade')
imageString = $r('app.media.icon_no_appointmentMade1')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NetworkFailed) {
imageString = $r('app.media.icon_no_limiting')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVisitAccount) {
... ... @@ -251,7 +250,8 @@ export struct EmptyComponent {
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoVideo) {
imageString = $r('app.media.icon_no_content')
} else if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent1 ||
this.emptyType === WDViewDefaultType.WDViewDefaultType_NoFollow || this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent2) {
this.emptyType === WDViewDefaultType.WDViewDefaultType_NoFollow ||
this.emptyType === WDViewDefaultType.WDViewDefaultType_NoContent2) {
imageString = $r('app.media.icon_no_appointmentMade1')
}
return imageString
... ...
... ... @@ -65,7 +65,12 @@ export struct OperRowListView {
* 7:图集详情页
*/
@Prop componentType: number = 1 //1: 底部栏目样式 2: 新闻页中间位置样式 3:动态Tab内容下的互动入口
@Prop pageComponentType?: number = -1 //1:视频详情页 2:竖屏直播页 3:图集 4: 横屏直播页
/**
* 用于区分页面类型,在哪个页面嵌套就传相应的值
* 1:视频详情页 2:竖屏直播页 3:图集 4:横屏直播页
*/
@Prop pageComponentType?: number = -1
@Prop showBackIcon?: boolean = true
@State likesStyle: number = this.contentDetailData.likesStyle // 赞样式 1红心(点赞) 2大拇指(祈福) 3蜡烛(默哀) 4置空
@Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件
@State needLike: boolean = true
... ... @@ -138,7 +143,7 @@ export struct OperRowListView {
Image($r('app.media.ic_news_detail_division'))
.width('100%')
.height($r('app.float.margin_1'))
.margin({bottom: -2})
// .margin({bottom: -2})
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
// AudioDialog()
... ... @@ -151,14 +156,16 @@ export struct OperRowListView {
.aspectRatio(1)
.interpolation(ImageInterpolation.High)
}
.width(48)
.hoverEffect(HoverEffect.Scale)
.visibility(this.showBackIcon ? Visibility.Visible : Visibility.None)
.onClick(() => {
if (this.onBack) {
this.onBack()
}
router.back();
})
.width(48)
if (this.contentDetailData?.newsId) {
ForEach(this.operationButtonList, (item: string, index: number) => {
... ... @@ -209,7 +216,8 @@ export struct OperRowListView {
}
.layoutWeight(1)
.margin({
right: this.pageComponentType === 1 ? 22 : 0,
right: this.pageComponentType === 1 ? 20 : 0,
left: 16
})
if (this.showCommentIcon) {
... ...
... ... @@ -39,18 +39,18 @@ export struct AreaPickerDialog {
this.confirmCallback(this.currentFirst.label,this.currentSecondBean.label,this.currentThirdBean.label,this.currentFirst.label+this.currentSecondBean.label+this.currentThirdBean.label);
})
.backgroundColor(0xffffff)
.fontColor(Color.Blue)
.fontColor('#ED2800')
.layoutWeight(1)
}
.margin({top:0,bottom:10})
Row(){
FirstLevelComponent().width('30%')
SecondLevelComponent().width('30%')
ThirdLevelComponent().width('30%')
FirstLevelComponent().width('33%')
SecondLevelComponent().width('33%')
ThirdLevelComponent().width('33%')
}
}
.height('40%')
.width('100%')
}
}
\ No newline at end of file
... ...
import { RMCalendar } from '../components/calendar/RMCalendar'
import { RMCalendarBean } from '../components/calendar/RMCalendarBean'
import { ToastUtils, NetworkUtil } from 'wdKit/Index';
@CustomDialog
export struct ENewspaperCalendarDialog {
... ... @@ -26,4 +27,9 @@ export struct ENewspaperCalendarDialog {
}
})
}
aboutToAppear(): void {
if (!NetworkUtil.isNetConnected()) {
ToastUtils.showToast('网络出小差了,请检查网络后重试', 1000)
}
}
}
\ No newline at end of file
... ...
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.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() {
... ... @@ -417,7 +439,7 @@ struct MineHomePage {
this.userName = value.userName
this.headPhotoUrl = value.headPhotoUrl
if(StringUtils.isNotEmpty(value.introduction)){
this.desc = "简介:" + value.introduction
this.desc = value.introduction
this.isHasIntroduction = true
}else{
this.desc = "点击添加简介,让大家认识你"
... ...
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 { common } from '@kit.AbilityKit';
import { insightIntent } from '@kit.IntentsKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { CompDTO, CompList, ContentDTO, PageInfoBean } from 'wdBean';
import { CompDTO, CompList, ContentDTO, PageInfoBean, ContentDetailDTO, InteractDataDTO } from 'wdBean';
function generateUUID() {
let dt = new Date().getTime(); // 获取当前时间的时间戳(毫秒)
... ... @@ -82,12 +82,58 @@ export function viewBlogInsightIntentShare(context: common.UIAbilityContext, ent
}
}
//ViewBlog意图共享-节目详情 目前单独在详情页上报
export function viewBlogItemInsightIntentShare(context: common.UIAbilityContext, item: ContentDetailDTO,
interactData?: InteractDataDTO) {
let identifier = generateUUID()
let viewBlogInsightIntentItem: insightIntent.InsightIntent = {
intentName: 'ViewBlog',
intentVersion: '1.0.1',
identifier,
intentActionInfo: {
actionMode: ActionMode.EXECUTED,
currentPercentage: 50,
},
intentEntityInfo: {
entityName: 'Blog',
entityId: String(item?.newsId),
displayName: item?.newsTitle,
entityGroupId: String(item?.reLInfo?.channelId), //channelId
logoURL: item.fullColumnImgUrls.length > 0 ? item.fullColumnImgUrls[0]?.url : item.firstFrameImageUri,
metadataModificationTime: item?.publishTime,
blogTitle: item?.newsTitle,
blogType: 'Normal',
blogCategory: item,
categoryDisplayName: '', //TODO 分类名称
blogSubTitle: item?.newsSummary.length > 20 ?
item?.newsSummary.substring(0, 20) : item?.newsSummary,
blogAuthor: item?.newsSourceName,
blogPublishTime: item?.publishTime,
tag: item?.newsTags.split(','),
viewCount: item?.viewCount || 0,
likeCount: interactData?.likeNum || 0,
forwardCount: interactData?.shareNum || 0,
commentCount: interactData?.commentNum || 0,
favorites: interactData?.collectNum || 0,
rankingHint: 99,
isPublicData: true
}
}
//ViewBlog意图共享-早晚报
console.log('yzl', JSON.stringify(viewBlogInsightIntentItem))
// 共享数据
insightIntent.shareIntent(context, [viewBlogInsightIntentItem]).then(() => {
console.log('yzl shareIntent success');
}).catch((err: BusinessError) => {
console.error(`yzl failed because ${err?.message}`);
});
}
//ViewColumn意图共享-早晚报
export function viewColumInsightIntentShare(context: common.UIAbilityContext, entityId: string,
pageInfoBean: PageInfoBean) {
console.log('viewColumInsightIntentShare')
let viewBlogInsightIntentItem: insightIntent.InsightIntent = {
let viewColumInsightIntentItem: insightIntent.InsightIntent = {
intentName: 'ViewColumn',
intentVersion: '1.0.1',
identifier: generateUUID(),
... ... @@ -108,10 +154,10 @@ export function viewColumInsightIntentShare(context: common.UIAbilityContext, en
isPublicData: true
}
}
console.log('yzl viewColumInsightIntentShare', JSON.stringify(viewBlogInsightIntentItem))
console.log('yzl viewColumInsightIntentShare', JSON.stringify(viewColumInsightIntentItem))
// 共享数据
insightIntent.shareIntent(context, [viewBlogInsightIntentItem]).then(() => {
insightIntent.shareIntent(context, [viewColumInsightIntentItem]).then(() => {
console.log('yzl shareIntent success');
}).catch((err: BusinessError) => {
console.error(`yzl failed because ${err?.message}`);
... ...
... ... @@ -84,6 +84,10 @@ export function touchUpPullRefresh(pageModel: PageModel, pageAdvModel: PageAdMod
* @param pageAdvModel 广告数据
*/
export function autoRefresh(pageModel: PageModel, pageAdvModel: PageAdModel) {
if (pageModel.isRefreshing === true) {
// 拦截多次刷新
return
}
pageModel.isVisiblePullDown = true;
pageModel.offsetY = vp2px(pageModel.pullDownRefreshHeight);
pullRefreshState(pageModel, RefreshState.Refreshing);
... ...
... ... @@ -26,7 +26,7 @@ export function touchUpLoadMore(model: PageModel) {
}, () => {
self.offsetY = 0;
})
if ((self.isCanLoadMore === true) && (self.hasMore === true)) {
if ((self.isCanLoadMore === true) && (self.hasMore === true) && (self.isLoading === false)) {
self.isLoading = true;
setTimeout(() => {
closeLoadMore(model);
... ...
... ... @@ -47,7 +47,7 @@ export class RefreshConstants {
* The NoMoreLayout constants.
*/
static readonly NoMoreLayoutConstant_NORMAL_PADDING: number = 8;
static readonly NoMoreLayoutConstant_TITLE_FONT: string = '16vp';
static readonly NoMoreLayoutConstant_TITLE_FONT: string = '12vp';
static readonly NoMoreLayoutConstant_TITLE_COLOR: string = '#666666';
/**
* The RefreshLayout constants.
... ...
import { CompDTO, ContentDTO, InteractDataDTO, LiveReviewDTO, PageDTO, PageInfoDTO } from 'wdBean';
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';
... ... @@ -17,6 +17,14 @@ import { CacheData } from 'wdNetwork/Index';
const TAG = 'PageHelper';
// 本地的一行两图卡 style值
const OneRowDoubleColumnStyle = CompStyle.Card_Comp_Zh_Grid_Layout_02
const Normal_Page_Size = 20 // 常规每页数量
const Rec_Page_Size = 10 // 推荐每页数量
/**
* 处理返回后的数据
*/
... ... @@ -25,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)
}
... ... @@ -35,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)
... ... @@ -44,60 +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)
Logger.error("ZZZXXXXX", 'parseCacheGroup----1-----');
for (const group of pageInfo.groups) {
pageModel.groupId = group.id;
pageModel.groupData = group
Logger.error("ZZZXXXXX", '楼层id-start--》' + pageModel.groupId);
// 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(pageModel,pageDto, pageInfo, index == pageInfo.groups.length - 1)
Logger.error("ZZZXXXXX", '楼层id-end--》' + pageModel.groupId + ' 楼层 comp数量=' + pageDto.compList.length);
}
// 收集页面所有楼层的组件信息,同步完成广告投放计算,异步完成稿件批查,
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))
}
Logger.error('zzzz', 'parseCacheGroup count: ' + pageModel.compList.totalCount())
pageModel.currentPage++
pageModel.viewType = ViewType.LOADED
closeRefresh(pageModel, true)
Logger.error("ZZZXXXXX", 'parseGroup----3----->' + pageInfo.oneRequestPageGroupCompList.length);
}
/**
* 进页面请求数据
*/
... ... @@ -131,62 +111,106 @@ 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 = []
pageInfo.oneRequestPageGroupCompList = new ArrayList()
pageModel.groupList.push(...pageInfo.groups)
Logger.error("ZZZXXXXX", 'parseGroup----1-----');
for (const group of pageInfo.groups) {
pageModel.isRecGroup = group.groupStrategy === 1;
pageModel.groupId = group.id;
if (pageModel.isRecGroup) {
pageModel.pageSize = 10
pageModel.pageSize = Rec_Page_Size
} else {
pageModel.pageSize = 20
pageModel.pageSize = Normal_Page_Size
}
pageModel.groupData = group
Logger.error("ZZZXXXXX", '楼层id-start--》' + pageModel.groupId);
//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)
if (index == 0) {
// 清空comp列表
pageModel.compList.clear()
// // 保存缓存
// CacheData.saveCacheData(CacheData.compGroupInfoDataCacheKey + pageModel.pageId + pageModel.groupId, pageDto,
// pageDto.md5)
// 解析楼层组件
this.analysisPageGroupCompData(pageDto, pageInfo)
// 最后一个楼层,特殊处理
if (index == pageInfo.groups.length - 1) {
// 检测楼层最后一个组件业务数据是否需要通过访问接口获取
let comp: CompDTO = pageDto.compList[pageDto.compList.length - 1]
// 直播回放,需要二次请求数据
if (comp.compStyle == CompStyle.Zh_Grid_Layout_02) {
pageInfo.lastCompSourceType = 1
let listReviewDtoBean = await PageViewModel.getLiveReviewUrl(1, Normal_Page_Size) as LiveReviewDTO
// 创建一行两图卡组件
this.createDoubleColumComp(listReviewDtoBean, pageInfo)
} else {
pageInfo.lastCompSourceType = 0
}
}
this.analysisPageGroupCompData(pageModel,pageDto, pageInfo, index == pageInfo.groups.length - 1)
Logger.error("ZZZXXXXX", '楼层id-end--》' + pageModel.groupId + ' 楼层 comp数量=' + pageDto.compList.length);
}
/*
... ... @@ -196,9 +220,11 @@ export class PageHelper {
// 处理页面广告数据,投放到页面的位置
this.handlePageCompAdvPostion(pageInfo.oneRequestPageGroupCompList, pageModel, pageInfo.pageAdList);
// 清空comp列表
pageModel.compList.clear()
//遍历所有组件和稿件数据 push到页面
for (let element of pageInfo.oneRequestPageGroupCompList) {
pageModel.compList.push(CompDTO.createNewsBean(element))
pageModel.compList.push(element)
}
// 批查互动数据
... ... @@ -209,7 +235,6 @@ export class PageHelper {
pageModel.viewType = ViewType.LOADED
closeRefresh(pageModel, true)
Logger.error("ZZZXXXXX", 'parseGroup----3----->' + pageInfo.oneRequestPageGroupCompList.length);
if (pageModel.compList.isEmpty()) {
// 没数据,展示空页面
Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.');
... ... @@ -225,26 +250,11 @@ export class PageHelper {
* @param pageInfo 信息流页面信息
* @param isLastGroup pageDto信息是不是最后一个楼层
*/
private async analysisPageGroupCompData(pageModel: PageModel,pageDto: PageDTO, pageInfo: PageInfoDTO, isLastGroup: boolean) {
private async analysisPageGroupCompData(pageDto: PageDTO, pageInfo: PageInfoDTO) {
if (pageDto && pageDto.compList && pageDto.compList.length > 0) {
let pageCompList: ArrayList<CompDTO> = new ArrayList() // 收集楼层组件、稿件和本地组件容器
// 遍历楼层的组件数据
pageDto.compList.forEach((element: CompDTO) => {
let contentInfo: ContentDTO = CollectionUtils.getElement(element.operDataList, 0);
//移除音频 和 活动
if (contentInfo && (contentInfo.objectType === '13' || contentInfo.objectType === '3')) {
Logger.debug(TAG, 'getGroupData 移除音频 和 活动');
} else {
// 暂时屏蔽活动和音频详情入口
if (element.operDataList[0]?.objectType === '3' || element.operDataList[0]?.objectType === '13') {
} else {
pageCompList.add(element)
}
}
})
let pageCompList = this.factoryCompArray(pageDto.compList)
// pageInfor 记录
pageCompList.forEach((comp: CompDTO) => {
pageInfo.oneRequestPageGroupCompList.add(comp)
... ... @@ -255,19 +265,6 @@ export class PageHelper {
pageInfo.pageAdList.push(...pageDto.compAdList)
}
// 检测最后一个楼层是否有一行两图卡
if (isLastGroup) {
// 最后一个楼层,特殊处理
// 检测楼层最后一个组件业务数据是否需要通过访问接口获取
let comp: CompDTO = pageDto.compList[pageDto.compList.length - 1]
// 直播回放,需要二次请求数据
if ( comp.compStyle == CompStyle.Zh_Grid_Layout_02) {
// 这个comp,数据自己二次请求,自己分页处理,这里加flag,将page层滑动及loadmore ui去掉
pageModel.contentNeedScroll = true
//this.getLiveReviewData(pageInfo,comp)
}
}
}
}
... ... @@ -295,23 +292,32 @@ export class PageHelper {
promptAction.showToast({ message: err });
})
} else {
PageViewModel.getPageGroupCompData(pageModel.bizCopy())
.then((data: PageDTO) => {
if (data == null || data.compList == null || data.compList.length == 0) {
pageModel.hasMore = false;
} else {
// 直接认为有分页,一直加载分页。直到没有数据,再停止
pageModel.currentPage++;
pageModel.hasMore = true;
//移除音频 和 活动
this.loadMorePageComp(pageModel, data)
// 参与批查
this.allCompBatchRequest(data.compList, pageModel)
}
}).catch((err: string | Resource) => {
promptAction.showToast({ message: err });
})
if (pageModel.pageInfo.lastCompSourceType == 1) {
// 加载更多 走 直播回看接口
this.getLiveReviewData(pageModel, pageModel.pageInfo)
} else {
// 默认加载更多走 楼层接口
PageViewModel.getPageGroupCompData(pageModel.bizCopy())
.then((data: PageDTO) => {
if (data == null || data.compList == null || data.compList.length == 0) {
pageModel.hasMore = false;
} else {
// 直接认为有分页,一直加载分页。直到没有数据,再停止
pageModel.currentPage++;
pageModel.hasMore = true;
//移除音频 和 活动
this.loadMorePageComp(pageModel, data)
// 参与批查
this.allCompBatchRequest(data.compList, pageModel)
}
}).catch((err: string | Resource) => {
promptAction.showToast({ message: err });
})
}
}
}
... ... @@ -321,9 +327,34 @@ export class PageHelper {
*/
private loadMorePageComp(pageModel: PageModel, pageDto: PageDTO) {
let pageCompList: ArrayList<CompDTO> = new ArrayList() // 收集页面组件、稿件和本地组件容器
let pageCompList = this.factoryCompArray(pageDto.compList) // 收集页面组件、稿件和本地组件容器
pageDto.compList.forEach((element: CompDTO) => {
// pageInfor 记录
pageModel.pageInfo.oneRequestPageGroupCompList.clear()
pageCompList.forEach((comp: CompDTO) => {
pageModel.pageInfo.oneRequestPageGroupCompList.add(comp)
})
// 记录
pageModel.pageTotalCompSize = pageCompList.length + pageModel.pageTotalCompSize
// 处理页面广告数据,投放到页面的位置
this.handlePageCompAdvPostion(pageCompList, pageModel, pageDto.compAdList);
//遍历所有组件和稿件数据 push到页面
for (let element of pageCompList) {
pageModel.compList.push(element)
}
}
/**
* 加工 组件数组信息
* @param compList
* @returns
*/
private factoryCompArray(compList: CompDTO[]): ArrayList<CompDTO> {
let pageCompList: ArrayList<CompDTO> = new ArrayList() // 收集页面组件、稿件和本地组件容器
compList.forEach((element: CompDTO) => {
let contentInfo: ContentDTO = CollectionUtils.getElement(element.operDataList, 0);
//移除音频 和 活动
if (contentInfo && (contentInfo.objectType === '13' || contentInfo.objectType === '3')) {
... ... @@ -332,22 +363,17 @@ export class PageHelper {
// 暂时屏蔽活动和音频详情入口
if (element.operDataList[0]?.objectType === '3' || element.operDataList[0]?.objectType === '13') {
} else {
pageCompList.add(element)
if (element.name == "月度排行卡") {
} else {
pageCompList.add(CompDTO.createNewsBean(element))
}
}
}
})
// 记录
pageModel.pageTotalCompSize = pageCompList.length + pageModel.pageTotalCompSize
// 处理页面广告数据,投放到页面的位置
this.handlePageCompAdvPostion(pageCompList, pageModel, pageDto.compAdList);
//遍历所有组件和稿件数据 push到页面
for (let element of pageCompList) {
pageModel.compList.push(CompDTO.createNewsBean(element))
}
return pageCompList
}
/**
... ... @@ -356,6 +382,8 @@ export class PageHelper {
* @param pageModel
*/
private allCompBatchRequest(compList: CompDTO[], pageModel: PageModel) {
// 批查人数
PageViewModel.getInteractData(compList).then((data: InteractDataDTO[]) => {
// 刷新,替换所有数据
this.resetInteract(data, pageModel.compList)
... ... @@ -366,6 +394,10 @@ export class PageHelper {
}
})
// 批查直播观看人数
this.getLiveRoomDataInfo(compList)
// 测试数据
// setTimeout(() => {
// let index = 1
... ... @@ -381,6 +413,59 @@ export class PageHelper {
}
/**
* 直播回看的批查数据
* @param list
* @param compList
*/
private getLiveRoomDataInfo(compList: CompDTO[]) {
let list: ContentDTO[] = []
compList.forEach((comp: CompDTO) => {
if (comp.compStyle == OneRowDoubleColumnStyle) {
list.push(...comp.operDataList)
}
})
let time = DateTimeUtils.getTimeStamp().toString()
let reserveIds = this.getLiveDetailIds(list)
PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
if (result && result.length > 0) {
result.forEach((bean: LiveRoomDataBean) => {
for (let item of list) {
if (item.objectId == bean.liveId.toString()) {
item.liveRoomDataBean = bean
outer: for (let compBean of compList) {
for (let contentBean of compBean.operDataList) {
if (contentBean === item) {
compBean.timestamp = time
break outer
}
}
}
break
}
}
})
}
}).catch(() => {
})
}
/**
* 获取直播详情id入参
* @param list
* @returns
*/
private getLiveDetailIds(list: ContentDTO[]): string {
let idList: string[] = []
list.forEach(item => {
idList.push(item.objectId)
});
return idList.join(',')
}
/**
* 刷新互动数据到compList
* @param interact 批查互动数据结果
* @param compList comp list
... ... @@ -560,12 +645,98 @@ export class PageHelper {
/**
* 获取直播回看数据
*/
private async getLiveReviewData(pageInfo: PageInfoDTO,comp: CompDTO) {
private async getLiveReviewData(pageModel: PageModel, pageInfo: PageInfoDTO) {
let currentPage = 1
let pageSize = 20
let listReviewDtoBean = await PageViewModel.getLiveReviewUrl(currentPage, pageSize) as LiveReviewDTO
Logger.error("ZZZXXXXX", 'getLiveReviewData---------'+listReviewDtoBean.list.length);
let currentPage = pageModel.currentPage
let pageSize = Normal_Page_Size
PageViewModel.getLiveReviewUrl(currentPage, pageSize).then((liveReviewDTO) => {
if (liveReviewDTO == null || liveReviewDTO.list == null || liveReviewDTO.list.length == 0) {
pageModel.hasMore = false;
} else {
pageInfo.oneRequestPageGroupCompList.clear()
// 直接认为有分页,一直加载分页。直到没有数据,再停止
pageModel.currentPage++;
pageModel.hasMore = true;
let haveMoveContent = false
//获取当前页面最后一个组件
let lastIndex = pageModel.compList.totalCount() - 1
let lastComp = pageModel.compList.getData(lastIndex) as CompDTO
// 一行两图卡,需要从奇数 补齐成偶数内容
if (lastComp.compStyle == OneRowDoubleColumnStyle) {
let operLength = lastComp.operDataList.length
// 页面的最后一个组件的业务数据是奇数,需要从获取更多的业务数据中补一个数据
if (operLength === 1) {
haveMoveContent = true
lastComp.operDataList.push(liveReviewDTO.list[0])
// 更新某个组件
pageModel.compList.updateItem(lastComp, lastIndex)
// 移走新获取的数据中第一条数据
liveReviewDTO.list.splice(0, 1)
}
}
// 创建本地一行两图卡
this.createDoubleColumComp(liveReviewDTO, pageInfo)
// 统计页面的总的组件和稿件数量
pageModel.pageTotalCompSize = pageInfo.oneRequestPageGroupCompList.length + pageModel.pageTotalCompSize
//遍历所有组件和稿件数据 push到页面
for (let element of pageInfo.oneRequestPageGroupCompList) {
pageModel.compList.push(element)
}
// 批查直播观看人数
if (haveMoveContent) {
// 把当前获取到的直播回看数据
pageInfo.oneRequestPageGroupCompList.add(lastComp)
}
this.getLiveRoomDataInfo(pageInfo.oneRequestPageGroupCompList.convertToArray())
}
}).catch((err: string | Resource) => {
promptAction.showToast({ message: err });
})
}
/**
* 创建一行两图卡 自定义的业务稿件
* @param listReviewDtoBean
* @param pageInfo
*/
private createDoubleColumComp(listReviewDtoBean: LiveReviewDTO, pageInfo: PageInfoDTO, test?: boolean) {
/*
两个业务 内容 配置一个comp
*/
let length = listReviewDtoBean.list.length
// if (test) {
// // 偶数变成奇数
// if (length % 2 === 0) {
// listReviewDtoBean.list.splice(length - 1, 1)
// length = listReviewDtoBean.list.length
// }
// }
for (let i = 0; i < length; i = i + 2) {
let sliceArray: ContentDTO[]
let j = i + 2
if (j < length) {
sliceArray = listReviewDtoBean.list.slice(i, j)
} else {
sliceArray = listReviewDtoBean.list.slice(i)
}
// 创建一行两图卡 自定义的业务稿件
let doubleColumnLiveReviewComp = new CompDTO()
doubleColumnLiveReviewComp.compStyle = OneRowDoubleColumnStyle
let operDataList: ContentDTO[] = sliceArray
doubleColumnLiveReviewComp.operDataList = operDataList
pageInfo.oneRequestPageGroupCompList.add(doubleColumnLiveReviewComp)
}
}
}
... ...
... ... @@ -63,6 +63,10 @@ export default class PageModel {
pageType: number = 0;
extra: string = ''
// 缓存数据相关
cachePageInfoMd5: string = ''
cacheGroupInfoMd5: string = ''
/**
* 简单复制业务数据
*/
... ...
... ... @@ -162,13 +162,21 @@
}
,
{
"name": "color_9E9E9E_40",
"name": "color_FFFFFF_40",
"value": "#40FFFFFF"
}
,
{
"name": "color_ED2800_99",
"value": "#99ED2800"
},
{
"name": "color_white_30",
"value": "#4D000000"
},
{
"name": "color_848484",
"value": "#848484"
}
]
}
\ No newline at end of file
... ...
... ... @@ -23,8 +23,8 @@ export struct LiveCountdownComponent {
aboutToAppear(): void {
//注册字体
font.registerFont({
familyName: 'BebasNeue_Regular',
familySrc: $rawfile('font/BebasNeue_Regular.otf')
familyName: 'BebasNeueBold',
familySrc: $rawfile('font/BebasNeueBold.otf')
})
setTimeout(() => {
this.textTimerController.start()
... ... @@ -69,13 +69,16 @@ export struct LiveCountdownComponent {
.showTimeStyleBold()
Text('月')
.showTimeStyleNormal()
.margin({ left: 3 })
.margin({ left: 1 })
.baselineOffset('-6vp')
Text(this.day)
.showTimeStyleBold()
.margin({ left: 3 })
Text('日')
.showTimeStyleNormal()
.margin({ left: 3 })
.margin({ left: 1 })
.baselineOffset('-6vp')
Text(this.hour)
.showTimeStyleBold()
.margin({ left: 10 })
... ... @@ -85,15 +88,15 @@ export struct LiveCountdownComponent {
.showTimeStyleBold()
}
.margin({ top: 10 })
.visibility(this.isCountDownStart ? Visibility.None : Visibility.Visible
)
.visibility(this.isCountDownStart ? Visibility.None : Visibility.Visible)
// 倒计时
TextTimer({ isCountDown: true, count: this.differenceTimeStamp, controller: this.textTimerController })
.format(this.format)
.fontSize('40fp')
.fontSize('40vp')
.fontWeight(FontWeight.Bold)
.fontColor('#222222')
.fontFamily('BebasNeue_Regular')
.fontFamily('BebasNeueBold')
.onTimer((utc: number, elapsedTime: number) => {
console.info('textTimer notCountDown utc is:' + utc + ', elapsedTime: ' + elapsedTime)
})
... ... @@ -139,7 +142,7 @@ export struct LiveCountdownComponent {
//2024-04-01 19:44:00-trim->2024-04-0119:44:00
if (StringUtils.isNotEmpty(this.liveDetailsBean.liveInfo?.planStartTime)) {
let playStartTimeTmp = this.liveDetailsBean.liveInfo?.planStartTime?.trim()
this.month = playStartTimeTmp.substring(5, 7)
this.month = Number(playStartTimeTmp.substring(5, 7)).toString()
this.day = playStartTimeTmp.substring(8, 10)
this.hour = playStartTimeTmp.substring(11, 13)
this.minute = playStartTimeTmp.substring(14, 16)
... ... @@ -182,7 +185,7 @@ export struct LiveCountdownComponent {
@Extend(Text)
function showTimeStyleNormal() {
.fontSize('16fp')
.fontSize('16vp')
.fontWeight(500)
.fontColor('#222222')
}
... ... @@ -190,7 +193,7 @@ function showTimeStyleNormal() {
@Extend(Text)
function showTimeStyleBold() {
.fontSize('40fp')
.fontFamily('BebasNeue_Regular')
.fontFamily('BebasNeueBold')
.fontWeight(FontWeight.Bold)
.fontColor('#222222')
}
\ No newline at end of file
... ...
... ... @@ -30,7 +30,8 @@ export struct TabInfoComponent {
Text(this.liveDetailsBean.newsTitle)
.maxLines(2)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('18fp')
.fontSize('18vp')
.lineHeight('26vp')
.fontWeight(500)
.fontColor('#222222')
}
... ... @@ -40,9 +41,10 @@ export struct TabInfoComponent {
Text(this.liveDetailsBean.newIntroduction)
.maxLines(5)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('14fp')
.fontSize('14vp')
.fontWeight(400)
.fontColor('#666666')
.lineHeight('22vp')
.margin({ top: 8 })
}
}
\ No newline at end of file
... ...
... ... @@ -25,13 +25,13 @@ export struct TabLiveItemComponent {
Text(this.item.senderUserName)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('14fp')
.fontSize('14vp')
.fontWeight(400)
.fontColor('#222222')
Text(this.item.role === 'host' ? '主持人' : '嘉宾')
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor('#968562')
.backgroundColor('#F1EFEB')
... ... @@ -44,17 +44,18 @@ export struct TabLiveItemComponent {
.borderRadius(2)
.margin({ left: 8 })
.visibility(StringUtils.isNotEmpty(this.item.role) ? Visibility.Visible : Visibility.None)
Text(DateTimeUtils.getCommentTime(new Date(this.item.time).getTime()))
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis })
.fontSize('12fp')
.fontSize('12vp')
.fontWeight(400)
.fontColor('#999999')
.margin({ left: 8 })
.visibility(StringUtils.isNotEmpty(this.item.time) ? Visibility.Visible : Visibility.None)
Text('置顶')
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor('#ED2800')
.backgroundColor('#F1EFEB')
... ... @@ -71,9 +72,10 @@ export struct TabLiveItemComponent {
}
Text(this.item.text)
.fontSize('14fp')
.fontSize('14vp')
.fontWeight(400)
.fontColor('#222222')
.lineHeight('20vp')
.margin({
top: 6
})
... ...
... ... @@ -89,8 +89,8 @@ export struct PlayUIComponent {
Text(this.liveDetailsBean.newsTitle)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.MARQUEE })
.fontSize('16fp')
.fontWeight(500)
.fontSize(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '18vp' : '16vp')
.fontWeight(this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? 600 : 500)
.fontColor(Color.White)
.textAlign(TextAlign.Start)
.layoutWeight(1)
... ... @@ -200,7 +200,7 @@ export struct PlayUIComponent {
else if (this.liveDetailsBean.liveInfo?.liveState == 'end') {
Row() {
Text('回看')
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
... ... @@ -209,7 +209,7 @@ export struct PlayUIComponent {
.width(12)
.height(12)
Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`)
.fontSize('11fp')
.fontSize('11vp')
.fontWeight(400)
.fontColor(Color.White)
}
... ... @@ -221,6 +221,8 @@ export struct PlayUIComponent {
top: 1,
right: 4,
bottom: 1
}).margin({
left: this.displayDirection == DisplayDirection.VIDEO_HORIZONTAL ? '34vp' : 0
})
}
}
... ...
... ... @@ -15,8 +15,7 @@ import { HttpUtils } from 'wdNetwork/Index';
import { DateTimeUtils, WindowModel } from 'wdKit/Index';
import { PlayerBottomView } from '../view/PlayerBottomView';
import { PlayerRightView } from '../view/PlayerRightView';
import { CommentComponentPage } from '../view/CommentComponentPage';
import { window } from '@kit.ArkUI';
import { CommentDialogView } from '../view/CommentDialogView';
import { DisplayDirection } from 'wdConstant/Index';
const TAG = 'DetailPlayShortVideoPage';
... ... @@ -39,7 +38,7 @@ export struct DetailPlayShortVideoPage {
@Provide followStatus: string = '0' // 关注状态
@Provide isOpenDetail: boolean = false // 查看详情按钮点击
@Provide isDragging: boolean = false // 拖动时间进度条
@Provide showCommentList: boolean = false
@Consume showCommentList: boolean
@Consume displayDirection: DisplayDirection
@Consume @Watch('videoStatusChange') switchVideoStatus: boolean
@Consume @Watch('pageShowChange') pageShow: number
... ... @@ -225,15 +224,7 @@ export struct DetailPlayShortVideoPage {
.height('100%')
.width('100%')
// .padding({
// top: this.displayDirection === DisplayDirection.VIDEO_HORIZONTAL ? 0 : this.topSafeHeight + 'px'
// })
if (this.showCommentList) {
CommentComponentPage({})
.position({ y: '100%' })
.markAnchor({ y: '100%' })
}
CommentDialogView({ publishCommentModel: this.publishCommentModel })
}
.height('100%')
.width('100%')
... ... @@ -294,13 +285,14 @@ export struct DetailPlayShortVideoPage {
.margin({ left: 8, right: 4 })
Text("全屏观看")
.fontColor(Color.White)
.fontWeight(400)
.fontSize(12)
.layoutWeight(1)
}
.width(84)
.height(28)
.backgroundColor('#0d0d0d')
.border({ width: 1, color: '#4DFFFFFF', radius: 2 })
.backgroundColor('#0DFFFFFF')
.border({ width: 1, color: '#4DFFFFFF', radius: 4 })
.alignItems(VerticalAlign.Center)
.justifyContent(FlexAlign.Center)
.align(Alignment.Bottom)
... ...
... ... @@ -28,6 +28,7 @@ export struct DetailVideoListPage {
@Provide pageHide: number = -1
@Provide switchVideoStatus: boolean = true
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL
@Provide showCommentList: boolean = false
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State netStatus: number | undefined = undefined // 存储网络状态用来展示缺省图
... ... @@ -185,7 +186,6 @@ export struct DetailVideoListPage {
middle: { anchor: "__container__", align: HorizontalAlign.Center }
})
} else {
Column() {
Swiper(this.swiperController) {
ForEach(this.data, (item: ContentDetailDTO, index: number) => {
... ... @@ -197,7 +197,8 @@ export struct DetailVideoListPage {
})
}, (item: ContentDetailDTO) => item.newsId + '')
}
.disableSwipe(this.displayDirection === DisplayDirection.VERTICAL || !this.showComment ? false : true)
.disableSwipe(this.displayDirection === DisplayDirection.VERTICAL || this.showCommentList ?
false : true)
.indicator(false)
.vertical(true)
.loop(false)
... ... @@ -221,5 +222,6 @@ export struct DetailVideoListPage {
// bottom: this.bottomSafeHeight + 'px'
// })
}
}
}
\ No newline at end of file
... ...
... ... @@ -45,13 +45,15 @@ export struct VideoChannelDetail {
@Consume barBackgroundColor: Color
private swiperController: SwiperController = new SwiperController()
@Provide showComment: boolean = false
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@Provide windowWidth: number = AppStorage.get<number>('windowWidth') || 0
@Provide windowHeight: number = AppStorage.get<number>('windowHeight') || 0
@Provide bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0
@Provide topSafeHeight: number = AppStorage.get<number>('topSafeHeight') || 0
@Consume @Watch('pageShowChange') pageShow: number
@Consume @Watch('pageHideChange') pageHide: number
@Provide switchVideoStatus: boolean = true
@Provide displayDirection: DisplayDirection = DisplayDirection.VERTICAL
@Provide showCommentList: boolean = false
@State data: ContentDetailDTO[] = []
@State currentIndex: number = 0
@State interactDataList: InteractDataDTO[] = []
... ... @@ -267,8 +269,8 @@ export struct VideoChannelDetail {
}, (item: ContentDetailDTO) => item.newsId + '')
}
.displayCount(1, true)
.disableSwipe(this.displayDirection === DisplayDirection.VERTICAL || !this.showComment ? false : true)
.visibility(this.isMouted ? Visibility.Visible : Visibility.None)
.disableSwipe(this.displayDirection === DisplayDirection.VERTICAL || this.showCommentList ? false : true)
.visibility(this.isMouted ? Visibility.Visible : Visibility.Hidden)
.indicator(false)
.vertical(true)
.loop(false)
... ...
import { ContentDetailDTO } from 'wdBean/Index'
import { WindowModel } from 'wdKit/Index'
import {
publishCommentModel
} from '../../../../../wdComponent/src/main/ets/components/comment/model/PublishCommentModel'
import { CommentComponent } from '../../../../../wdComponent/src/main/ets/components/comment/view/CommentComponent'
import { OperRowListView } from '../../../../../wdComponent/src/main/ets/components/view/OperRowListView'
@Component
export struct CommentComponentPage {
scroller: Scroller = new Scroller()
@Consume contentDetailData: ContentDetailDTO
@Consume showCommentList: boolean
@State publishCommentModel: publishCommentModel = new publishCommentModel()
aboutToAppear(): void {
this.publishCommentModel.targetId = String(this.contentDetailData?.newsId || '')
this.publishCommentModel.targetRelId = String(this.contentDetailData?.reLInfo?.relId || '')
this.publishCommentModel.targetTitle = this.contentDetailData?.newsTitle
this.publishCommentModel.targetRelType = String(this.contentDetailData?.reLInfo?.relType || '')
this.publishCommentModel.targetRelObjectId = String(this.contentDetailData?.reLInfo?.relObjectId || '')
this.publishCommentModel.keyArticle = String(this.contentDetailData?.keyArticle || '')
this.publishCommentModel.targetType = String(this.contentDetailData?.newsType || '')
this.publishCommentModel.visitorComment = String(this.contentDetailData?.visitorComment || '')
}
build() {
Column() {
Scroll(this.scroller) {
Stack() {
CommentComponent({
publishCommentModel: this.publishCommentModel
})
Image($r("app.media.ic_close_black"))
.width(20)
.height(20)
.onClick(() => {
this.showCommentList = false
})
.margin({ top: 10, right: 30 })
.position({ x: '100%' })
.markAnchor({ x: '100%' })
}
}
.layoutWeight(1)
OperRowListView({
componentType: 1,
operationButtonList: ['comment', 'like', 'collect', 'share'],
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
showCommentIcon: true,
onBack: () => {
WindowModel.shared.setWindowLayoutFullScreen(false)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
})
}
.zIndex(1000)
.backgroundColor(Color.White)
.height('60%')
}
}
\ No newline at end of file
import { ContentDetailDTO } from 'wdBean/Index'
import { WindowModel } from 'wdKit/Index'
import {
publishCommentModel
} from '../../../../../wdComponent/src/main/ets/components/comment/model/PublishCommentModel'
import { CommentComponent } from '../../../../../wdComponent/src/main/ets/components/comment/view/CommentComponent'
import { OperRowListView } from '../../../../../wdComponent/src/main/ets/components/view/OperRowListView'
@Component
export struct CommentDialogView {
@Prop publishCommentModel: publishCommentModel
@Consume windowWidth: number
@Consume windowHeight: number
@Consume bottomSafeHeight: number
@Consume topSafeHeight: number
@Consume contentDetailData: ContentDetailDTO
@Consume @Watch('showCommentListChange') showCommentList: boolean
@State dialogOffsetY: number = 0 // (this.windowHeight - this.windowWidth * 9 / 16)
@State modifier: DrawModifier = new DrawModifier();
private dialogController: CustomDialogController = new CustomDialogController({
builder: DetailDialog({
publishCommentModel: this.publishCommentModel,
dialogOffsetY: $dialogOffsetY
}),
autoCancel: false,
customStyle: true,
alignment: DialogAlignment.Bottom,
// onWillDismiss: (dismissDialogAction: DismissDialogAction) => {
// this.showCommentList = false
// dismissDialogAction.dismiss()
// },
openAnimation: { duration: 0 },
closeAnimation: { duration: 0 },
})
/**
* 问题:弹窗从底部到上动画无法添加
*/
showCommentListChange(val: boolean) {
if (this.showCommentList) {
this.dialogController.open()
console.log('open')
// animateTo({ duration: 10000, expectedFrameRateRange: { min: 60, max: 60, expected: 60 } }, () => {
// this.dialogOffsetY = 500
// this.modifier.invalidate()
// })
} else {
this.dialogController.close()
console.log('close')
}
}
build() {
}
}
@CustomDialog
export struct DetailDialog {
controller: CustomDialogController
@Prop publishCommentModel: publishCommentModel
@Link dialogOffsetY: number
@Consume contentDetailData: ContentDetailDTO
@Consume showCommentList: boolean
@Consume windowWidth: number
@Consume windowHeight: number
build() {
Column() {
CommentComponent({
publishCommentModel: this.publishCommentModel,
showCloseIcon: true,
onCloseClick: () => {
console.log('onCloseClick')
this.showCommentList = false
this.controller.close()
}
})
.layoutWeight(1)
OperRowListView({
componentType: 1,
showBackIcon: false,
operationButtonList: ['comment', 'like', 'collect', 'share'],
contentDetailData: this.contentDetailData,
publishCommentModel: this.publishCommentModel,
showCommentIcon: true,
onBack: () => {
WindowModel.shared.setWindowLayoutFullScreen(false)
WindowModel.shared.setWindowSystemBarProperties({ statusBarContentColor: '#000000', })
}
})
}
.height(this.windowHeight - this.windowWidth * 9 / 16 + 'px')
// .margin({ top: this.dialogOffsetY + 'px' })
.zIndex(1000)
.backgroundColor(Color.White)
}
}
\ No newline at end of file
... ...
... ... @@ -109,6 +109,8 @@ export struct OperationListView {
contentList: [{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
relType: this.contentDetailData?.reLInfo?.relType + '',
contentRelId: this.contentDetailData?.reLInfo?.relId + '',
}],
}
... ...
... ... @@ -68,6 +68,8 @@ export struct PlayerProgressView {
console.log('slider onChange:', value, mode)
})
}.visibility(this.isOpenDetail ? Visibility.None : Visibility.Visible)
}
.margin({ top: 40 })
.visibility(this.isOpenDetail ? Visibility.None : Visibility.Visible)
}
}
\ No newline at end of file
... ...
... ... @@ -87,6 +87,8 @@ export struct PlayerRightView {
contentList: [{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
relType: this.contentDetailData?.reLInfo?.relType + '',
contentRelId: this.contentDetailData?.reLInfo?.relId + '',
}],
}
... ...
... ... @@ -2,4 +2,5 @@ export { add } from "./src/main/ets/utils/Calc"
export { HWLocationUtils } from './src/main/ets/location/HWLocationUtils'
export { WDPushNotificationManager } from "./src/main/ets/notification/WDPushNotificationManager"
\ No newline at end of file
// export { WDPushNotificationManager } from "./src/main/ets/notification/WDPushNotificationManager"
export { GetuiPush } from "./src/main/ets/getuiPush/GetuiPush"
\ No newline at end of file
... ...
... ... @@ -7,10 +7,12 @@
"license": "Apache-2.0",
"packageType": "InterfaceHar",
"dependencies": {
"library": "file:./src/main/ets/getuiPush/GTSDK-1.0.1.0.har",
"wdConstant": "file:../../commons/wdConstant",
"wdLogin": "file:../../features/wdLogin",
"wdKit": "file:../../commons/wdKit",
"wdBean": "file:../../features/wdBean",
"wdRouter": "file:../../commons/wdRouter",
"wdNetwork": "file:../../commons/wdNetwork"
}
}
\ No newline at end of file
... ...
import { common, Want } from '@kit.AbilityKit';
import PushManager, {
BindAliasCmdMessage,
GTCmdMessage, GTNotificationMessage, GTTransmitMessage, PushConst,
SetTagCmdMessage,
Tag,
UnBindAliasCmdMessage } from 'library';
import { AppUtils, DeviceUtil, EmitterEventId, EmitterUtils, Logger, SPHelper } from 'wdKit/Index';
import { HostEnum, HostManager, HttpBizUtil, HttpUrlUtils, HttpUtils, ResponseDTO } from 'wdNetwork/Index';
import { notificationManager } from '@kit.NotificationKit';
import { BusinessError } from '@kit.BasicServicesKit';
import { SpConstants } from 'wdConstant/Index';
import { PushContentBean, PushContentParser } from './PushContentParser';
const TAG = "GetuiPush"
export class GetuiPush {
private static GETUI_APPID_ONLINE = "sMkzgp09Ov82nU1MGk7Ae6"
private static GETUI_APPID_TEST = "ZMi5AAXYHE84VN9p55YpW2"
private readonly ALIAS_SN_USERID = "userID"
private readonly TAG_SN_TAG = "tag1"
private readonly TAG_PD_ZH = "peopledaily_zh"
private cid: string = ""
private deviceToken: string = ""
private currentUserId = ""
private lastPushContent?: PushContentBean
private initialed = false
private constructor() {
}
private static manager: GetuiPush
static sharedInstance() : GetuiPush {
if (!GetuiPush.manager) {
GetuiPush.manager = new GetuiPush()
}
return GetuiPush.manager
}
init(context: common.UIAbilityContext) {
const isOnlineEnv = HostManager.getHost() === HostEnum.HOST_PRODUCT
PushManager.initialize({
appId:isOnlineEnv ? GetuiPush.GETUI_APPID_TEST : GetuiPush.GETUI_APPID_TEST,
context: context,
onSuccess: (cid:string) => {
Logger.debug(TAG, "个推SDK初始化成功,cid = " + cid)
this.initialed = true
this.cid = cid
this.registerEvents()
this.checkSetup()
},
onFailed: (error:string) => {
Logger.error(TAG, "个推SDK初始化失败,error = " + error)
}
})
}
async requestEnableNotifications(context: common.UIAbilityContext) : Promise<boolean> {
let enabled = await notificationManager.isNotificationEnabled()
if (!enabled) {
try {
await notificationManager.requestEnableNotification(context)
enabled = true
} catch (err) {
Logger.error(TAG, "请求通知权限报错: " + JSON.stringify(err))
let error = err as BusinessError
if (error.code == 1600004) {
Logger.error(TAG, "请求通知权限 - 用户已拒绝")
}
}
}
Logger.info(TAG, "推送 enabled " + enabled)
return enabled
}
checkSetup() {
if (!this.initialed) { return }
if (HttpUtils.isLogin()) {
const userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
this.currentUserId = userId
this.setAlias(true, userId)
}
let tags = [this.TAG_PD_ZH, AppUtils.getAppVersionCode()]
this.setTags(tags)
}
// 默认是开启的
switchPush(turnOn: boolean) {
turnOn ? PushManager.turnOnPush() : PushManager.turnOffPush()
}
registerEvents() {
// 登录和退出
EmitterUtils.receiveEvent(EmitterEventId.LOGIN_SUCCESS, () => {
const userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
this.currentUserId = userId
this.setAlias(true, userId)
})
EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, () => {
if (this.currentUserId.length) {
this.setAlias(false, this.currentUserId)
}
})
PushManager.setPushCallback({
// cid
onReceiveClientId: (clientId: string) => {
Logger.debug(TAG, "推送 接收到 clientId = " + clientId)
this.cid = PushManager.getClientId()
SPHelper.default.save(SpConstants.GETUI_PUSH_CID, this.cid)
this.uploadPushInfo(this.cid)
},
//接收⼚商token
onReceiveDeviceToken: (deviceToken:string) => {
Logger.debug(TAG, "推送 deviceToken = " + deviceToken)
this.deviceToken = deviceToken;
SPHelper.default.save(SpConstants.GETUI_PUSH_DEVICE_TOKEN, this.deviceToken)
},
// cid 离线上线通知
onReceiveOnlineState: (onLine:boolean) => {
Logger.debug(TAG, "推送 onLine State = " + onLine)
},
//命令相应回复
onReceiveCommandResult: (result: GTCmdMessage) => {
Logger.debug(TAG, "推送 Cmd Message = " + JSON.stringify(result))
this.dealWithCmdMessage(result)
},
//sdk 收到透传消息
onReceiveMessageData: (message: GTTransmitMessage) => {
Logger.debug(TAG, "推送 透传 Message = " + JSON.stringify(message))
this.dealWithTransmitMessage(message)
},
//通知到达回调
onNotificationMessageArrived: (message: GTNotificationMessage) => {
Logger.debug(TAG, "推送 通知到达回调 " + JSON.stringify(message))
},
//通知点击回调, 需要配合PushManager.setClickWant(want)使⽤
onNotificationMessageClicked: (message: GTNotificationMessage) => {
Logger.debug(TAG, "推送 通知 点击 回调 " + JSON.stringify(message))
},
})
}
setAlias(bind: boolean, alias: string, sn: string = this.ALIAS_SN_USERID) {
if (!this.initialed) { return }
if (bind) {
Logger.debug(TAG, "推送 绑定别名 " + alias)
PushManager.bindAlias(alias, sn)
} else {
Logger.debug(TAG, "推送 解绑别名 " + alias)
PushManager.unBindAlias(alias, true, sn)
}
}
setTags(tags: string[], sn: string = this.TAG_SN_TAG) {
if (!this.initialed) { return }
Logger.debug(TAG, "推送 设置标签 " + tags)
PushManager.setTag(tags.map((tag) => {
return new Tag().setName(tag)
}), sn)
}
setBadgeNumber(number: number) {
Logger.debug(TAG, "推送 设置角标 " + number)
PushManager.setBadgeNum(number)
}
// 接收推送数据,包括启动和二次点击拉起
// 参考:https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/push-dev-0000001727885258
onWant(want: Want) {
this.onNewWant(want, true)
}
onNewWant(want: Want, startup: boolean = false) {
Logger.debug(TAG, "want: " + JSON.stringify(want))
this.lastPushContent = undefined
let pushContent = PushContentParser.getPushLinkFromWant(want)
if (pushContent && pushContent.isPush) {
Logger.debug(TAG, "接收到推送: " + JSON.stringify(want.parameters))
this.lastPushContent = pushContent
if (this.initialed) {
this.comsumeLastPushContent()
}
}
}
// 首次进入主页,即可解析跳转推送
onReachMainPage() {
if (this.initialed) {
this.comsumeLastPushContent()
} else {
this.lastPushContent = undefined
}
}
comsumeLastPushContent() {
if (!this.lastPushContent) {
return
}
if (this.lastPushContent.online) {
if (this.lastPushContent.want) {
Logger.debug(TAG, "推送 回执: " + this.lastPushContent.want)
PushManager.setClickWant(this.lastPushContent.want)
}
}
if (this.lastPushContent.pushLink) {
Logger.debug(TAG, "跳转对应页面: " + this.lastPushContent.pushLink)
PushContentParser.jumpWithPushLink(this.lastPushContent.pushLink)
}
this.lastPushContent = undefined
}
private dealWithCmdMessage(result: GTCmdMessage) {
let action: Number = result.action;
if (action === PushConst.BIND_ALIAS_RESULT) {
let bindAliasCmdMessage = result as BindAliasCmdMessage;
/* code 结果说明
0:成功
10099:SDK 未初始化成功
30001:绑定别名失败,频率过快,两次调⽤的间隔需⼤于 1s
30002:绑定别名失败,参数错误
30003:当前 cid 绑定别名次数超限
30004:绑定别名失败,未知异常
30005:绑定别名时,cid 未获取到
30006:绑定别名时,发⽣⽹络错误
30007:别名⽆效
30008:sn ⽆效 */
let code = bindAliasCmdMessage.code
if (code == 0) {
Logger.debug(TAG, "推送 Cmd BindAlias 成功 " + bindAliasCmdMessage.sn)
} else {
Logger.debug(TAG, "推送 Cmd BindAlias 失败 "
+ ",sn = "+bindAliasCmdMessage.sn
+ ",clinetId = "+bindAliasCmdMessage.clientId
+ ",pkgname = "+bindAliasCmdMessage.pkgName
+ ",appId = "+bindAliasCmdMessage.appId
+ ",action = "+result.action
+ ",code ="+bindAliasCmdMessage.code)
}
} else if (action === PushConst.UNBIND_ALIAS_RESULT) {
let unBindAliasCmdMessage = result as UnBindAliasCmdMessage
/* code 结果说明
0:成功
10099:SDK 未初始化成功
30001:解绑别名失败,频率过快,两次调⽤的间隔需⼤于 1s
30002:解绑别名失败,参数错误
30003:当前 cid 解绑别名次数超限
30004:解绑别名失败,未知异常
30005:解绑别名时,cid 未获取到
30006:解绑别名时,发⽣⽹络错误
30007:别名⽆效
30008:sn ⽆效*/
let code = unBindAliasCmdMessage.code
if (code == 0) {
Logger.debug(TAG, "推送 Cmd UnBindAlias 成功 " + unBindAliasCmdMessage.sn)
} else {
Logger.debug(TAG, "推送 Cmd UnBindAlias 失败 "
+ ",sn = "+unBindAliasCmdMessage.sn
+ ",clinetId = "+unBindAliasCmdMessage.clientId
+ ",pkgname = "+unBindAliasCmdMessage.pkgName
+ ",appId = "+unBindAliasCmdMessage.appId
+ ",action = "+result.action
+ ",code ="+unBindAliasCmdMessage.code)
}
} else if (action === PushConst.SET_TAG_RESULT) {
let setTagCmdMessage = result as SetTagCmdMessage
/* code 值说明
0:成功
10099:SDK 未初始化成功
20001:tag 数量过⼤(单次设置的 tag 数量不超过 100)
20002:调⽤次数超限(默认⼀天只能成功设置⼀次)
20003:标签重复
20004:服务初始化失败
20005:setTag 异常
20006:tag 为空
20007:sn 为空
20008:离线,还未登陆成功
20009:该 appid 已经在⿊名单列表(请联系技术⽀持处理)
20010:已存 tag 数⽬超限
20011:tag 内容格式不正确 */
let code = setTagCmdMessage.code
if (code == 0) {
Logger.debug(TAG, "推送 Cmd SetTag 成功 " + setTagCmdMessage.sn)
} else {
Logger.debug(TAG, "推送 Cmd SetTag 失败 "
+ ",sn = "+setTagCmdMessage.sn
+ ",clinetId = "+setTagCmdMessage.clientId
+ ",pkgname = "+setTagCmdMessage.pkgName
+ ",appId = "+setTagCmdMessage.appId
+ ",action = "+result.action
+ ",code ="+setTagCmdMessage.code)
}
}
}
private dealWithTransmitMessage(message: GTTransmitMessage) {
// const taskid = message.taskId
// const messageId = message.messageId
// /* 上报个推透传消息的展示回执。如果透传消息本地创建通知栏消息“展示”了,则调⽤此⽅法上报。
// */
// int gtactionid = 60001;//gtactionid传⼊60001表示个推渠道消息展示了
// boolean result = PushManager.sendFeedbackMessag(taskid, messageid, gtactionid);
// /**
// * 上报个推透传消息的点击回执。如果透传消息本地创建通知栏消息“点击”了,则调⽤此⽅法上报。
// */
// int gtactionid = 60002;//gtactionid传⼊60002表示个推渠道消息点击了
// boolean result = PushManager.sendFeedbackMessage(taskid, messageid, gtactionid);
}
private uploadPushInfo(cid: string) {
const url = HttpUrlUtils.getUploadPushInfoUrl()
let bean: Record<string, string | number> = {}
bean["deviceId"] = DeviceUtil.clientId()
bean["cid"] = cid
bean["userId"] = SPHelper.default.getSync(SpConstants.USER_ID, "") as string
bean["appVersion"] = AppUtils.getAppVersionName()
bean["platform"] = 3
HttpBizUtil.post<ResponseDTO<string>>(url, bean).then((data) => {
Logger.debug(TAG, "上传cid成功" + JSON.stringify(data))
}).catch((e: BusinessError) => {
Logger.debug(TAG, "上传cid失败" + JSON.stringify(e))
})
}
}
\ No newline at end of file
... ...
import Want from '@ohos.app.ability.Want';
import { Logger } from 'wdKit/Index';
import { JSON } from '@kit.ArkTS';
import { AppInfo } from '@mpaas/framework';
import { AppInnerLink } from 'wdRouter/Index';
export interface PushContentBean {
isPush: boolean // 是否为推送数据
want?: Want // want参数 (用来在消费时,回执)
online: boolean // 解析want,是否为在线消息(在线走的是个推通道,离线走的是华为厂商通道)
pushLink?: string // 解析want,对应pushLink参数
}
/*
* */
export class PushContentParser {
private static LAUNCH_PARAM_GETUI_DATA = "gtdata"
private static LAUNCH_PARAM_GETUI_TASKID = "taskid"
private static LAUNCH_PARAM_GETUI_NOTIFYID = "_push_notifyid"
private static PUSH_PARAM_PUSH_LINK = "pushLink"
static getPushLinkFromWant(want: Want) : PushContentBean {
// 个推在线消息
if (want && want.parameters && want.parameters[PushContentParser.LAUNCH_PARAM_GETUI_DATA]) {
/*
{
"age": 12,
"gtdata": {
"actionid": "10010",
"appid": "ZMi5AAXYHE84VN9p55YpW2",
"bigStyle": 0,
"checkpackage": "com.peopledailychina.hosactivity",
"content": "通知内容444",
"feedbackid": "0",
"isFloat": false,
"messageid": "44fd0876c9834214a6b7032b35d9826b",
"notifID": 62288,
"notifyStyle": 0,
"payload": "",
"taskid": "TEST_0516_03a84918e7df6191502497ed2cbef384",
"title": "测试通知444",
"wantUri": "{\"deviceId\":\"\",\"bundleName\":\"com.peopledailychina.hosactivity\",\"abilityName\":\"EntryAbility\",\"uri\":\"rmrbapp://rmrb.app:8080/openwith\",\"action\":\"com.test.pushaction\",\"parameters\":{\"pushLink\":\"Getui\",\"age\":12}}"
},
"isCallBySCB": false,
"moduleName": "phone",
"pushLink": "Getui",
"ohos.aafwk.param.callerAbilityName": "",
"ohos.aafwk.param.callerBundleName": "com.ohos.sceneboard",
"ohos.aafwk.param.callerPid": 44239,
"ohos.aafwk.param.callerToken": 537702494,
"ohos.aafwk.param.callerUid": 20020018,
"specifyTokenId": 537063794
}
},*/
let gtData = want.parameters[PushContentParser.LAUNCH_PARAM_GETUI_DATA] as Record<string, string | number | object>
if (gtData[PushContentParser.LAUNCH_PARAM_GETUI_TASKID] != undefined) {
let json = JSON.parse(gtData["wantUri"] as string) as Record<string, string | number>
if (json && json[PushContentParser.PUSH_PARAM_PUSH_LINK] != null) {
const pushLink = json[PushContentParser.PUSH_PARAM_PUSH_LINK] as string
return {
isPush: true, online: true, pushLink: pushLink, want: want
}
}
}
}
/*
{
"deviceId": "",
"bundleName": "com.peopledailychina.hosactivity",
"abilityName": "EntryAbility",
"moduleName": "phone",
"uri": "rmrbapp://rmrb.app:8080/openwith",
"type": "",
"flags": 0,
"action": "com.test.pushaction",
"parameters": {
"_push_notifyid": 1,
"age": 12, // 自定义
"debugApp": false,
"isCallBySCB": false,
"moduleName": "phone",
"pushLink": "Getui", // 自定义
"ohos.aafwk.param.callerAbilityName": "PushServiceInnerAbility",
"ohos.aafwk.param.callerBundleName": "com.huawei.hms.pushservice",
"ohos.aafwk.param.callerPid": 22808,
"ohos.aafwk.param.callerToken": 537908725,
"ohos.aafwk.param.callerUid": 20004,
"ohos.dlp.params.sandbox": false
},
"entities": [
]
* */
// 离线消息,华为直接推送
if (want && want.parameters && want.parameters[PushContentParser.LAUNCH_PARAM_GETUI_NOTIFYID]) {
if (want.parameters[PushContentParser.PUSH_PARAM_PUSH_LINK]) {
let pushLink = want.parameters[PushContentParser.PUSH_PARAM_PUSH_LINK] as string
return {
isPush: true, online: false, pushLink: pushLink, want: want
}
}
}
return {
isPush: false, online: false
}
}
static jumpWithPushLink(pushLink: string) {
AppInnerLink.jumpWithLink(pushLink)
}
}
\ No newline at end of file
... ...
... ... @@ -17,7 +17,7 @@ struct GuidePages {
this.ChildItem(index)
}, (item: number) => JSON.stringify(item))
}.loop(false)
}.loop(false).disableSwipe(true)
.indicator(false)
.width('100%')
.height('100%')
... ...
... ... @@ -7,7 +7,6 @@ import window from '@ohos.window';
import { BusinessError } from '@ohos.base';
import { DeviceUtil, EmitterEventId, EmitterUtils, WindowModel } from 'wdKit';
import { ConfigurationConstant } from '@kit.AbilityKit';
import { WDPushNotificationManager } from 'wdHwAbility/Index';
import { StartupManager } from '../startupmanager/StartupManager';
import { UIContext } from '@ohos.arkui.UIContext';
... ... @@ -29,7 +28,7 @@ export default class EntryAbility extends UIAbility {
// App活着情况下,点击推送通知进入
onNewWant(want: Want, launchParam: AbilityConstant.LaunchParam): void {
WDPushNotificationManager.getInstance().onWant(want)
StartupManager.sharedInstance().appOnNewWant(want, launchParam)
}
onDestroy(): void {
... ...
import { BottomNavigationComponent, LogoutViewModel, PermissionDesComponent } from 'wdComponent';
import { BreakpointConstants } from 'wdConstant';
import { HWLocationUtils, WDPushNotificationManager } from 'wdHwAbility/Index';
import { common } from '@kit.AbilityKit';
import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger, MpaasUpgradeCheck, WindowModel } from 'wdKit';
import { promptAction, window } from '@kit.ArkUI';
... ... @@ -33,16 +32,6 @@ struct MainPage {
this.breakpointSystem.register()
let context = getContext(this) as common.UIAbilityContext
WDPushNotificationManager.getInstance().requestEnableNotifications(context).then((enabled) => {
if (enabled) {
WDPushNotificationManager.getInstance().fetchTokenAndBindProfileId()
// WDPushNotificationManager.getInstance().sendLocalNotification()
}
HWLocationUtils.startLocationService()
})
Logger.info(TAG, `aboutToAppear `);
EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, () => {
LogoutViewModel.clearLoginInfo()
... ...
import { AbilityConstant, common, Want } from '@kit.AbilityKit'
import { WDPushNotificationManager } from 'wdHwAbility/Index'
import { DeviceUtil,
EmitterEventId,
EmitterUtils,
... ... @@ -16,6 +15,8 @@ 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'
import { GetuiPush, HWLocationUtils } from 'wdHwAbility/Index'
const TAG = "[StartupManager]"
... ... @@ -24,6 +25,8 @@ export class StartupManager {
private context?: common.UIAbilityContext
private constructor() {
}
private static _manger?: StartupManager
static sharedInstance(): StartupManager {
if (!StartupManager._manger) {
... ... @@ -36,6 +39,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);
... ... @@ -57,10 +62,14 @@ export class StartupManager {
this.preInitUmentStat()
// 通知栏点击后启动
WDPushNotificationManager.getInstance().onWant(want)
GetuiPush.sharedInstance().onWant(want)
Logger.debug(TAG, "App onCreate: finised")
}
appOnNewWant(want: Want, launchParam: AbilityConstant.LaunchParam) {
GetuiPush.sharedInstance().onNewWant(want)
}
appOnDestory() {
Logger.debug(TAG, "App onDestory")
NetworkManager.getInstance().release()
... ... @@ -88,13 +97,19 @@ export class StartupManager {
Logger.debug(TAG, "App 必要初始化完成")
}
// 到达主页后,初始化非必须部分
// 初次到达主页后,初始化非必须部分
appReachMainPage() : Promise<void> {
return new Promise((resolve) => {
Logger.debug(TAG, "App 进入首页,开始其他任务初始化")
Logger.debug(TAG, "App 初次进入首页,开始其他任务初始化")
LoginModule.reportDeviceInfo()
GetuiPush.sharedInstance().requestEnableNotifications(this.context!).then((enabled) => {
HWLocationUtils.startLocationService()
})
GetuiPush.sharedInstance().onReachMainPage()
//TODO:
resolve()
... ... @@ -127,7 +142,8 @@ export class StartupManager {
}
private initGeTuiPush() {
// Logger.debug(TAG, "App 初始化")
Logger.debug(TAG, "App 个推推送 初始化")
GetuiPush.sharedInstance().init(this.context!)
}
private initLocation() {
... ... @@ -167,4 +183,4 @@ export class StartupManager {
private initOthers() {
}
}
\ No newline at end of file
}
... ...
import { insightIntent, InsightIntentExecutor } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
import { ProcessUtils } from 'wdRouter';
/**
* 意图调用
*/
export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
private static readonly ViewColumn = 'ViewColumn';
private static readonly ViewBlog = 'ViewBlog';
private static readonly ViewColumnUpdate = 'ViewColumnUpdate';
/**
* override 执行前台UIAbility意图
*
... ... @@ -17,10 +19,13 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
*/
onExecuteInUIAbilityForegroundMode(name: string, param: Record<string, Object>, pageLoader: window.WindowStage):
Promise<insightIntent.ExecuteResult> {
console.log('yzl onExecuteInUIAbilityForegroundMode',name,JSON.stringify(param))
// 根据意图名称分发处理逻辑
switch (name) {
case InsightIntentExecutorImpl.ViewColumn:
return this.jumpToView(param, pageLoader);
case InsightIntentExecutorImpl.ViewBlog:
return this.jumpToViewBlog(param, pageLoader);
case InsightIntentExecutorImpl.ViewColumnUpdate:
return this.jumpToViewColumnUpdate(param, pageLoader);
default:
break;
}
... ... @@ -32,18 +37,47 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
} as insightIntent.ExecuteResult)
}
/**
* 实现跳转新闻页面功能
*
* 实现习惯推荐功能
* @param param 意图参数
* @param pageLoader 窗口
*/
private jumpToView(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
private jumpToViewBlog(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
console.log('yzl jumpToView',JSON.stringify(param))
return new Promise((resolve, reject) => {
// TODO 实现意图调用,loadContent的入参为歌曲落地页路径,例如:pages/SongPage
pageLoader.loadContent('pages/MainPage')
.then(() => {
let entityId: string = (param.items as Array<object>)?.[0]?.['entityId'];
// TODO 调用成功的情况,此处可以打印日志
let entityGroupId: string = (param.items as Array<object>)?.[0]?.['entityGroupId'];
ProcessUtils.jumpChannelTab(entityGroupId,'')
resolve({
code: 0,
result: {
message: 'Intent execute success'
}
});
})
.catch((err: BusinessError) => {
resolve({
code: -1,
result: {
message: 'Intent execute failed'
}
})
});
})
}
/**
* 实现事件推荐功能
* @param param 意图参数
* @param pageLoader 窗口
*/
private jumpToViewColumnUpdate(param: Record<string, Object>, pageLoader: window.WindowStage): Promise<insightIntent.ExecuteResult> {
console.log('yzl jumpToViewColum',JSON.stringify(param))
return new Promise((resolve, reject) => {
pageLoader.loadContent('pages/MainPage')
.then(() => {
// TODO 事件推荐调用
resolve({
code: 0,
result: {
... ... @@ -52,7 +86,6 @@ export default class InsightIntentExecutorImpl extends InsightIntentExecutor {
});
})
.catch((err: BusinessError) => {
// TODO 调用失败的情况
resolve({
code: -1,
result: {
... ...
... ... @@ -14,7 +14,7 @@
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"name": "EntryAbility", // 这里不能改动,和后台推送有绑定
"srcEntry": "./ets/entryability/EntryAbility.ets",
"description": "$string:EntryAbility_desc",
"icon": "$media:app_icon",
... ... @@ -28,8 +28,15 @@
"entity.system.home"
],
"actions": [
"action.system.home"
]
"action.system.home",
"com.test.pushaction"
],
"uris" : [{
"scheme": 'rmrbapp',
"host": 'rmrb.app',
'port': '8080',
"path": 'openwith'
}]
}
]
}
... ...
{
"insightIntents": [
{
"intentName": "ViewColumn",
"intentName": "ViewBlog",
"domain": "",
"intentVersion": "1.0.1",
"srcEntry": "./ets/utils/InsightIntentExecutorImpl.ets",
"uiAbility": {
"ability": "EntryAbility",
"executeMode": [
"background",
"foreground"
]
}
},
{
"intentName": "ViewColumnUpdate",
"domain": "",
"intentVersion": "1.0.1",
"srcEntry": "./ets/utils/InsightIntentExecutorImpl.ets",
... ...