Showing
58 changed files
with
1309 additions
and
411 deletions
| 1 | import { StringUtils } from './StringUtils'; | 1 | import { StringUtils } from './StringUtils'; |
| 2 | -import getLunar from './GetLunar' | 2 | +import getLunar from './GetLunar'; |
| 3 | + | ||
| 3 | /** | 4 | /** |
| 4 | * 日期/时间工具 | 5 | * 日期/时间工具 |
| 5 | */ | 6 | */ |
| @@ -480,6 +481,34 @@ export class DateTimeUtils { | @@ -480,6 +481,34 @@ export class DateTimeUtils { | ||
| 480 | return 0 | 481 | return 0 |
| 481 | } | 482 | } |
| 482 | } | 483 | } |
| 484 | + /** | ||
| 485 | + * 进度值换算 | ||
| 486 | + * @param seconds | ||
| 487 | + * @returns | ||
| 488 | + */ | ||
| 489 | + static secondToTime(seconds: number) { | ||
| 490 | + let time = '00:00' | ||
| 491 | + let hourUnit = 60 * 60; | ||
| 492 | + let hour = Math.floor(seconds / hourUnit); | ||
| 493 | + let minute = Math.floor((seconds - hour * hourUnit) / 60); | ||
| 494 | + let second = seconds - hour * hourUnit - minute * 60; | ||
| 495 | + if (hour > 0) { | ||
| 496 | + return `${DateTimeUtils.padding(hour.toString())}${':'}${DateTimeUtils.padding(minute.toString())}${':'}${DateTimeUtils.padding(second.toString())}`; | ||
| 497 | + } | ||
| 498 | + if (minute > 0) { | ||
| 499 | + return `${DateTimeUtils.padding(minute.toString())}${':'}${DateTimeUtils.padding(second.toString())}`; | ||
| 500 | + } else { | ||
| 501 | + return `${'00'}${':'}${DateTimeUtils.padding(second.toString())}`; | ||
| 502 | + } | ||
| 503 | + } | ||
| 504 | + | ||
| 505 | + static padding(num: string) { | ||
| 506 | + let length = 2; | ||
| 507 | + for (let len = (num.toString()).length; len < length; len = num.length) { | ||
| 508 | + num = `${'0'}${num}`; | ||
| 509 | + } | ||
| 510 | + return num; | ||
| 511 | + } | ||
| 483 | } | 512 | } |
| 484 | 513 | ||
| 485 | // const dateTimeUtils = new DateTimeUtils() | 514 | // const dateTimeUtils = new DateTimeUtils() |
| @@ -7,7 +7,17 @@ export namespace ErrorToastUtils { | @@ -7,7 +7,17 @@ export namespace ErrorToastUtils { | ||
| 7 | NET_CORE_PAGE_ERROR_NETWORK, //网络出小差了,请检查网络后重试 | 7 | NET_CORE_PAGE_ERROR_NETWORK, //网络出小差了,请检查网络后重试 |
| 8 | NET_CORE_LOAD_ERROR_NETWORK, //加载失败,请重试 | 8 | NET_CORE_LOAD_ERROR_NETWORK, //加载失败,请重试 |
| 9 | NET_CORE_ENTER_ERROR_NETWORK, //很抱歉,当前内容无法加载,请点击重试 | 9 | NET_CORE_ENTER_ERROR_NETWORK, //很抱歉,当前内容无法加载,请点击重试 |
| 10 | - LIVE_CORE_NO_NETWORK, //网络出小差了,请检查下网络 | 10 | + |
| 11 | + //直播异常 | ||
| 12 | + LIVE_CORE_NO_NETWORK, //直播 无网络 网络出小差了,请检查下网络 | ||
| 13 | + LIVE_CORE_WEAK_NETWORK, //直播 弱网 网络出小差了,请检查下网络 | ||
| 14 | + LIVE_CORE_IO_NETWORK, //直播 直播流异常 直播加载异常 | ||
| 15 | + LIVE_CORE_SERVICE_NETWORK, //直播 服务端接口异常 直播加载异常 | ||
| 16 | + LIVE_CORE_SWITCH_FLOW_NETWORK, //直播 网络切换到流量 正在使用流量,请注意流量使用 | ||
| 17 | + | ||
| 18 | + //审核后异常报错 | ||
| 19 | + AUDITING_CORE_CONTENT_DISTRIBUTE, //审核 内容分发下线规则 内容已下线 | ||
| 20 | + AUDITING_CORE_ACCOUNT_ERROR, //审核 账号有问题下线规则 内容已下线 | ||
| 11 | 21 | ||
| 12 | } | 22 | } |
| 13 | 23 | ||
| @@ -32,6 +42,27 @@ export namespace ErrorToastUtils { | @@ -32,6 +42,27 @@ export namespace ErrorToastUtils { | ||
| 32 | case ErrorType.LIVE_CORE_NO_NETWORK: | 42 | case ErrorType.LIVE_CORE_NO_NETWORK: |
| 33 | ToastUtils.shortToast($r('app.string.live_core_no_network')) | 43 | ToastUtils.shortToast($r('app.string.live_core_no_network')) |
| 34 | break | 44 | break |
| 45 | + case ErrorType.LIVE_CORE_WEAK_NETWORK: | ||
| 46 | + ToastUtils.shortToast($r('app.string.live_core_weak_network')) | ||
| 47 | + break | ||
| 48 | + case ErrorType.LIVE_CORE_IO_NETWORK: | ||
| 49 | + ToastUtils.shortToast($r('app.string.live_core_io_network')) | ||
| 50 | + break | ||
| 51 | + case ErrorType.LIVE_CORE_SERVICE_NETWORK: | ||
| 52 | + ToastUtils.shortToast($r('app.string.live_core_service_network')) | ||
| 53 | + break | ||
| 54 | + case ErrorType.LIVE_CORE_SWITCH_FLOW_NETWORK: | ||
| 55 | + ToastUtils.shortToast($r('app.string.live_core_switch_flow_network')) | ||
| 56 | + break | ||
| 57 | + case ErrorType.LIVE_CORE_SWITCH_FLOW_NETWORK: | ||
| 58 | + ToastUtils.shortToast($r('app.string.live_core_switch_flow_network')) | ||
| 59 | + break | ||
| 60 | + case ErrorType.AUDITING_CORE_CONTENT_DISTRIBUTE: | ||
| 61 | + ToastUtils.shortToast($r('app.string.auditing_core_error')) | ||
| 62 | + break | ||
| 63 | + case ErrorType.AUDITING_CORE_ACCOUNT_ERROR: | ||
| 64 | + ToastUtils.shortToast($r('app.string.auditing_core_error')) | ||
| 65 | + break | ||
| 35 | } | 66 | } |
| 36 | 67 | ||
| 37 | } | 68 | } |
| @@ -27,6 +27,26 @@ | @@ -27,6 +27,26 @@ | ||
| 27 | { | 27 | { |
| 28 | "name": "live_core_no_network", | 28 | "name": "live_core_no_network", |
| 29 | "value": "网络出小差了,请检查下网络" | 29 | "value": "网络出小差了,请检查下网络" |
| 30 | + }, | ||
| 31 | + { | ||
| 32 | + "name": "live_core_weak_network", | ||
| 33 | + "value": "网络出小差了,请检查下网络" | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + "name": "live_core_io_network", | ||
| 37 | + "value": "直播加载异常" | ||
| 38 | + }, | ||
| 39 | + { | ||
| 40 | + "name": "live_core_service_network", | ||
| 41 | + "value": "直播加载异常" | ||
| 42 | + }, | ||
| 43 | + { | ||
| 44 | + "name": "live_core_switch_flow_network", | ||
| 45 | + "value": "正在使用流量,请注意流量使用" | ||
| 46 | + }, | ||
| 47 | + { | ||
| 48 | + "name": "auditing_core_error", | ||
| 49 | + "value": "内容已下线" | ||
| 30 | } | 50 | } |
| 31 | ] | 51 | ] |
| 32 | } | 52 | } |
| 1 | -import HashMap from '@ohos.util.HashMap' | ||
| 2 | -import { ConfigConstants, SpConstants } from 'wdConstant' | ||
| 3 | -import { DateTimeUtils, Logger, SPHelper, StringUtils } from 'wdKit' | 1 | +import HashMap from '@ohos.util.HashMap'; |
| 2 | +import { SpConstants } from 'wdConstant'; | ||
| 3 | +import { SPHelper, StringUtils } from 'wdKit'; | ||
| 4 | 4 | ||
| 5 | /** | 5 | /** |
| 6 | * 网络请求业务侧工具类 | 6 | * 网络请求业务侧工具类 |
| @@ -213,6 +213,18 @@ export class HttpUrlUtils { | @@ -213,6 +213,18 @@ export class HttpUrlUtils { | ||
| 213 | */ | 213 | */ |
| 214 | static readonly LIVE_CHAT_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/chat/list"; | 214 | static readonly LIVE_CHAT_LIST_PATH: string = "/api/live-center-message/zh/a/live/message/chat/list"; |
| 215 | /** | 215 | /** |
| 216 | + * 直播详情-直播数据 | ||
| 217 | + */ | ||
| 218 | + static readonly LIVE_ROOM_DATA_PATH: string = "/api/live-center-message/zh/a/live/room/number/all"; | ||
| 219 | + /** | ||
| 220 | + * 直播详情-预约直播状态 | ||
| 221 | + */ | ||
| 222 | + static readonly LIVE_APPOINTMENT_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe/query"; | ||
| 223 | + /** | ||
| 224 | + * 直播详情-预约/取消预约直播 | ||
| 225 | + */ | ||
| 226 | + static readonly LIVE_APPOINTMENT_PATH: string = "/api/live-center-message/zh/c/live/subscribe"; | ||
| 227 | + /** | ||
| 216 | 228 | ||
| 217 | * 搜索结果 显示tab 数 | 229 | * 搜索结果 显示tab 数 |
| 218 | */ | 230 | */ |
| @@ -653,6 +665,21 @@ export class HttpUrlUtils { | @@ -653,6 +665,21 @@ export class HttpUrlUtils { | ||
| 653 | return url | 665 | return url |
| 654 | } | 666 | } |
| 655 | 667 | ||
| 668 | + static getLiveRoomDataUrl() { | ||
| 669 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_ROOM_DATA_PATH | ||
| 670 | + return url | ||
| 671 | + } | ||
| 672 | + | ||
| 673 | + static getLiveAppointmentStatusUrl() { | ||
| 674 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_APPOINTMENT_STATUS_PATH | ||
| 675 | + return url | ||
| 676 | + } | ||
| 677 | + | ||
| 678 | + static getLiveAppointmentUrl() { | ||
| 679 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.LIVE_APPOINTMENT_PATH | ||
| 680 | + return url | ||
| 681 | + } | ||
| 682 | + | ||
| 656 | static getSearchResultCountDataUrl() { | 683 | static getSearchResultCountDataUrl() { |
| 657 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH | 684 | let url = HttpUrlUtils._hostUrl + HttpUrlUtils.SEARCH_RESULT_COUNT_DATA_PATH |
| 658 | return url | 685 | return url |
| @@ -120,3 +120,5 @@ export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO | @@ -120,3 +120,5 @@ export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO | ||
| 120 | 120 | ||
| 121 | export { LiveRoomBean,LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoomBean'; | 121 | export { LiveRoomBean,LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoomBean'; |
| 122 | 122 | ||
| 123 | +export { LiveRoomDataBean } from './src/main/ets/bean/live/LiveRoomDataBean'; | ||
| 124 | + |
| @@ -29,4 +29,9 @@ export interface CompDTO { | @@ -29,4 +29,9 @@ export interface CompDTO { | ||
| 29 | subType: string; | 29 | subType: string; |
| 30 | imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 | 30 | imageScale: number; // 封面图比例 1-4:3, 2-16:9, 3-3:2 |
| 31 | audioDataList: AudioDTO[]; | 31 | audioDataList: AudioDTO[]; |
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 组件内容源类型 (LIVE_HORIZONTAL_CARD\LIVE_RESERVATION\LIVE_LARGE_CARD\LIVE_END\LIVE_MONTHLY_RANKING ) | ||
| 35 | + */ | ||
| 36 | + dataSourceType: string; | ||
| 32 | } | 37 | } |
| @@ -2,6 +2,7 @@ import { CompDTO } from './CompDTO'; | @@ -2,6 +2,7 @@ import { CompDTO } from './CompDTO'; | ||
| 2 | 2 | ||
| 3 | /** | 3 | /** |
| 4 | * Page数据DTO | 4 | * Page数据DTO |
| 5 | + * 其实是comp接口(display/zh/c/compInfo)返回 | ||
| 5 | */ | 6 | */ |
| 6 | export interface PageDTO { | 7 | export interface PageDTO { |
| 7 | pageId: string; // 页面id | 8 | pageId: string; // 页面id |
| @@ -158,9 +158,12 @@ export interface LiveDetailsBean { | @@ -158,9 +158,12 @@ export interface LiveDetailsBean { | ||
| 158 | */ | 158 | */ |
| 159 | liveInfo: LiveInfo | 159 | liveInfo: LiveInfo |
| 160 | fullColumnImgUrls: Array<FullColumnImgUrls> | 160 | fullColumnImgUrls: Array<FullColumnImgUrls> |
| 161 | - vlive: Array<Vlive> | ||
| 162 | newsTitle: string | 161 | newsTitle: string |
| 162 | + newsId: string | ||
| 163 | newIntroduction: string | 163 | newIntroduction: string |
| 164 | + //迁移id | ||
| 165 | + oldNewsId: string | ||
| 166 | + reLInfo: ReLInfo | ||
| 164 | } | 167 | } |
| 165 | 168 | ||
| 166 | export interface LiveInfo { | 169 | export interface LiveInfo { |
| @@ -168,8 +171,12 @@ export interface LiveInfo { | @@ -168,8 +171,12 @@ export interface LiveInfo { | ||
| 168 | liveState: string | 171 | liveState: string |
| 169 | //2024-04-12 15:00:00 直播开始时间 | 172 | //2024-04-12 15:00:00 直播开始时间 |
| 170 | planStartTime: string | 173 | planStartTime: string |
| 174 | + vlive: Array<Vlive> | ||
| 175 | + mlive:MLive | ||
| 176 | +} | ||
| 177 | +export interface MLive { | ||
| 178 | + mliveId:string | ||
| 171 | } | 179 | } |
| 172 | - | ||
| 173 | export interface FullColumnImgUrls { | 180 | export interface FullColumnImgUrls { |
| 174 | url: string | 181 | url: string |
| 175 | } | 182 | } |
| @@ -179,4 +186,8 @@ export interface Vlive { | @@ -179,4 +186,8 @@ export interface Vlive { | ||
| 179 | liveUrl: string | 186 | liveUrl: string |
| 180 | //直播回看地址,多路直播录制文件URL | 187 | //直播回看地址,多路直播录制文件URL |
| 181 | replayUri: string | 188 | replayUri: string |
| 189 | +} | ||
| 190 | + | ||
| 191 | +export interface ReLInfo { | ||
| 192 | + relId: string | ||
| 182 | } | 193 | } |
| @@ -14,7 +14,12 @@ export struct DynamicDetailComponent { | @@ -14,7 +14,12 @@ export struct DynamicDetailComponent { | ||
| 14 | private contentId: string = '' | 14 | private contentId: string = '' |
| 15 | private relType: string = '' | 15 | private relType: string = '' |
| 16 | //出参 | 16 | //出参 |
| 17 | - @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] | 17 | + @State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO |
| 18 | + //变量 | ||
| 19 | + /** | ||
| 20 | + * 默认未关注 点击去关注 | ||
| 21 | + */ | ||
| 22 | + private followStatus: boolean = false; | ||
| 18 | 23 | ||
| 19 | 24 | ||
| 20 | async aboutToAppear() { | 25 | async aboutToAppear() { |
| @@ -25,17 +30,97 @@ export struct DynamicDetailComponent { | @@ -25,17 +30,97 @@ export struct DynamicDetailComponent { | ||
| 25 | } | 30 | } |
| 26 | 31 | ||
| 27 | build() { | 32 | build() { |
| 28 | - Row() { | ||
| 29 | - Column(){ | ||
| 30 | - Text("this is a test!") | 33 | + Row() { |
| 34 | + Column(){ | ||
| 35 | + //logo、日期 | ||
| 36 | + Row() { | ||
| 37 | + Image($r('app.media.ic_article_rmh')) | ||
| 38 | + .width(80) | ||
| 39 | + .height(28) | ||
| 40 | + .margin({ left: 16 }) | ||
| 41 | + Blank() | ||
| 42 | + Text("2023年03月14日 08:16") | ||
| 43 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 44 | + .fontSize(12) | ||
| 45 | + .lineHeight(28) | ||
| 46 | + .margin({ right: 16 }) | ||
| 31 | } | 47 | } |
| 48 | + .height(48) | ||
| 49 | + .width('100%') | ||
| 50 | + //分割线 | ||
| 51 | + Image($r('app.media.ic_news_detail_division')) | ||
| 52 | + .width('100%') | ||
| 53 | + .height(7) | ||
| 54 | + .margin({left: 16, right: 16} ) | ||
| 55 | + //号主信息 | ||
| 56 | + Row() { | ||
| 57 | + //头像 | ||
| 58 | + Stack() { | ||
| 59 | + Image(this.contentDetailData.rmhInfo?.rmhHeadUrl) | ||
| 60 | + .alt(this.contentDetailData.rmhInfo?.userType=='1'?$r('app.media.default_head'):$r('app.media.icon_default_head_mater')) | ||
| 61 | + .width('32') | ||
| 62 | + .height('32') | ||
| 63 | + .objectFit(ImageFit.Cover) | ||
| 64 | + .borderRadius(16) | ||
| 65 | + Image($r('app.media.icon_border_test')) | ||
| 66 | + .width('48') | ||
| 67 | + .height('48') | ||
| 68 | + .objectFit(ImageFit.Cover) | ||
| 69 | + .borderRadius(24) | ||
| 70 | + } | ||
| 71 | + .width(48) | ||
| 72 | + .height(48) | ||
| 73 | + .alignContent(Alignment.Center) | ||
| 74 | + Column(){ | ||
| 75 | + //昵称 | ||
| 76 | + Text("this.contentDetailData.rmhInfo?.rmhName") | ||
| 77 | + .fontSize(14) | ||
| 78 | + .fontColor($r('app.color.color_222222')) | ||
| 79 | + .fontWeight(FontWeight.Medium) | ||
| 80 | + .margin({ left: 5 }) | ||
| 81 | + //简介 | ||
| 82 | + Text("this.contentDetailData.rmhInfo?.rmhDesc") | ||
| 83 | + .fontSize(14) | ||
| 84 | + .fontColor($r('app.color.color_B0B0B0')) | ||
| 85 | + .fontWeight(FontWeight.Medium) | ||
| 86 | + .margin({ left: 5 }) | ||
| 87 | + } | ||
| 88 | + if (!this.followStatus) { | ||
| 89 | + Text('关注') | ||
| 90 | + .width(60) | ||
| 91 | + .height(24) | ||
| 92 | + .textAlign(TextAlign.Center) | ||
| 93 | + .fontSize($r('app.float.font_size_12')) | ||
| 94 | + .borderRadius($r('app.float.button_border_radius')) | ||
| 95 | + .backgroundColor($r('app.color.color_ED2800')) | ||
| 96 | + .fontColor($r('app.color.color_fff')) | ||
| 97 | + .onClick(() => { | ||
| 98 | + // this.handleAccention(this.item, 1) | ||
| 99 | + }) | ||
| 100 | + } else { | ||
| 101 | + Text('已关注') | ||
| 102 | + .width(60) | ||
| 103 | + .height(24) | ||
| 104 | + .borderWidth(1) | ||
| 105 | + .textAlign(TextAlign.Center) | ||
| 106 | + .fontSize($r('app.float.font_size_12')) | ||
| 107 | + .borderRadius($r('app.float.button_border_radius')) | ||
| 108 | + .borderColor($r('app.color.color_CCCCCC')) | ||
| 109 | + .fontColor($r('app.color.color_CCCCCC')) | ||
| 110 | + .onClick(() => { | ||
| 111 | + // this.handleAccention(this.item, 0) | ||
| 112 | + }) | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + .width('100%') | ||
| 32 | } | 116 | } |
| 33 | - | 117 | + } |
| 118 | + .backgroundColor('#FFFFFFFF') | ||
| 34 | } | 119 | } |
| 35 | private async getContentDetailData() { | 120 | private async getContentDetailData() { |
| 36 | try { | 121 | try { |
| 37 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | 122 | let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) |
| 38 | - this.contentDetailData = data; | 123 | + this.contentDetailData = data[0]; |
| 39 | console.log('动态详情',JSON.stringify(this.contentDetailData)) | 124 | console.log('动态详情',JSON.stringify(this.contentDetailData)) |
| 40 | } catch (exception) { | 125 | } catch (exception) { |
| 41 | console.log('请求失败',JSON.stringify(exception)) | 126 | console.log('请求失败',JSON.stringify(exception)) |
| @@ -77,11 +77,6 @@ export struct CardMediaInfo { | @@ -77,11 +77,6 @@ export struct CardMediaInfo { | ||
| 77 | .width(14) | 77 | .width(14) |
| 78 | .height(14) | 78 | .height(14) |
| 79 | .margin({ right: 3 }) | 79 | .margin({ right: 3 }) |
| 80 | - .shadow({ | ||
| 81 | - radius: 2, | ||
| 82 | - color: 'rgba(0,0,0,0.3)', | ||
| 83 | - offsetY: 2 | ||
| 84 | - }) | ||
| 85 | } | 80 | } |
| 86 | } | 81 | } |
| 87 | 82 |
| @@ -5,51 +5,49 @@ import { DateTimeUtils } from 'wdKit/Index'; | @@ -5,51 +5,49 @@ import { DateTimeUtils } from 'wdKit/Index'; | ||
| 5 | @Component | 5 | @Component |
| 6 | export struct CardSourceInfo { | 6 | export struct CardSourceInfo { |
| 7 | @State contentDTO: ContentDTO = {} as ContentDTO; | 7 | @State contentDTO: ContentDTO = {} as ContentDTO; |
| 8 | + | ||
| 8 | build() { | 9 | build() { |
| 9 | Flex() { | 10 | Flex() { |
| 10 | - if(this.contentDTO.corner) { | 11 | + if (this.contentDTO.corner) { |
| 11 | Text(this.contentDTO.corner) | 12 | Text(this.contentDTO.corner) |
| 12 | .fontSize($r("app.float.font_size_12")) | 13 | .fontSize($r("app.float.font_size_12")) |
| 13 | .fontColor($r("app.color.color_ED2800")) | 14 | .fontColor($r("app.color.color_ED2800")) |
| 14 | - .margin({right: 2}) | 15 | + .margin({ right: 2 }) |
| 15 | } | 16 | } |
| 16 | - if(this.contentDTO.rmhPlatform === 1) { | 17 | + if (this.contentDTO.rmhPlatform === 1) { |
| 17 | Text(this.contentDTO.rmhInfo.rmhName) | 18 | Text(this.contentDTO.rmhInfo.rmhName) |
| 18 | .fontSize($r("app.float.font_size_12")) | 19 | .fontSize($r("app.float.font_size_12")) |
| 19 | .fontColor($r("app.color.color_B0B0B0")) | 20 | .fontColor($r("app.color.color_B0B0B0")) |
| 20 | .maxLines(1) | 21 | .maxLines(1) |
| 21 | - .textOverflow({overflow: TextOverflow.Ellipsis}) | ||
| 22 | - Image($r("app.media.point")) | ||
| 23 | - .width(16) | ||
| 24 | - .height(16) | ||
| 25 | - } else if(this.contentDTO.source) { | 22 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 23 | + } else if (this.contentDTO.source) { | ||
| 26 | Text(`${this.contentDTO.source}`) | 24 | Text(`${this.contentDTO.source}`) |
| 27 | .fontSize($r("app.float.font_size_12")) | 25 | .fontSize($r("app.float.font_size_12")) |
| 28 | .fontColor($r("app.color.color_B0B0B0")) | 26 | .fontColor($r("app.color.color_B0B0B0")) |
| 29 | .maxLines(1) | 27 | .maxLines(1) |
| 30 | - .textOverflow({overflow: TextOverflow.Ellipsis}) | 28 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 31 | } | 29 | } |
| 32 | // 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间 | 30 | // 新闻tab下的卡片,2天之前的不显示时间。但是如果是搜索情况下展示的卡片,显示时间 |
| 33 | - if(this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime | 31 | + if (this.contentDTO.isSearch || !this.contentDTO.isSearch && DateTimeUtils.getCommentTime |
| 34 | (Number | 32 | (Number |
| 35 | .parseFloat(this | 33 | .parseFloat(this |
| 36 | - .contentDTO.publishTime)) | 34 | + .contentDTO.publishTime)) |
| 37 | .indexOf | 35 | .indexOf |
| 38 | - ('-') === -1) { | 36 | + ('-') === -1) { |
| 39 | Image($r("app.media.point")) | 37 | Image($r("app.media.point")) |
| 40 | .width(16) | 38 | .width(16) |
| 41 | .height(16) | 39 | .height(16) |
| 42 | Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) | 40 | Text(DateTimeUtils.getCommentTime(Number.parseFloat(this.contentDTO.publishTime))) |
| 43 | .fontSize($r("app.float.font_size_12")) | 41 | .fontSize($r("app.float.font_size_12")) |
| 44 | .fontColor($r("app.color.color_B0B0B0")) | 42 | .fontColor($r("app.color.color_B0B0B0")) |
| 45 | - .margin({ right: 6 }) | ||
| 46 | .flexShrink(0) | 43 | .flexShrink(0) |
| 47 | } | 44 | } |
| 48 | - if(this.contentDTO?.interactData?.commentNum) { | 45 | + if (this.contentDTO?.interactData?.commentNum) { |
| 49 | Text(`${this.contentDTO.interactData.commentNum}评`) | 46 | Text(`${this.contentDTO.interactData.commentNum}评`) |
| 50 | .fontSize($r("app.float.font_size_12")) | 47 | .fontSize($r("app.float.font_size_12")) |
| 51 | .fontColor($r("app.color.color_B0B0B0")) | 48 | .fontColor($r("app.color.color_B0B0B0")) |
| 52 | .flexShrink(0) | 49 | .flexShrink(0) |
| 50 | + .margin({ left: 6 }) | ||
| 53 | } | 51 | } |
| 54 | } | 52 | } |
| 55 | .width(CommonConstants.FULL_WIDTH) | 53 | .width(CommonConstants.FULL_WIDTH) |
| 1 | import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean'; | 1 | import { ContentDTO, FullColumnImgUrlDTO } from 'wdBean'; |
| 2 | import { RmhTitle } from '../cardCommon/RmhTitle' | 2 | import { RmhTitle } from '../cardCommon/RmhTitle' |
| 3 | - | 3 | +import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 4 | const TAG = 'Card19Component'; | 4 | const TAG = 'Card19Component'; |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| @@ -94,6 +94,9 @@ export struct Card19Component { | @@ -94,6 +94,9 @@ export struct Card19Component { | ||
| 94 | top: $r('app.float.card_comp_pagePadding_tb'), | 94 | top: $r('app.float.card_comp_pagePadding_tb'), |
| 95 | bottom: $r('app.float.card_comp_pagePadding_tb') | 95 | bottom: $r('app.float.card_comp_pagePadding_tb') |
| 96 | }) | 96 | }) |
| 97 | + .onClick((event: ClickEvent) => { | ||
| 98 | + ProcessUtils.processPage(this.contentDTO) | ||
| 99 | + }) | ||
| 97 | } | 100 | } |
| 98 | } | 101 | } |
| 99 | 102 |
| @@ -2,7 +2,7 @@ import { ContentDTO } from 'wdBean'; | @@ -2,7 +2,7 @@ import { ContentDTO } from 'wdBean'; | ||
| 2 | import { RmhTitle } from '../cardCommon/RmhTitle' | 2 | import { RmhTitle } from '../cardCommon/RmhTitle' |
| 3 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | 3 | import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 4 | import { CommonConstants } from 'wdConstant/Index'; | 4 | import { CommonConstants } from 'wdConstant/Index'; |
| 5 | - | 5 | +import { ProcessUtils } from '../../utils/ProcessUtils'; |
| 6 | const TAG = 'Card20Component'; | 6 | const TAG = 'Card20Component'; |
| 7 | 7 | ||
| 8 | /** | 8 | /** |
| @@ -71,6 +71,9 @@ export struct Card20Component { | @@ -71,6 +71,9 @@ export struct Card20Component { | ||
| 71 | top: $r('app.float.card_comp_pagePadding_tb'), | 71 | top: $r('app.float.card_comp_pagePadding_tb'), |
| 72 | bottom: $r('app.float.card_comp_pagePadding_tb') | 72 | bottom: $r('app.float.card_comp_pagePadding_tb') |
| 73 | }) | 73 | }) |
| 74 | + .onClick((event: ClickEvent) => { | ||
| 75 | + ProcessUtils.processPage(this.contentDTO) | ||
| 76 | + }) | ||
| 74 | } | 77 | } |
| 75 | } | 78 | } |
| 76 | 79 |
| @@ -2,7 +2,7 @@ import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI' | @@ -2,7 +2,7 @@ import { CustomTitleAndEditUI } from '../reusable/CustomTitleAndEditUI' | ||
| 2 | import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; | 2 | import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; |
| 3 | import PageModel from '../../viewmodel/PageModel'; | 3 | import PageModel from '../../viewmodel/PageModel'; |
| 4 | import { CommonConstants, ViewType } from 'wdConstant' | 4 | import { CommonConstants, ViewType } from 'wdConstant' |
| 5 | -import { EmptyComponent } from '../view/EmptyComponent' | 5 | +import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent' |
| 6 | import { ErrorComponent } from '../view/ErrorComponent' | 6 | import { ErrorComponent } from '../view/ErrorComponent' |
| 7 | import RefreshLayout from './RefreshLayout' | 7 | import RefreshLayout from './RefreshLayout' |
| 8 | import { RefreshLayoutBean } from './RefreshLayoutBean'; | 8 | import { RefreshLayoutBean } from './RefreshLayoutBean'; |
| @@ -43,7 +43,7 @@ struct MyCollectionListPage { | @@ -43,7 +43,7 @@ struct MyCollectionListPage { | ||
| 43 | }else if(this.browSingModel.viewType == ViewType.ERROR){ | 43 | }else if(this.browSingModel.viewType == ViewType.ERROR){ |
| 44 | ErrorComponent() | 44 | ErrorComponent() |
| 45 | }else if(this.browSingModel.viewType == ViewType.EMPTY){ | 45 | }else if(this.browSingModel.viewType == ViewType.EMPTY){ |
| 46 | - EmptyComponent() | 46 | + EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoCollection}) |
| 47 | }else { | 47 | }else { |
| 48 | this.ListLayout() | 48 | this.ListLayout() |
| 49 | } | 49 | } |
| 1 | -import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit'; | ||
| 2 | -import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; | 1 | +import { CommonConstants, ViewType } from 'wdConstant'; |
| 2 | +import { Logger } from 'wdKit'; | ||
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | import { EmptyComponent } from '../view/EmptyComponent'; | 4 | import { EmptyComponent } from '../view/EmptyComponent'; |
| 5 | import { ErrorComponent } from '../view/ErrorComponent'; | 5 | import { ErrorComponent } from '../view/ErrorComponent'; |
| @@ -11,9 +11,8 @@ import NoMoreLayout from './NoMoreLayout'; | @@ -11,9 +11,8 @@ import NoMoreLayout from './NoMoreLayout'; | ||
| 11 | import LoadMoreLayout from './LoadMoreLayout'; | 11 | import LoadMoreLayout from './LoadMoreLayout'; |
| 12 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | 12 | import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; |
| 13 | import { CompParser } from '../CompParser'; | 13 | import { CompParser } from '../CompParser'; |
| 14 | -import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | ||
| 15 | -import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean'; | ||
| 16 | - | 14 | +import { CompDTO } from 'wdBean'; |
| 15 | +import PageHelper from '../../viewmodel/PageHelper'; | ||
| 17 | 16 | ||
| 18 | const TAG = 'PageComponent'; | 17 | const TAG = 'PageComponent'; |
| 19 | 18 | ||
| @@ -23,22 +22,6 @@ export struct PageComponent { | @@ -23,22 +22,6 @@ export struct PageComponent { | ||
| 23 | navIndex: number = 0; | 22 | navIndex: number = 0; |
| 24 | pageId: string = ""; | 23 | pageId: string = ""; |
| 25 | channelId: string = ""; | 24 | channelId: string = ""; |
| 26 | - pageNum: number = 1; | ||
| 27 | - isFirstIn: boolean = true | ||
| 28 | - pageDto: PageDTO = { | ||
| 29 | - pageId: '', | ||
| 30 | - id: 0, | ||
| 31 | - name: '', | ||
| 32 | - branchMark: false, | ||
| 33 | - compList: [] | ||
| 34 | - } | ||
| 35 | - liveReviewDTO: LiveReviewDTO = { | ||
| 36 | - hasNext: false, | ||
| 37 | - pageNum: 0, | ||
| 38 | - pageSize: 0, | ||
| 39 | - totalCount: 0, | ||
| 40 | - list: [] | ||
| 41 | - }; | ||
| 42 | @Link @Watch('onChange') currentTopNavSelectedIndex: number | 25 | @Link @Watch('onChange') currentTopNavSelectedIndex: number |
| 43 | 26 | ||
| 44 | build() { | 27 | build() { |
| @@ -69,7 +52,6 @@ export struct PageComponent { | @@ -69,7 +52,6 @@ export struct PageComponent { | ||
| 69 | @Builder | 52 | @Builder |
| 70 | ListLayout() { | 53 | ListLayout() { |
| 71 | List() { | 54 | List() { |
| 72 | - | ||
| 73 | // 下拉刷新 | 55 | // 下拉刷新 |
| 74 | ListItem() { | 56 | ListItem() { |
| 75 | RefreshLayout({ | 57 | RefreshLayout({ |
| @@ -99,7 +81,6 @@ export struct PageComponent { | @@ -99,7 +81,6 @@ export struct PageComponent { | ||
| 99 | NoMoreLayout() | 81 | NoMoreLayout() |
| 100 | } | 82 | } |
| 101 | } | 83 | } |
| 102 | - | ||
| 103 | } | 84 | } |
| 104 | .scrollBar(BarState.Off) | 85 | .scrollBar(BarState.Off) |
| 105 | .cachedCount(8) | 86 | .cachedCount(8) |
| @@ -122,171 +103,32 @@ export struct PageComponent { | @@ -122,171 +103,32 @@ export struct PageComponent { | ||
| 122 | 103 | ||
| 123 | async aboutToAppear() { | 104 | async aboutToAppear() { |
| 124 | // 选中tab,才请求数据。拦截大量接口请求 | 105 | // 选中tab,才请求数据。拦截大量接口请求 |
| 125 | - if (this.navIndex === 0 && this.navIndex === this.currentTopNavSelectedIndex) { | 106 | + if (this.navIndex === this.currentTopNavSelectedIndex) { |
| 126 | this.getData(); | 107 | this.getData(); |
| 127 | - } else if (this.navIndex === 1) { | ||
| 128 | - this.getPreviewData() | ||
| 129 | } | 108 | } |
| 130 | - | ||
| 131 | } | 109 | } |
| 132 | 110 | ||
| 133 | onChange() { | 111 | onChange() { |
| 134 | - Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , ${this.isFirstIn} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 135 | - // if (this.navIndex === this.currentTopNavSelectedIndex && !this.isFirstIn) { | 112 | + Logger.info(TAG, `onChangezz id: ${this.pageId} , ${this.channelId} , ${this.navIndex} , navIndex: ${this.currentTopNavSelectedIndex}`); |
| 136 | if (this.navIndex === this.currentTopNavSelectedIndex) { | 113 | if (this.navIndex === this.currentTopNavSelectedIndex) { |
| 137 | this.getData(); | 114 | this.getData(); |
| 138 | } | 115 | } |
| 139 | } | 116 | } |
| 140 | 117 | ||
| 141 | - /** | ||
| 142 | - * 要按顺序处理pageInfo.groups中的每个元素,并确保每个异步操作完成后再继续执行下一个,你应该避免使用forEach。 | ||
| 143 | - * 取而代之的是,你可以使用for...of循环,并配合async/await来确保按顺序执行操作。 | ||
| 144 | - * */ | ||
| 145 | async getData() { | 118 | async getData() { |
| 146 | Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | 119 | Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); |
| 147 | this.pageModel.pageId = this.pageId; | 120 | this.pageModel.pageId = this.pageId; |
| 148 | this.pageModel.groupId = this.pageId; | 121 | this.pageModel.groupId = this.pageId; |
| 149 | this.pageModel.channelId = this.channelId; | 122 | this.pageModel.channelId = this.channelId; |
| 150 | this.pageModel.currentPage = 1; | 123 | this.pageModel.currentPage = 1; |
| 151 | - let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | 124 | + let pageInfo = await PageViewModel.getPageInfo(this.pageModel.pageId); |
| 152 | if (pageInfo == null) { | 125 | if (pageInfo == null) { |
| 153 | this.pageModel.viewType = ViewType.EMPTY; | 126 | this.pageModel.viewType = ViewType.EMPTY; |
| 154 | return; | 127 | return; |
| 155 | } | 128 | } |
| 156 | - if (this.navIndex === 0) { | ||
| 157 | - await this.getVideoListData(pageInfo); | ||
| 158 | - } else { | ||
| 159 | - await this.getLiveListData(pageInfo); | ||
| 160 | - } | ||
| 161 | - | ||
| 162 | - | ||
| 163 | - } | ||
| 164 | - | ||
| 165 | - private async getVideoListData(pageInfo: PageInfoBean) { | ||
| 166 | - let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); | ||
| 167 | - if (groupInfo != null) { | ||
| 168 | - this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; | ||
| 169 | - this.pageModel.groupId = groupInfo.id; | ||
| 170 | - } | ||
| 171 | - // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 172 | - // for (const group of pageInfo.groups) { | ||
| 173 | - this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 174 | - this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 175 | - if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 176 | - this.pageDto.compList.forEach((comp) => { | ||
| 177 | - if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 178 | - comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 179 | - } | ||
| 180 | - }); | ||
| 181 | - | ||
| 182 | - this.pageModel.viewType = ViewType.LOADED; | ||
| 183 | - this.pageModel.compList.push(...this.pageDto.compList); | ||
| 184 | - if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 185 | - this.pageModel.currentPage++; | ||
| 186 | - this.pageModel.hasMore = true; | ||
| 187 | - } else { | ||
| 188 | - this.pageModel.hasMore = false; | ||
| 189 | - } | ||
| 190 | - // // 二次请求,批查互动数据 | ||
| 191 | - // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 192 | - // // 刷新,替换所有数据 | ||
| 193 | - // this.pageModel.compList.replaceAll(...data) | ||
| 194 | - // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 195 | - // }) | ||
| 196 | - this.isFirstIn = false; | ||
| 197 | - Logger.debug(TAG, 'cj111'); | ||
| 198 | - // } else { | ||
| 199 | - // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 200 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 201 | - // } | ||
| 202 | - } | ||
| 203 | - } | ||
| 204 | - | ||
| 205 | - // private async getLiveListData(pageInfo: PageInfoBean) { | ||
| 206 | - // // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 207 | - // for (const group of pageInfo.groups) { | ||
| 208 | - // this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 209 | - // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 210 | - // if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 211 | - // this.pageDto.compList.forEach((comp) => { | ||
| 212 | - // if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 213 | - // comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 214 | - // } | ||
| 215 | - // }); | ||
| 216 | - // | ||
| 217 | - // this.pageModel.viewType = ViewType.LOADED; | ||
| 218 | - // this.pageModel.compList.push(...this.pageDto.compList); | ||
| 219 | - // if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 220 | - // this.pageModel.currentPage++; | ||
| 221 | - // this.pageModel.hasMore = true; | ||
| 222 | - // } else { | ||
| 223 | - // this.pageModel.hasMore = false; | ||
| 224 | - // } | ||
| 225 | - // // // 二次请求,批查互动数据 | ||
| 226 | - // // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 227 | - // // // 刷新,替换所有数据 | ||
| 228 | - // // this.pageModel.compList.replaceAll(...data) | ||
| 229 | - // // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 230 | - // // }) | ||
| 231 | - // this.isFirstIn = false; | ||
| 232 | - // Logger.debug(TAG, 'cj111'); | ||
| 233 | - // // } else { | ||
| 234 | - // // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 235 | - // // this.pageModel.viewType = ViewType.EMPTY; | ||
| 236 | - // } | ||
| 237 | - // } | ||
| 238 | - // } | ||
| 239 | - | ||
| 240 | - async getLiveListData(pageInfo: PageInfoBean) { | ||
| 241 | - // Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 242 | - // this.pageModel.pageId = this.pageId; | ||
| 243 | - // this.pageModel.groupId = this.pageId; | ||
| 244 | - // this.pageModel.channelId = this.channelId; | ||
| 245 | - // this.pageModel.currentPage = 1; | ||
| 246 | - // let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | ||
| 247 | - // if (pageInfo == null) { | ||
| 248 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 249 | - // return; | ||
| 250 | - // } | ||
| 251 | - Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id); | ||
| 252 | - // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 253 | - for (const group of pageInfo.groups) { | ||
| 254 | - this.pageDto = await PageViewModel.getLivePageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId, group.groupStrategy | ||
| 255 | - , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) | ||
| 256 | - this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 257 | - if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 258 | - this.pageDto.compList.forEach((comp) => { | ||
| 259 | - if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 260 | - comp.operDataList.push(...this.liveReviewDTO.list) | ||
| 261 | - } | ||
| 262 | - }) | ||
| 263 | - | ||
| 264 | - this.pageModel.viewType = ViewType.LOADED; | ||
| 265 | - this.pageModel.compList.push(...this.pageDto.compList) | ||
| 266 | - if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 267 | - this.pageModel.currentPage++; | ||
| 268 | - this.pageModel.hasMore = true; | ||
| 269 | - } else { | ||
| 270 | - this.pageModel.hasMore = false; | ||
| 271 | - } | ||
| 272 | - // 二次请求,批查互动数据 | ||
| 273 | - PageViewModel.getInteractData(this.pageDto.compList).then((data: CompDTO[]) => { | ||
| 274 | - // 刷新,替换所有数据 | ||
| 275 | - this.pageModel.compList.replaceAll(...data) | ||
| 276 | - this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 277 | - }) | ||
| 278 | - this.isFirstIn = false | ||
| 279 | - } else { | ||
| 280 | - Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 281 | - this.pageModel.viewType = ViewType.EMPTY; | ||
| 282 | - } | ||
| 283 | - } | ||
| 284 | - } | ||
| 285 | - | ||
| 286 | - async getPreviewData() { | ||
| 287 | - this.liveReviewDTO = await PageViewModel.getLiveReviewUrl(this.pageNum, this.pageModel.pageSize) | ||
| 288 | - Logger.debug(TAG, 'aboutToAppear, getPreviewData ' + this.liveReviewDTO.hasNext); | ||
| 289 | - this.getData(); | 129 | + this.pageModel.pageInfo = pageInfo; |
| 130 | + this.pageModel.loadStrategy = 1 | ||
| 131 | + PageHelper.parseGroup(this.pageModel) | ||
| 290 | } | 132 | } |
| 291 | } | 133 | } |
| 292 | 134 |
| 1 | +export class PageUIReqBean { | ||
| 2 | + // 页面数据 | ||
| 3 | + pageId: string = ''; | ||
| 4 | + groupId: string = ''; | ||
| 5 | + channelId: string = ''; | ||
| 6 | + isRecGroup: boolean = false; | ||
| 7 | + /** | ||
| 8 | + * 首次加载:loadStrategy= 1 | ||
| 9 | + * 下拉刷新:loadStrategy= 2 | ||
| 10 | + * 上推刷新:loadStrategy= 3 | ||
| 11 | + */ | ||
| 12 | + loadStrategy: number = 1; | ||
| 13 | + currentPage: number = 1; | ||
| 14 | + pageSize: number = 0; | ||
| 15 | + /** | ||
| 16 | + * 楼层类型: | ||
| 17 | + * 推荐:1 | ||
| 18 | + * 普通:2 | ||
| 19 | + */ | ||
| 20 | + groupStrategy: number = 2; | ||
| 21 | +} |
| @@ -4,6 +4,42 @@ import { Logger } from 'wdKit'; | @@ -4,6 +4,42 @@ import { Logger } from 'wdKit'; | ||
| 4 | const TAG = 'EmptyComponent'; | 4 | const TAG = 'EmptyComponent'; |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | + * WDViewDefaultType 缺省页 | ||
| 8 | + */ | ||
| 9 | +export const enum WDViewDefaultType { | ||
| 10 | + ///默认 | ||
| 11 | + WDViewDefaultType_Default, | ||
| 12 | + ///无网 | ||
| 13 | + WDViewDefaultType_NoNetwork, | ||
| 14 | + ///暂无内容(列表页) | ||
| 15 | + WDViewDefaultType_NoListContent, | ||
| 16 | + ///内容找不到了(内容详情页) | ||
| 17 | + WDViewDefaultType_NoContent, | ||
| 18 | + ///无搜索内容 | ||
| 19 | + WDViewDefaultType_NoSearchResult, | ||
| 20 | + ///无消息内容 | ||
| 21 | + WDViewDefaultType_NoMessage, | ||
| 22 | + ///无收藏内容 | ||
| 23 | + WDViewDefaultType_NoCollection, | ||
| 24 | + ///无历史记录 | ||
| 25 | + WDViewDefaultType_NoHistory, | ||
| 26 | + ///网络失败 | ||
| 27 | + WDViewDefaultType_NetworkFailed, | ||
| 28 | + ///内容获取失败 | ||
| 29 | + WDViewDefaultType_ContentFailed, | ||
| 30 | + ///无预约内容 | ||
| 31 | + WDViewDefaultType_NoBooking, | ||
| 32 | + ///无评论内容 | ||
| 33 | + WDViewDefaultType_NoComment, | ||
| 34 | + ///暂无作品 | ||
| 35 | + WDViewDefaultType_NoCreation, | ||
| 36 | + ///该号主无法访问 | ||
| 37 | + WDViewDefaultType_NoVisitAccount, | ||
| 38 | + ///暂无关注 | ||
| 39 | + WDViewDefaultType_NoFollow | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +/** | ||
| 7 | * 空数据/无数据 | 43 | * 空数据/无数据 |
| 8 | */ | 44 | */ |
| 9 | @Component | 45 | @Component |
| @@ -11,18 +47,19 @@ export struct EmptyComponent { | @@ -11,18 +47,19 @@ export struct EmptyComponent { | ||
| 11 | // private emptySize: SizeOptions = {}; | 47 | // private emptySize: SizeOptions = {}; |
| 12 | @State emptyWidth: string | number = CommonConstants.FULL_PARENT; | 48 | @State emptyWidth: string | number = CommonConstants.FULL_PARENT; |
| 13 | @State emptyHeight: string | number = CommonConstants.FULL_PARENT; | 49 | @State emptyHeight: string | number = CommonConstants.FULL_PARENT; |
| 50 | + @State emptyType:number = WDViewDefaultType.WDViewDefaultType_Default | ||
| 14 | /** | 51 | /** |
| 15 | * The empty image width percentage setting. | 52 | * The empty image width percentage setting. |
| 16 | */ | 53 | */ |
| 17 | - readonly EMPTY_IMAGE_WIDTH: string = '50%'; | 54 | + readonly EMPTY_IMAGE_WIDTH: string = '15%'; |
| 18 | /** | 55 | /** |
| 19 | * The empty image height percentage setting. | 56 | * The empty image height percentage setting. |
| 20 | */ | 57 | */ |
| 21 | - readonly EMPTY_IMAGE_HEIGHT: string = '30%'; | 58 | + readonly EMPTY_IMAGE_HEIGHT: string = '15%'; |
| 22 | /** | 59 | /** |
| 23 | * The empty data text component margin top. | 60 | * The empty data text component margin top. |
| 24 | */ | 61 | */ |
| 25 | - readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '2%'; | 62 | + readonly EMPTY_TIP_TEXT_MARGIN_TOP: string = '10'; |
| 26 | /** | 63 | /** |
| 27 | * The empty data text opacity. | 64 | * The empty data text opacity. |
| 28 | */ | 65 | */ |
| @@ -38,11 +75,11 @@ export struct EmptyComponent { | @@ -38,11 +75,11 @@ export struct EmptyComponent { | ||
| 38 | @Builder | 75 | @Builder |
| 39 | noProgrammeData() { | 76 | noProgrammeData() { |
| 40 | Column() { | 77 | Column() { |
| 41 | - // Image($r('app.media.icon_no_content')) | ||
| 42 | - // .width(this.EMPTY_IMAGE_WIDTH) | ||
| 43 | - // .height(this.EMPTY_IMAGE_HEIGHT) | ||
| 44 | - // .objectFit(ImageFit.Contain) | ||
| 45 | - // // .border({ width: 1, color: Color.Red, radius: 6 }) | 78 | + Image(this.buildNoDataTipImage()) |
| 79 | + .width('this.EMPTY_IMAGE_WIDTH') | ||
| 80 | + .height(this.EMPTY_IMAGE_HEIGHT) | ||
| 81 | + .objectFit(ImageFit.Contain) | ||
| 82 | + // .border({ width: 1, color: Color.Red, radius: 6 }) | ||
| 46 | 83 | ||
| 47 | Text(this.buildNoDataTip()) | 84 | Text(this.buildNoDataTip()) |
| 48 | .fontSize($r('app.float.normal_text_size')) | 85 | .fontSize($r('app.float.normal_text_size')) |
| @@ -59,8 +96,22 @@ export struct EmptyComponent { | @@ -59,8 +96,22 @@ export struct EmptyComponent { | ||
| 59 | .height(this.emptyHeight) | 96 | .height(this.emptyHeight) |
| 60 | } | 97 | } |
| 61 | 98 | ||
| 62 | - buildNoDataTip(): Resource | string { | 99 | + buildNoDataTip(): string { |
| 63 | Logger.info(TAG, "buildNoDataTip"); | 100 | Logger.info(TAG, "buildNoDataTip"); |
| 64 | - return $r('app.string.load_net_data_none') | 101 | + let contentString: string = '暂无内容' |
| 102 | + if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoCollection) { | ||
| 103 | + contentString = '暂无收藏' | ||
| 104 | + } | ||
| 105 | + return contentString | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + | ||
| 109 | + buildNoDataTipImage(): Resource | string { | ||
| 110 | + Logger.info(TAG, "buildNoDataTip"); | ||
| 111 | + let imageString: Resource | string = $r('app.media.icon_no_content') | ||
| 112 | + if (this.emptyType === WDViewDefaultType.WDViewDefaultType_NoCollection) { | ||
| 113 | + imageString = $r('app.media.icon_no_collection') | ||
| 114 | + } | ||
| 115 | + return imageString | ||
| 65 | } | 116 | } |
| 66 | } | 117 | } |
| 1 | // 视频直播横划卡16:9 | 1 | // 视频直播横划卡16:9 |
| 2 | -import { LiveVideoTypeComponent } from './LiveVideoTypeComponent' | ||
| 3 | import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent' | 2 | import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent' |
| 4 | import { Action, CompDTO, ContentDTO, Params } from 'wdBean' | 3 | import { Action, CompDTO, ContentDTO, Params } from 'wdBean' |
| 5 | import { CommonConstants } from 'wdConstant' | 4 | import { CommonConstants } from 'wdConstant' |
| 6 | import { WDRouterRule } from 'wdRouter/Index' | 5 | import { WDRouterRule } from 'wdRouter/Index' |
| 7 | - | 6 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 8 | @Component | 7 | @Component |
| 9 | export struct LiveHorizontalCardComponent { | 8 | export struct LiveHorizontalCardComponent { |
| 10 | @State compDTO: CompDTO = {} as CompDTO | 9 | @State compDTO: CompDTO = {} as CompDTO |
| @@ -60,19 +59,9 @@ export struct LiveHorizontalCardComponent { | @@ -60,19 +59,9 @@ export struct LiveHorizontalCardComponent { | ||
| 60 | .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | 59 | .width(this.compDTO.operDataList.length == 2 ? 210 : 150) |
| 61 | .borderRadius(4) | 60 | .borderRadius(4) |
| 62 | .objectFit(ImageFit.Cover) | 61 | .objectFit(ImageFit.Cover) |
| 63 | - if (item.objectType === '2' && item.liveInfo && item.liveInfo.liveState === 'running') { | ||
| 64 | - LiveVideoTypeComponent({ nType: 0, name: '直播中' }) | ||
| 65 | - .padding({ | ||
| 66 | - bottom: 4, | ||
| 67 | - right: 4 | ||
| 68 | - }) | ||
| 69 | - } else if (item.objectType === '1' && item.videoInfo) { | ||
| 70 | - LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration + "" }) | ||
| 71 | - .padding({ | ||
| 72 | - bottom: 4, | ||
| 73 | - right: 4 | ||
| 74 | - }) | ||
| 75 | - } | 62 | + CardMediaInfo({ |
| 63 | + contentDTO: item | ||
| 64 | + }) | ||
| 76 | } | 65 | } |
| 77 | 66 | ||
| 78 | Text(item.newsTitle) | 67 | Text(item.newsTitle) |
| 1 | // 视频直播横划卡16:9/1个 | 1 | // 视频直播横划卡16:9/1个 |
| 2 | import { CommonConstants } from 'wdConstant' | 2 | import { CommonConstants } from 'wdConstant' |
| 3 | import { ContentDTO } from 'wdBean' | 3 | import { ContentDTO } from 'wdBean' |
| 4 | -import { LiveVideoTypeComponent } from './LiveVideoTypeComponent' | ||
| 5 | - | 4 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 6 | @Component | 5 | @Component |
| 7 | export struct LiveHorizontalCardForOneComponent { | 6 | export struct LiveHorizontalCardForOneComponent { |
| 8 | @State contentDTO: ContentDTO = {} as ContentDTO | 7 | @State contentDTO: ContentDTO = {} as ContentDTO |
| @@ -15,21 +14,9 @@ export struct LiveHorizontalCardForOneComponent { | @@ -15,21 +14,9 @@ export struct LiveHorizontalCardForOneComponent { | ||
| 15 | .width(CommonConstants.FULL_WIDTH) | 14 | .width(CommonConstants.FULL_WIDTH) |
| 16 | .borderRadius(4) | 15 | .borderRadius(4) |
| 17 | .objectFit(ImageFit.Cover) | 16 | .objectFit(ImageFit.Cover) |
| 18 | - if (this.contentDTO.objectType === '2' | ||
| 19 | - && this.contentDTO.liveInfo | ||
| 20 | - && this.contentDTO.liveInfo.liveState === 'running') { | ||
| 21 | - LiveVideoTypeComponent({ nType: 0, name: '直播中' }) | ||
| 22 | - .padding({ | ||
| 23 | - bottom: 2, | ||
| 24 | - right: 2 | ||
| 25 | - }) | ||
| 26 | - } else if (this.contentDTO.objectType === '1' && this.contentDTO.videoInfo) { | ||
| 27 | - LiveVideoTypeComponent({ nType: 1, name: this.contentDTO.videoInfo.videoDuration + '' ?? '00:00' }) | ||
| 28 | - .padding({ | ||
| 29 | - bottom: 2, | ||
| 30 | - right: 2 | ||
| 31 | - }) | ||
| 32 | - } | 17 | + CardMediaInfo({ |
| 18 | + contentDTO: this.contentDTO | ||
| 19 | + }) | ||
| 33 | } | 20 | } |
| 34 | 21 | ||
| 35 | Text(this.contentDTO.newsTitle) | 22 | Text(this.contentDTO.newsTitle) |
| 1 | // 视频直播直播预约 | 1 | // 视频直播直播预约 |
| 2 | -import { LiveVideoTypeComponent } from './LiveVideoTypeComponent' | ||
| 3 | import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent' | 2 | import { LiveHorizontalCardForOneComponent } from './LiveHorizontalCardForOneComponent' |
| 4 | import { CompDTO, ContentDTO } from 'wdBean' | 3 | import { CompDTO, ContentDTO } from 'wdBean' |
| 5 | import { CommonConstants } from 'wdConstant' | 4 | import { CommonConstants } from 'wdConstant' |
| 6 | import { StringUtils } from 'wdKit/Index' | 5 | import { StringUtils } from 'wdKit/Index' |
| 7 | - | 6 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' |
| 8 | @Component | 7 | @Component |
| 9 | export struct LiveHorizontalReservationComponent { | 8 | export struct LiveHorizontalReservationComponent { |
| 10 | @State compDTO: CompDTO = {} as CompDTO | 9 | @State compDTO: CompDTO = {} as CompDTO |
| @@ -51,19 +50,9 @@ export struct LiveHorizontalReservationComponent { | @@ -51,19 +50,9 @@ export struct LiveHorizontalReservationComponent { | ||
| 51 | .width(this.compDTO.operDataList.length == 2 ? 210 : 150) | 50 | .width(this.compDTO.operDataList.length == 2 ? 210 : 150) |
| 52 | .borderRadius(4) | 51 | .borderRadius(4) |
| 53 | .objectFit(ImageFit.Cover) | 52 | .objectFit(ImageFit.Cover) |
| 54 | - if (item.objectType === '2' && item.liveInfo && item.liveInfo.liveState === 'running') { | ||
| 55 | - LiveVideoTypeComponent({ nType: 0, name: '直播中' }) | ||
| 56 | - .padding({ | ||
| 57 | - bottom: 4, | ||
| 58 | - right: 4 | ||
| 59 | - }) | ||
| 60 | - } else if (item.objectType === '1' && item.videoInfo) { | ||
| 61 | - LiveVideoTypeComponent({ nType: 1, name: item.videoInfo.videoDuration + "" }) | ||
| 62 | - .padding({ | ||
| 63 | - bottom: 4, | ||
| 64 | - right: 4 | ||
| 65 | - }) | ||
| 66 | - } | 53 | + CardMediaInfo({ |
| 54 | + contentDTO: item | ||
| 55 | + }) | ||
| 67 | } | 56 | } |
| 68 | 57 | ||
| 69 | Text(item.newsTitle) | 58 | Text(item.newsTitle) |
| @@ -23,6 +23,7 @@ import { | @@ -23,6 +23,7 @@ import { | ||
| 23 | postInteractAccentionOperateParams, | 23 | postInteractAccentionOperateParams, |
| 24 | postRecommendListParams | 24 | postRecommendListParams |
| 25 | } from 'wdBean'; | 25 | } from 'wdBean'; |
| 26 | +import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | ||
| 26 | 27 | ||
| 27 | const TAG = 'HttpRequest'; | 28 | const TAG = 'HttpRequest'; |
| 28 | 29 | ||
| @@ -46,31 +47,70 @@ export class PageRepository { | @@ -46,31 +47,70 @@ export class PageRepository { | ||
| 46 | return url; | 47 | return url; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | - static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | ||
| 50 | - let url = HttpUrlUtils.getHost(); | ||
| 51 | - if (1 == groupStrategy) { | ||
| 52 | - //推荐 | ||
| 53 | - url = url + HttpUrlUtils.COMP_REC_PATH; | 50 | + static getCompInfoUrl(pageBean: PageUIReqBean) { |
| 51 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_PATH; | ||
| 52 | + // first_load、pull_down、push_up | ||
| 53 | + let loadStrategy = '' | ||
| 54 | + if (pageBean.loadStrategy == 2) { | ||
| 55 | + loadStrategy = 'pull_down' | ||
| 56 | + } else if (pageBean.loadStrategy == 3) { | ||
| 57 | + loadStrategy = 'push_up' | ||
| 54 | } else { | 58 | } else { |
| 55 | - //非推荐 | ||
| 56 | - url = url + HttpUrlUtils.COMP_PATH; | 59 | + loadStrategy = 'first_load' |
| 57 | } | 60 | } |
| 58 | - // TODO 暂定只请求第一页,后续对接分页加载,参数再调整 first_load? | ||
| 59 | - url = url + "?channelStrategy=2&loadStrategy=first_load" | 61 | + url = url + "?channelStrategy=" + pageBean.groupStrategy |
| 62 | + + "&loadStrategy=" + loadStrategy | ||
| 60 | + "&districtCode=" + HttpUrlUtils.getDistrictCode() | 63 | + "&districtCode=" + HttpUrlUtils.getDistrictCode() |
| 61 | + "&provinceCode=" + HttpUrlUtils.getProvinceCode() | 64 | + "&provinceCode=" + HttpUrlUtils.getProvinceCode() |
| 62 | + "&cityCode=" + HttpUrlUtils.getCityCode() | 65 | + "&cityCode=" + HttpUrlUtils.getCityCode() |
| 63 | + "&refreshTime=" + DateTimeUtils.getTimeStamp() | 66 | + "&refreshTime=" + DateTimeUtils.getTimeStamp() |
| 64 | - + "&pageId=" + pageId | ||
| 65 | - + "&groupId=" + groupId | ||
| 66 | - + "&channelId=" + channelId | ||
| 67 | - + "&pageSize=" + pageSize | ||
| 68 | - + "&pageNum=" + currentPage; | 67 | + + "&pageId=" + pageBean.pageId |
| 68 | + + "&groupId=" + pageBean.groupId | ||
| 69 | + + "&channelId=" + pageBean.channelId | ||
| 70 | + + "&pageSize=" + pageBean.pageSize | ||
| 71 | + + "&pageNum=" + pageBean.currentPage; | ||
| 72 | + // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | ||
| 73 | + Logger.info(TAG, "getCompInfoUrl url = " + url) | ||
| 74 | + return url; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + static getRecCompInfoUrl(pageBean: PageUIReqBean) { | ||
| 78 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMP_REC_PATH; | ||
| 79 | + /** | ||
| 80 | + * 首次加载:loadStrategy= first_load | ||
| 81 | + * 上推刷新:loadStrategy= push_up | ||
| 82 | + * 下拉刷新:loadStrategy= pull_down | ||
| 83 | + */ | ||
| 84 | + let loadStrategy = '' | ||
| 85 | + if (pageBean.loadStrategy == 2) { | ||
| 86 | + loadStrategy = 'pull_down' | ||
| 87 | + } else if (pageBean.loadStrategy == 3) { | ||
| 88 | + loadStrategy = 'push_up' | ||
| 89 | + } else { | ||
| 90 | + loadStrategy = 'first_load' | ||
| 91 | + } | ||
| 92 | + url = url + "?channelStrategy=" + pageBean.groupStrategy | ||
| 93 | + + "&loadStrategy=" + loadStrategy | ||
| 94 | + + "&districtCode=" + HttpUrlUtils.getDistrictCode() | ||
| 95 | + + "&provinceCode=" + HttpUrlUtils.getProvinceCode() | ||
| 96 | + + "&cityCode=" + HttpUrlUtils.getCityCode() | ||
| 97 | + + "&refreshTime=" + DateTimeUtils.getTimeStamp() | ||
| 98 | + + "&pageId=" + pageBean.pageId | ||
| 99 | + + "&groupId=" + pageBean.groupId | ||
| 100 | + + "&channelId=" + pageBean.channelId | ||
| 101 | + + "&pageSize=" + pageBean.pageSize | ||
| 102 | + + "&pageNum=" + pageBean.currentPage; | ||
| 69 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); | 103 | // Logger.debug("TAG", 'getCompInfoUrl url: '+url); |
| 70 | Logger.info(TAG, "getCompInfoUrl url = " + url) | 104 | Logger.info(TAG, "getCompInfoUrl url = " + url) |
| 71 | return url; | 105 | return url; |
| 72 | } | 106 | } |
| 73 | 107 | ||
| 108 | + static getLiveReviewUrl(pageNum: number = 1, pageSize: number = 20) { | ||
| 109 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_REVIEW_PATH + "?pageNum=" + pageNum + "&pageSize=" + pageSize; | ||
| 110 | + Logger.info(TAG, "getLiveReviewUrl url = " + url) | ||
| 111 | + return url; | ||
| 112 | + } | ||
| 113 | + | ||
| 74 | static getDetailInfoUrl(relId: string, contentId: string, relType: string) { | 114 | static getDetailInfoUrl(relId: string, contentId: string, relType: string) { |
| 75 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH; | 115 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.DETAIL_PATH; |
| 76 | url = url + "?relId=" + relId | 116 | url = url + "?relId=" + relId |
| @@ -155,12 +195,6 @@ export class PageRepository { | @@ -155,12 +195,6 @@ export class PageRepository { | ||
| 155 | return url; | 195 | return url; |
| 156 | } | 196 | } |
| 157 | 197 | ||
| 158 | - static getLiveReviewUrl(pageNum: number = 1, pageSize: number = 20) { | ||
| 159 | - let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_REVIEW_PATH + "?pageNum=" + pageNum + "&pageSize=" + pageSize; | ||
| 160 | - Logger.info(TAG, "getLiveReviewUrl url = " + url) | ||
| 161 | - return url; | ||
| 162 | - } | ||
| 163 | - | ||
| 164 | static fetchNavigationDataApi() { | 198 | static fetchNavigationDataApi() { |
| 165 | let url = PageRepository.getBottomNavGroupUrl(); | 199 | let url = PageRepository.getBottomNavGroupUrl(); |
| 166 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 200 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| @@ -194,14 +228,14 @@ export class PageRepository { | @@ -194,14 +228,14 @@ export class PageRepository { | ||
| 194 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) | 228 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) |
| 195 | }; | 229 | }; |
| 196 | 230 | ||
| 197 | - static fetchLivePageData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | ||
| 198 | - let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | 231 | + static fetchCompData(pageBean: PageUIReqBean) { |
| 232 | + let url = PageRepository.getCompInfoUrl(pageBean) | ||
| 199 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 233 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 200 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 234 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 201 | }; | 235 | }; |
| 202 | 236 | ||
| 203 | - static fetchCompData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | ||
| 204 | - let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | 237 | + static fetchRecCompData(pageBean: PageUIReqBean) { |
| 238 | + let url = PageRepository.getRecCompInfoUrl(pageBean) | ||
| 205 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 239 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 206 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 240 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 207 | }; | 241 | }; |
| @@ -5,6 +5,7 @@ import { PageDTO, CompDTO } from 'wdBean'; | @@ -5,6 +5,7 @@ import { PageDTO, CompDTO } from 'wdBean'; | ||
| 5 | import PageModel from '../viewmodel/PageModel'; | 5 | import PageModel from '../viewmodel/PageModel'; |
| 6 | import PageViewModel from '../viewmodel/PageViewModel'; | 6 | import PageViewModel from '../viewmodel/PageViewModel'; |
| 7 | import { DateTimeUtils } from 'wdKit'; | 7 | import { DateTimeUtils } from 'wdKit'; |
| 8 | +import PageHelper from '../viewmodel/PageHelper'; | ||
| 8 | 9 | ||
| 9 | export function listTouchEvent(pageModel: PageModel, event: TouchEvent) { | 10 | export function listTouchEvent(pageModel: PageModel, event: TouchEvent) { |
| 10 | switch (event.type) { | 11 | switch (event.type) { |
| @@ -71,31 +72,32 @@ export function touchUpPullRefresh(pageModel: PageModel) { | @@ -71,31 +72,32 @@ export function touchUpPullRefresh(pageModel: PageModel) { | ||
| 71 | pageModel.currentPage = 1; | 72 | pageModel.currentPage = 1; |
| 72 | setTimeout(() => { | 73 | setTimeout(() => { |
| 73 | let self: PageModel = pageModel; | 74 | let self: PageModel = pageModel; |
| 74 | - PageViewModel.getPageData(self, getContext()) | ||
| 75 | - .then((data: PageDTO) => { | ||
| 76 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 77 | - if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 78 | - self.hasMore = false; | ||
| 79 | - } else { | ||
| 80 | - if (data.compList.length == self.pageSize) { | ||
| 81 | - self.currentPage++; | ||
| 82 | - self.hasMore = true; | ||
| 83 | - } else { | ||
| 84 | - self.hasMore = false; | ||
| 85 | - } | ||
| 86 | - // 刷新,替换所有数据 | ||
| 87 | - self.compList.replaceAll(...data.compList) | ||
| 88 | - PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 89 | - // 刷新,替换所有数据 | ||
| 90 | - self.compList.replaceAll(...data) | ||
| 91 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 92 | - }) | ||
| 93 | - } | ||
| 94 | - closeRefresh(self, true); | ||
| 95 | - }).catch((err: string | Resource) => { | ||
| 96 | - promptAction.showToast({ message: err }); | ||
| 97 | - closeRefresh(self, false); | ||
| 98 | - }); | 75 | + PageHelper.refreshUI(self) |
| 76 | + // PageViewModel.getPageData(self.bizCopy(2)) | ||
| 77 | + // .then((data: PageDTO) => { | ||
| 78 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 79 | + // if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 80 | + // self.hasMore = false; | ||
| 81 | + // } else { | ||
| 82 | + // if (data.compList.length == self.pageSize) { | ||
| 83 | + // self.currentPage++; | ||
| 84 | + // self.hasMore = true; | ||
| 85 | + // } else { | ||
| 86 | + // self.hasMore = false; | ||
| 87 | + // } | ||
| 88 | + // // 刷新,替换所有数据 | ||
| 89 | + // self.compList.replaceAll(...data.compList) | ||
| 90 | + // PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 91 | + // // 刷新,替换所有数据 | ||
| 92 | + // self.compList.replaceAll(...data) | ||
| 93 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 94 | + // }) | ||
| 95 | + // } | ||
| 96 | + // closeRefresh(self, true); | ||
| 97 | + // }).catch((err: string | Resource) => { | ||
| 98 | + // promptAction.showToast({ message: err }); | ||
| 99 | + // closeRefresh(self, false); | ||
| 100 | + // }); | ||
| 99 | }, Const.DELAY_TIME); | 101 | }, Const.DELAY_TIME); |
| 100 | } else { | 102 | } else { |
| 101 | closeRefresh(pageModel, false); | 103 | closeRefresh(pageModel, false); |
| @@ -2,8 +2,9 @@ import promptAction from '@ohos.promptAction'; | @@ -2,8 +2,9 @@ import promptAction from '@ohos.promptAction'; | ||
| 2 | import PageModel from '../viewmodel/PageModel'; | 2 | import PageModel from '../viewmodel/PageModel'; |
| 3 | import { RefreshConstants as Const } from './RefreshConstants'; | 3 | import { RefreshConstants as Const } from './RefreshConstants'; |
| 4 | import PageViewModel from '../viewmodel/PageViewModel'; | 4 | import PageViewModel from '../viewmodel/PageViewModel'; |
| 5 | -import { PageDTO,CompDTO } from 'wdBean'; | 5 | +import { PageDTO, CompDTO } from 'wdBean'; |
| 6 | import { DateTimeUtils } from 'wdKit'; | 6 | import { DateTimeUtils } from 'wdKit'; |
| 7 | +import PageHelper from '../viewmodel/PageHelper'; | ||
| 7 | 8 | ||
| 8 | export function touchMoveLoadMore(model: PageModel, event: TouchEvent) { | 9 | export function touchMoveLoadMore(model: PageModel, event: TouchEvent) { |
| 9 | // list size +1 | 10 | // list size +1 |
| @@ -28,29 +29,30 @@ export function touchUpLoadMore(model: PageModel) { | @@ -28,29 +29,30 @@ export function touchUpLoadMore(model: PageModel) { | ||
| 28 | self.isLoading = true; | 29 | self.isLoading = true; |
| 29 | setTimeout(() => { | 30 | setTimeout(() => { |
| 30 | closeLoadMore(model); | 31 | closeLoadMore(model); |
| 31 | - PageViewModel.getPageData(self, getContext()) | ||
| 32 | - .then((data: PageDTO) => { | ||
| 33 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 34 | - if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 35 | - self.hasMore = false; | ||
| 36 | - } else { | ||
| 37 | - if (data.compList.length == self.pageSize) { | ||
| 38 | - self.currentPage++; | ||
| 39 | - self.hasMore = true; | ||
| 40 | - } else { | ||
| 41 | - self.hasMore = false; | ||
| 42 | - } | ||
| 43 | - let sizeBefore:number = self.compList.size(); | ||
| 44 | - self.compList.push(...data.compList) | ||
| 45 | - PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 46 | - // 刷新,替换所有数据 | ||
| 47 | - self.compList.updateItems(sizeBefore, data) | ||
| 48 | - self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 49 | - }) | ||
| 50 | - } | ||
| 51 | - }).catch((err: string | Resource) => { | ||
| 52 | - promptAction.showToast({ message: err }); | ||
| 53 | - }) | 32 | + PageHelper.loadMore(self) |
| 33 | + // PageViewModel.getPageData(self.bizCopy()) | ||
| 34 | + // .then((data: PageDTO) => { | ||
| 35 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 36 | + // if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 37 | + // self.hasMore = false; | ||
| 38 | + // } else { | ||
| 39 | + // if (data.compList.length == self.pageSize) { | ||
| 40 | + // self.currentPage++; | ||
| 41 | + // self.hasMore = true; | ||
| 42 | + // } else { | ||
| 43 | + // self.hasMore = false; | ||
| 44 | + // } | ||
| 45 | + // let sizeBefore: number = self.compList.size(); | ||
| 46 | + // self.compList.push(...data.compList) | ||
| 47 | + // PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 48 | + // // 刷新,替换所有数据 | ||
| 49 | + // self.compList.updateItems(sizeBefore, data) | ||
| 50 | + // self.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 51 | + // }) | ||
| 52 | + // } | ||
| 53 | + // }).catch((err: string | Resource) => { | ||
| 54 | + // promptAction.showToast({ message: err }); | ||
| 55 | + // }) | ||
| 54 | }, Const.DELAY_TIME); | 56 | }, Const.DELAY_TIME); |
| 55 | } else { | 57 | } else { |
| 56 | closeLoadMore(self); | 58 | closeLoadMore(self); |
| 1 | +import { PageDTO, CompDTO, PageInfoDTO } from 'wdBean'; | ||
| 2 | +import { ViewType } from 'wdConstant/Index'; | ||
| 3 | +import { DateTimeUtils, Logger } from 'wdKit'; | ||
| 4 | +import { closeRefresh } from '../utils/PullDownRefresh'; | ||
| 5 | +import PageModel from './PageModel'; | ||
| 6 | +import PageViewModel from './PageViewModel'; | ||
| 7 | +import { promptAction } from '@kit.ArkUI'; | ||
| 8 | + | ||
| 9 | +const TAG = 'PageHelper'; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 处理返回后的数据 | ||
| 13 | + * @deprecated | ||
| 14 | + */ | ||
| 15 | +export class PageHelper { | ||
| 16 | + async refreshUI(pageModel: PageModel) { | ||
| 17 | + pageModel.loadStrategy = 2 | ||
| 18 | + this.parseGroup(pageModel) | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + async loadMore(pageModel: PageModel) { | ||
| 22 | + pageModel.loadStrategy = 3 | ||
| 23 | + // 暂只支持comp分页加载,节目分页加载的得完善框架(如直播回看节目数据分页) | ||
| 24 | + this.compLoadMore(pageModel) | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + async parseGroup(pageModel: PageModel) { | ||
| 28 | + let pageInfo: PageInfoDTO = pageModel.pageInfo | ||
| 29 | + pageModel.groupList = [] | ||
| 30 | + pageModel.groupList.push(...pageInfo.groups) | ||
| 31 | + for (const group of pageInfo.groups) { | ||
| 32 | + pageModel.isRecGroup = group.groupStrategy === 1; | ||
| 33 | + pageModel.groupId = group.id; | ||
| 34 | + if (pageModel.isRecGroup) { | ||
| 35 | + pageModel.pageSize = 10 | ||
| 36 | + } else { | ||
| 37 | + pageModel.pageSize = 20 | ||
| 38 | + } | ||
| 39 | + pageModel.groupData = group | ||
| 40 | + // await,确保groups接口顺序执行 | ||
| 41 | + let pageDto = await PageViewModel.getPageData(pageModel.bizCopy()) | ||
| 42 | + let index = pageInfo.groups.indexOf(group) | ||
| 43 | + if (index == 0) { | ||
| 44 | + // 清空comp列表 | ||
| 45 | + pageModel.compList.clear() | ||
| 46 | + } | ||
| 47 | + this.getGroupData(pageModel, pageDto, index == pageInfo.groups.length - 1) | ||
| 48 | + } | ||
| 49 | + if (pageModel.compList.isEmpty()) { | ||
| 50 | + // 没数据,展示空页面 | ||
| 51 | + Logger.debug(TAG, 'aboutToAppear, data response page ' + pageModel.pageId + ', comp list is empty.'); | ||
| 52 | + pageModel.viewType = ViewType.EMPTY; | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + private async getGroupData(pageModel: PageModel, pageDto: PageDTO, isLastGroup: boolean) { | ||
| 57 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 58 | + if (pageDto && pageDto.compList && pageDto.compList.length > 0) { | ||
| 59 | + pageModel.viewType = ViewType.LOADED; | ||
| 60 | + let sizeBefore: number = pageModel.compList.size(); | ||
| 61 | + pageModel.compList.push(...pageDto.compList) | ||
| 62 | + if (pageDto.compList.length === pageModel.pageSize) { | ||
| 63 | + pageModel.currentPage++; | ||
| 64 | + pageModel.hasMore = true; | ||
| 65 | + } else { | ||
| 66 | + pageModel.hasMore = false; | ||
| 67 | + } | ||
| 68 | + // 二次请求,批查互动数据 | ||
| 69 | + PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 70 | + // 刷新,替换所有数据 | ||
| 71 | + // pageModel.compList.replaceAll(...data) | ||
| 72 | + pageModel.compList.updateItems(sizeBefore, data) | ||
| 73 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 74 | + }) | ||
| 75 | + // TODO 待优化,解决content级别的展现加载 | ||
| 76 | + if (isLastGroup) { | ||
| 77 | + closeRefresh(pageModel, true); | ||
| 78 | + // // 最后一个楼层,特殊处理 | ||
| 79 | + // // 检测楼层最后一个组件业务数据是否需要通过访问接口获取 | ||
| 80 | + // let comp: CompDTO = pageDto.compList[pageDto.compList.length - 1] | ||
| 81 | + // let compSize = CollectionUtils.getListSize(comp.operDataList) | ||
| 82 | + // // 直播回放,需要二次请求数据 | ||
| 83 | + // if (compSize <= 0 && comp.dataSourceType == 'LIVE_END') { | ||
| 84 | + // let liveReviewDTO = await PageViewModel.getLiveReviewUrl(pageModel.currentPage, pageModel.pageSize) | ||
| 85 | + // // content数据回来,塞给comp | ||
| 86 | + // comp.operDataList.push(...liveReviewDTO.list) | ||
| 87 | + // } | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + /** | ||
| 93 | + * 获取直播回看数据 | ||
| 94 | + */ | ||
| 95 | + private async getLiveEnd(pageModel: PageModel) { | ||
| 96 | + let liveReviewDTO = await PageViewModel.getLiveReviewUrl(pageModel.currentPage, pageModel.pageSize) | ||
| 97 | + Logger.debug(TAG, 'aboutToAppear, getPreviewData ' + liveReviewDTO.hasNext); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * comp加载更多,分页加载 | ||
| 102 | + */ | ||
| 103 | + private compLoadMore(pageModel: PageModel) { | ||
| 104 | + PageViewModel.getPageData(pageModel.bizCopy()) | ||
| 105 | + .then((data: PageDTO) => { | ||
| 106 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 107 | + if (data == null || data.compList == null || data.compList.length == 0) { | ||
| 108 | + pageModel.hasMore = false; | ||
| 109 | + } else { | ||
| 110 | + if (data.compList.length == pageModel.pageSize) { | ||
| 111 | + pageModel.currentPage++; | ||
| 112 | + pageModel.hasMore = true; | ||
| 113 | + } else { | ||
| 114 | + pageModel.hasMore = false; | ||
| 115 | + } | ||
| 116 | + let sizeBefore: number = pageModel.compList.size(); | ||
| 117 | + pageModel.compList.push(...data.compList) | ||
| 118 | + PageViewModel.getInteractData(data.compList).then((data: CompDTO[]) => { | ||
| 119 | + // 刷新,替换所有数据 | ||
| 120 | + pageModel.compList.updateItems(sizeBefore, data) | ||
| 121 | + pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 122 | + }) | ||
| 123 | + } | ||
| 124 | + }).catch((err: string | Resource) => { | ||
| 125 | + promptAction.showToast({ message: err }); | ||
| 126 | + }) | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * 节目数据分页加载 | ||
| 131 | + * TODO 待完善框架 | ||
| 132 | + */ | ||
| 133 | + private contentLoadMore() { | ||
| 134 | + | ||
| 135 | + } | ||
| 136 | +} | ||
| 137 | + | ||
| 138 | + | ||
| 139 | +let pageHelper = new PageHelper(); | ||
| 140 | + | ||
| 141 | +export default pageHelper as PageHelper; |
| 1 | -import { CompDTO } from 'wdBean'; | 1 | +import { CompDTO, GroupDTO } from 'wdBean'; |
| 2 | import { LazyDataSource } from 'wdKit'; | 2 | import { LazyDataSource } from 'wdKit'; |
| 3 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; | 3 | import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; |
| 4 | import { RefreshConstants as Const } from '../utils/RefreshConstants'; | 4 | import { RefreshConstants as Const } from '../utils/RefreshConstants'; |
| 5 | +import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | ||
| 6 | +import { GroupInfoDTO, PageInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | ||
| 5 | 7 | ||
| 8 | +/** | ||
| 9 | + * 页面下拉刷新、上拉加载数据bean。 | ||
| 10 | + * TODO 将业务数据拆出去 | ||
| 11 | + */ | ||
| 6 | export default class PageModel { | 12 | export default class PageModel { |
| 7 | // 页面数据 | 13 | // 页面数据 |
| 8 | pageId: string = ""; | 14 | pageId: string = ""; |
| 9 | groupId: string = ""; | 15 | groupId: string = ""; |
| 10 | channelId: string = ""; | 16 | channelId: string = ""; |
| 11 | isRecGroup: boolean = false; | 17 | isRecGroup: boolean = false; |
| 18 | + pageInfo: PageInfoDTO = {} as PageInfoDTO | ||
| 19 | + groupList: GroupInfoDTO[] = []; | ||
| 20 | + // 当前请求数据的group | ||
| 21 | + groupData: GroupInfoDTO = {} as GroupInfoDTO; | ||
| 12 | compList: LazyDataSource<CompDTO> = new LazyDataSource(); | 22 | compList: LazyDataSource<CompDTO> = new LazyDataSource(); |
| 13 | - // 页面状态,刷新、加载更多等 | 23 | + // 页面状态,刷新、加载更多等,1-首次、2-下拉、3上拉 |
| 24 | + loadStrategy: number = 1; | ||
| 14 | currentPage: number = 1; | 25 | currentPage: number = 1; |
| 15 | pageSize: number = Const.PAGE_SIZE; | 26 | pageSize: number = Const.PAGE_SIZE; |
| 16 | pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text'); | 27 | pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text'); |
| @@ -35,5 +46,20 @@ export default class PageModel { | @@ -35,5 +46,20 @@ export default class PageModel { | ||
| 35 | isCanLoadMore: boolean = false; | 46 | isCanLoadMore: boolean = false; |
| 36 | // keyGenerator相关字符串,用于刷新list布局 | 47 | // keyGenerator相关字符串,用于刷新list布局 |
| 37 | timestamp: String = '1'; | 48 | timestamp: String = '1'; |
| 38 | - groupStrategy: number = 0; | ||
| 39 | -} | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * 简单复制业务数据 | ||
| 52 | + */ | ||
| 53 | + bizCopy(): PageUIReqBean { | ||
| 54 | + let page = new PageUIReqBean() | ||
| 55 | + page.pageId = this.pageId | ||
| 56 | + page.groupId = this.groupId | ||
| 57 | + page.channelId = this.channelId | ||
| 58 | + page.isRecGroup = this.isRecGroup | ||
| 59 | + page.currentPage = this.currentPage | ||
| 60 | + page.pageSize = this.pageSize | ||
| 61 | + page.groupStrategy = this.groupData.groupStrategy | ||
| 62 | + page.loadStrategy = this.loadStrategy | ||
| 63 | + return page | ||
| 64 | + } | ||
| 65 | +} |
| @@ -7,14 +7,15 @@ import { | @@ -7,14 +7,15 @@ import { | ||
| 7 | MorningEveningPaperDTO, | 7 | MorningEveningPaperDTO, |
| 8 | NavigationBodyDTO, | 8 | NavigationBodyDTO, |
| 9 | PageDTO, | 9 | PageDTO, |
| 10 | - PageInfoBean | 10 | + PageInfoBean, |
| 11 | + PageInfoDTO | ||
| 11 | } from 'wdBean'; | 12 | } from 'wdBean'; |
| 12 | 13 | ||
| 13 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 14 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 14 | import { ResponseDTO, } from 'wdNetwork'; | 15 | import { ResponseDTO, } from 'wdNetwork'; |
| 16 | +import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | ||
| 15 | import { PageRepository } from '../repository/PageRepository'; | 17 | import { PageRepository } from '../repository/PageRepository'; |
| 16 | import { BaseViewModel } from './BaseViewModel'; | 18 | import { BaseViewModel } from './BaseViewModel'; |
| 17 | -import PageModel from './PageModel'; | ||
| 18 | 19 | ||
| 19 | const TAG = 'PageViewModel'; | 20 | const TAG = 'PageViewModel'; |
| 20 | /** | 21 | /** |
| @@ -141,38 +142,13 @@ export class PageViewModel extends BaseViewModel { | @@ -141,38 +142,13 @@ export class PageViewModel extends BaseViewModel { | ||
| 141 | return compRes.data | 142 | return compRes.data |
| 142 | } | 143 | } |
| 143 | 144 | ||
| 144 | - async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { | 145 | + async getPageData(pageModel: PageUIReqBean): Promise<PageDTO> { |
| 145 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); | 146 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); |
| 146 | - return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.isRecGroup == true ? 1 : 0, pageModel.currentPage, pageModel.pageSize)) | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - async getLivePageData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number | ||
| 150 | - , pageSize: number, context: Context): Promise<PageDTO> { | ||
| 151 | - Logger.debug(TAG, 'getPageData pageId: ' + pageId); | ||
| 152 | - if (mock_switch) { | ||
| 153 | - return this.getPageData1(currentPage, context); | 147 | + if (pageModel.isRecGroup) { |
| 148 | + return this.parseComp(PageRepository.fetchRecCompData(pageModel)) | ||
| 149 | + } else { | ||
| 150 | + return this.parseComp(PageRepository.fetchCompData(pageModel)) | ||
| 154 | } | 151 | } |
| 155 | - return new Promise<PageDTO>((success, error) => { | ||
| 156 | - PageRepository.fetchLivePageData(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 157 | - .then((resDTO: ResponseDTO<PageDTO>) => { | ||
| 158 | - if (!resDTO || !resDTO.data) { | ||
| 159 | - Logger.error(TAG, 'getNavData then resDTO is empty'); | ||
| 160 | - error('resDTO is empty'); | ||
| 161 | - return | ||
| 162 | - } | ||
| 163 | - if (resDTO.code != 0) { | ||
| 164 | - Logger.error(TAG, `getNavData then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 165 | - error('resDTO Response Code is failure'); | ||
| 166 | - return | ||
| 167 | - } | ||
| 168 | - Logger.info(TAG, "getNavData then,resDTO.timestamp:" + resDTO.timestamp); | ||
| 169 | - success(resDTO.data); | ||
| 170 | - }) | ||
| 171 | - .catch((err: Error) => { | ||
| 172 | - Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 173 | - error(err); | ||
| 174 | - }) | ||
| 175 | - }) | ||
| 176 | } | 152 | } |
| 177 | 153 | ||
| 178 | private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { | 154 | private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { |
| @@ -342,6 +318,19 @@ export class PageViewModel extends BaseViewModel { | @@ -342,6 +318,19 @@ export class PageViewModel extends BaseViewModel { | ||
| 342 | return param; | 318 | return param; |
| 343 | } | 319 | } |
| 344 | 320 | ||
| 321 | + async getPageInfo(pageId: string): Promise<PageInfoDTO> { | ||
| 322 | + return new Promise<PageInfoDTO>((success, error) => { | ||
| 323 | + PageRepository.fetchPageData(pageId).then((resDTO: ResponseDTO<PageInfoDTO>) => { | ||
| 324 | + if (this.isRespondsInvalid(resDTO, 'getPageInfo')) { | ||
| 325 | + error("getPageInfo data invalid"); | ||
| 326 | + return | ||
| 327 | + } | ||
| 328 | + Logger.info(TAG, "getPageInfo then,resDTO.timeStamp:" + resDTO.timestamp); | ||
| 329 | + success(resDTO.data as PageInfoDTO); | ||
| 330 | + }); | ||
| 331 | + }); | ||
| 332 | + } | ||
| 333 | + | ||
| 345 | async getLiveReviewUrl(pageNum: number, pageSize: number): Promise<LiveReviewDTO> { | 334 | async getLiveReviewUrl(pageNum: number, pageSize: number): Promise<LiveReviewDTO> { |
| 346 | return new Promise<LiveReviewDTO>((success, error) => { | 335 | return new Promise<LiveReviewDTO>((success, error) => { |
| 347 | Logger.info(TAG, `getLivePreviewUrl pageInfo start`); | 336 | Logger.info(TAG, `getLivePreviewUrl pageInfo start`); |
7.85 KB
sight_harmony/features/wdComponent/src/main/resources/base/media/ic_news_detail_division.webp
0 → 100644
No preview for this file type
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_default_head_mater.png
0 → 100644
7.17 KB
949 Bytes
64.2 KB
54.3 KB
| @@ -12,6 +12,7 @@ | @@ -12,6 +12,7 @@ | ||
| 12 | "wdNetwork": "file:../../commons/wdNetwork", | 12 | "wdNetwork": "file:../../commons/wdNetwork", |
| 13 | "wdKit": "file:../../commons/wdKit", | 13 | "wdKit": "file:../../commons/wdKit", |
| 14 | "wdBean": "file:../../features/wdBean", | 14 | "wdBean": "file:../../features/wdBean", |
| 15 | - "wdConstant": "file:../../commons/wdConstant" | 15 | + "wdConstant": "file:../../commons/wdConstant", |
| 16 | + "wdDetailPlayApi": "file:../../features/wdDetailPlayApi" | ||
| 16 | } | 17 | } |
| 17 | } | 18 | } |
| 1 | -import { LiveDetailsBean } from 'wdBean/Index'; | 1 | +import { Action, LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index'; |
| 2 | import { LiveViewModel } from '../viewModel/LiveViewModel'; | 2 | import { LiveViewModel } from '../viewModel/LiveViewModel'; |
| 3 | import { BottomComponent } from '../widgets/details/BottomComponent'; | 3 | import { BottomComponent } from '../widgets/details/BottomComponent'; |
| 4 | import { TabComponent } from '../widgets/details/TabComponent'; | 4 | import { TabComponent } from '../widgets/details/TabComponent'; |
| 5 | import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet'; | 5 | import { TopPlayComponent } from '../widgets/details/video/TopPlayComponet'; |
| 6 | +import router from '@ohos.router'; | ||
| 6 | 7 | ||
| 7 | @Entry | 8 | @Entry |
| 8 | @Component | 9 | @Component |
| 9 | export struct DetailPlayLivePage { | 10 | export struct DetailPlayLivePage { |
| 10 | TAG: string = 'DetailPlayLivePage'; | 11 | TAG: string = 'DetailPlayLivePage'; |
| 11 | liveViewModel: LiveViewModel = new LiveViewModel() | 12 | liveViewModel: LiveViewModel = new LiveViewModel() |
| 13 | + @State relId: string = '500005302448' | ||
| 14 | + @State contentId: string = '20000016340' | ||
| 15 | + @State relType: string = '1' | ||
| 12 | @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean | 16 | @Provide liveDetailsBean: LiveDetailsBean = {} as LiveDetailsBean |
| 17 | + @Provide liveRoomDataBean: LiveRoomDataBean = {} as LiveRoomDataBean | ||
| 13 | 18 | ||
| 14 | aboutToAppear(): void { | 19 | aboutToAppear(): void { |
| 20 | + //https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/content/zh/c/content/detail?relId=500005302448&relType=1&contentId=20000016340 | ||
| 21 | + let par: Action = router.getParams() as Action; | ||
| 22 | + let params = par?.params; | ||
| 23 | + this.relId = params?.extra?.relId || ''; | ||
| 24 | + this.relType = params?.extra?.relType || ''; | ||
| 25 | + this.contentId = params?.contentID || ''; | ||
| 15 | this.getLiveDetails() | 26 | this.getLiveDetails() |
| 27 | + this.getLiveRoomData() | ||
| 16 | } | 28 | } |
| 17 | 29 | ||
| 18 | build() { | 30 | build() { |
| 19 | Column() { | 31 | Column() { |
| 20 | - TopPlayComponent({playUrl:'http://mlive3.video.weibocdn.com/record/alicdn/5018726527666338/index.m3u8'}) | 32 | + TopPlayComponent() |
| 21 | TabComponent() | 33 | TabComponent() |
| 22 | BottomComponent() | 34 | BottomComponent() |
| 23 | } | 35 | } |
| @@ -30,8 +42,7 @@ export struct DetailPlayLivePage { | @@ -30,8 +42,7 @@ export struct DetailPlayLivePage { | ||
| 30 | } | 42 | } |
| 31 | 43 | ||
| 32 | getLiveDetails() { | 44 | getLiveDetails() { |
| 33 | - this.liveViewModel.getLiveDetails('20000016333', '500005300349', '1')//2024-04-12 15:00:00 | ||
| 34 | - // this.liveViewModel.getLiveDetails('20000016229', '500005272745', '1')//2024-04-03 05:00:00 | 45 | + this.liveViewModel.getLiveDetails(this.contentId, this.relId, this.relType) |
| 35 | .then( | 46 | .then( |
| 36 | (data) => { | 47 | (data) => { |
| 37 | if (data.length > 0) { | 48 | if (data.length > 0) { |
| @@ -43,6 +54,17 @@ export struct DetailPlayLivePage { | @@ -43,6 +54,17 @@ export struct DetailPlayLivePage { | ||
| 43 | }) | 54 | }) |
| 44 | } | 55 | } |
| 45 | 56 | ||
| 57 | + getLiveRoomData() { | ||
| 58 | + this.liveViewModel.getLiveRoomData(this.contentId) | ||
| 59 | + .then( | ||
| 60 | + (data) => { | ||
| 61 | + this.liveRoomDataBean = data | ||
| 62 | + }, | ||
| 63 | + () => { | ||
| 64 | + | ||
| 65 | + }) | ||
| 66 | + } | ||
| 67 | + | ||
| 46 | aboutToDisappear(): void { | 68 | aboutToDisappear(): void { |
| 47 | 69 | ||
| 48 | } | 70 | } |
| 1 | import HashMap from '@ohos.util.HashMap'; | 1 | import HashMap from '@ohos.util.HashMap'; |
| 2 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; | 2 | import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; |
| 3 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; | 3 | import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; |
| 4 | -import { Logger } from 'wdKit'; | ||
| 5 | -import { LiveDetailsBean, LiveRoomBean } from 'wdBean/Index'; | 4 | +import { Logger, ToastUtils } from 'wdKit'; |
| 5 | +import { LiveDetailsBean, LiveRoomBean, LiveRoomDataBean } from 'wdBean/Index'; | ||
| 6 | 6 | ||
| 7 | const TAG = 'LiveModel' | 7 | const TAG = 'LiveModel' |
| 8 | 8 | ||
| @@ -107,5 +107,91 @@ export class LiveModel { | @@ -107,5 +107,91 @@ export class LiveModel { | ||
| 107 | }) | 107 | }) |
| 108 | }) | 108 | }) |
| 109 | } | 109 | } |
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * 获取直播数据 | ||
| 113 | + * @param liveId | ||
| 114 | + * @returns | ||
| 115 | + */ | ||
| 116 | + getLiveRoomData(liveId: string) { | ||
| 117 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 118 | + return new Promise<LiveRoomDataBean>((success, fail) => { | ||
| 119 | + HttpRequest.get<ResponseDTO<LiveRoomDataBean>>( | ||
| 120 | + HttpUrlUtils.getLiveRoomDataUrl() + `?liveId=${liveId}`, | ||
| 121 | + headers).then((data: ResponseDTO<LiveRoomDataBean>) => { | ||
| 122 | + if (!data || !data.data) { | ||
| 123 | + fail("数据为空") | ||
| 124 | + return | ||
| 125 | + } | ||
| 126 | + if (data.code != 0) { | ||
| 127 | + fail(data.message) | ||
| 128 | + return | ||
| 129 | + } | ||
| 130 | + success(data.data) | ||
| 131 | + }, (error: Error) => { | ||
| 132 | + fail(error.message) | ||
| 133 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 134 | + }) | ||
| 135 | + }) | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + /** | ||
| 139 | + * 获取直播预约状态 | ||
| 140 | + * @param relationId | ||
| 141 | + * @param liveId | ||
| 142 | + * @returns | ||
| 143 | + */ | ||
| 144 | + getLiveAppointmentStatus(relationId: string, liveId: string) { | ||
| 145 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 146 | + return new Promise<boolean>((success, fail) => { | ||
| 147 | + HttpRequest.get<ResponseDTO<boolean>>( | ||
| 148 | + HttpUrlUtils.getLiveAppointmentStatusUrl() + `?relationId=${relationId}&liveId=${liveId}`, | ||
| 149 | + headers).then((data: ResponseDTO<boolean>) => { | ||
| 150 | + if (!data || !data.data) { | ||
| 151 | + fail("数据为空") | ||
| 152 | + return | ||
| 153 | + } | ||
| 154 | + if (data.code != 0) { | ||
| 155 | + fail(data.message) | ||
| 156 | + return | ||
| 157 | + } | ||
| 158 | + success(data.data) | ||
| 159 | + }, (error: Error) => { | ||
| 160 | + fail(error.message) | ||
| 161 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 162 | + }) | ||
| 163 | + }) | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + /** | ||
| 167 | + * 直播预约/取消预约 | ||
| 168 | + * @param relationId | ||
| 169 | + * @param mLiveId | ||
| 170 | + * @param isSubscribe | ||
| 171 | + * @returns | ||
| 172 | + */ | ||
| 173 | + liveAppointment(relationId: string, mLiveId: string, isSubscribe: boolean) { | ||
| 174 | + let params: Record<string, string> = {}; | ||
| 175 | + params['relationId'] = relationId | ||
| 176 | + params['liveId'] = mLiveId | ||
| 177 | + params['isSubscribe'] = `${isSubscribe}` | ||
| 178 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 179 | + return new Promise<ResponseDTO<string>>((success, fail) => { | ||
| 180 | + HttpRequest.post<ResponseDTO<string>>( | ||
| 181 | + HttpUrlUtils.getLiveAppointmentUrl(), | ||
| 182 | + params, | ||
| 183 | + headers).then((data: ResponseDTO<string>) => { | ||
| 184 | + if (data.code != 0) { | ||
| 185 | + fail(data.message) | ||
| 186 | + ToastUtils.shortToast(data.message) | ||
| 187 | + return | ||
| 188 | + } | ||
| 189 | + success(data) | ||
| 190 | + }, (error: Error) => { | ||
| 191 | + fail(error.message) | ||
| 192 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 193 | + }) | ||
| 194 | + }) | ||
| 195 | + } | ||
| 110 | } | 196 | } |
| 111 | 197 |
| 1 | -import { LiveDetailsBean, LiveRoomBean } from 'wdBean/Index' | 1 | +import { LiveDetailsBean, LiveRoomBean, LiveRoomDataBean } from 'wdBean/Index' |
| 2 | +import { ResponseDTO } from 'wdNetwork/Index' | ||
| 2 | import { LiveModel } from './LiveModel' | 3 | import { LiveModel } from './LiveModel' |
| 3 | 4 | ||
| 4 | const TAG = "LiveViewModel" | 5 | const TAG = "LiveViewModel" |
| @@ -42,4 +43,37 @@ export class LiveViewModel { | @@ -42,4 +43,37 @@ export class LiveViewModel { | ||
| 42 | }) | 43 | }) |
| 43 | }) | 44 | }) |
| 44 | } | 45 | } |
| 46 | + | ||
| 47 | + //直播详情直播间数据 | ||
| 48 | + getLiveRoomData(liveId: string) { | ||
| 49 | + return new Promise<LiveRoomDataBean>((success, fail) => { | ||
| 50 | + this.liveModel.getLiveRoomData(liveId).then((data) => { | ||
| 51 | + success(data) | ||
| 52 | + }).catch((message: string) => { | ||
| 53 | + fail(message) | ||
| 54 | + }) | ||
| 55 | + }) | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + //直播预约状态查询 | ||
| 59 | + getLiveAppointmentStatus(relationId: string, liveId: string) { | ||
| 60 | + return new Promise<boolean>((success, fail) => { | ||
| 61 | + this.liveModel.getLiveAppointmentStatus(relationId, liveId).then((data) => { | ||
| 62 | + success(data) | ||
| 63 | + }).catch((message: string) => { | ||
| 64 | + fail(message) | ||
| 65 | + }) | ||
| 66 | + }) | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + //直播预约/取消预约 | ||
| 70 | + liveAppointment(relationId: string, mLiveId: string, isSubscribe: boolean) { | ||
| 71 | + return new Promise<ResponseDTO<string>>((success, fail) => { | ||
| 72 | + this.liveModel.liveAppointment(relationId, mLiveId, isSubscribe).then((data) => { | ||
| 73 | + success(data) | ||
| 74 | + }).catch((message: string) => { | ||
| 75 | + fail(message) | ||
| 76 | + }) | ||
| 77 | + }) | ||
| 78 | + } | ||
| 45 | } | 79 | } |
| 1 | import font from '@ohos.font' | 1 | import font from '@ohos.font' |
| 2 | import { LiveDetailsBean } from 'wdBean/Index' | 2 | import { LiveDetailsBean } from 'wdBean/Index' |
| 3 | import { DateTimeUtils, StringUtils } from 'wdKit/Index' | 3 | import { DateTimeUtils, StringUtils } from 'wdKit/Index' |
| 4 | +import { LiveViewModel } from '../../viewModel/LiveViewModel' | ||
| 4 | 5 | ||
| 5 | @Component | 6 | @Component |
| 6 | export struct LiveCountdownComponent { | 7 | export struct LiveCountdownComponent { |
| @@ -13,6 +14,9 @@ export struct LiveCountdownComponent { | @@ -13,6 +14,9 @@ export struct LiveCountdownComponent { | ||
| 13 | @State minute: string = '' | 14 | @State minute: string = '' |
| 14 | @State differenceTimeStamp: number = 0 | 15 | @State differenceTimeStamp: number = 0 |
| 15 | @State isCountDownStart: boolean = false | 16 | @State isCountDownStart: boolean = false |
| 17 | + //是否预约过直播 | ||
| 18 | + @State isAppointmentLive: boolean = false | ||
| 19 | + liveViewModel: LiveViewModel = new LiveViewModel() | ||
| 16 | 20 | ||
| 17 | aboutToAppear(): void { | 21 | aboutToAppear(): void { |
| 18 | //注册字体 | 22 | //注册字体 |
| @@ -107,15 +111,23 @@ export struct LiveCountdownComponent { | @@ -107,15 +111,23 @@ export struct LiveCountdownComponent { | ||
| 107 | top: 16 | 111 | top: 16 |
| 108 | }) | 112 | }) |
| 109 | .border({ radius: 4 }) | 113 | .border({ radius: 4 }) |
| 110 | - .backgroundColor('#ED2800') | ||
| 111 | - // .backgroundColor('#CCCCCC') | 114 | + .backgroundColor(this.isAppointmentLive ? '#CCCCCC' : '#ED2800') |
| 115 | + .onClick(() => { | ||
| 116 | + if (this.liveDetailsBean && this.liveDetailsBean.liveInfo) { | ||
| 117 | + this.liveAppointment() | ||
| 118 | + } | ||
| 119 | + }) | ||
| 112 | } | 120 | } |
| 113 | 121 | ||
| 114 | calculateDataStatus() { | 122 | calculateDataStatus() { |
| 123 | + if (!this.liveDetailsBean) { | ||
| 124 | + return | ||
| 125 | + } | ||
| 126 | + this.getLiveAppointmentStatus() | ||
| 115 | let startTimeStamp: number = DateTimeUtils.getDateTimestamp(this.liveDetailsBean.liveInfo.planStartTime) | 127 | let startTimeStamp: number = DateTimeUtils.getDateTimestamp(this.liveDetailsBean.liveInfo.planStartTime) |
| 116 | let currentTimeStamp: number = DateTimeUtils.getTimeStamp() | 128 | let currentTimeStamp: number = DateTimeUtils.getTimeStamp() |
| 117 | let _differenceTimeStampTmp = startTimeStamp - currentTimeStamp | 129 | let _differenceTimeStampTmp = startTimeStamp - currentTimeStamp |
| 118 | - this.isCountDownStart = _differenceTimeStampTmp <= 4 * 60 * 60 * 1000 | 130 | + this.isCountDownStart = _differenceTimeStampTmp <= 0 ? false : _differenceTimeStampTmp <= 4 * 60 * 60 * 1000 |
| 119 | if (this.isCountDownStart) { | 131 | if (this.isCountDownStart) { |
| 120 | this.differenceTimeStamp = _differenceTimeStampTmp | 132 | this.differenceTimeStamp = _differenceTimeStampTmp |
| 121 | return | 133 | return |
| @@ -129,6 +141,34 @@ export struct LiveCountdownComponent { | @@ -129,6 +141,34 @@ export struct LiveCountdownComponent { | ||
| 129 | this.minute = playStartTimeTmp.substring(14, 16) | 141 | this.minute = playStartTimeTmp.substring(14, 16) |
| 130 | } | 142 | } |
| 131 | } | 143 | } |
| 144 | + | ||
| 145 | + getLiveAppointmentStatus() { | ||
| 146 | + this.liveViewModel.getLiveAppointmentStatus( | ||
| 147 | + this.liveDetailsBean.reLInfo ? this.liveDetailsBean.reLInfo.relId : '', | ||
| 148 | + this.liveDetailsBean.newsId | ||
| 149 | + ).then( | ||
| 150 | + (data) => { | ||
| 151 | + this.isAppointmentLive = data | ||
| 152 | + }, | ||
| 153 | + () => { | ||
| 154 | + | ||
| 155 | + }) | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + liveAppointment() { | ||
| 159 | + this.liveViewModel.liveAppointment( | ||
| 160 | + this.liveDetailsBean.reLInfo ? this.liveDetailsBean.reLInfo.relId : '', | ||
| 161 | + this.liveDetailsBean.newsId, | ||
| 162 | + !this.isAppointmentLive).then( | ||
| 163 | + (data) => { | ||
| 164 | + if (data.success) { | ||
| 165 | + this.isAppointmentLive = !this.isAppointmentLive | ||
| 166 | + } | ||
| 167 | + }, | ||
| 168 | + () => { | ||
| 169 | + | ||
| 170 | + }) | ||
| 171 | + } | ||
| 132 | } | 172 | } |
| 133 | 173 | ||
| 134 | @Extend(Text) | 174 | @Extend(Text) |
| 1 | -import { LiveRoomItemBean } from 'wdBean/Index' | 1 | +import { LiveDetailsBean, LiveRoomItemBean } from 'wdBean/Index' |
| 2 | import { EmptyComponent, ErrorComponent, ListHasNoMoreDataUI } from 'wdComponent/Index' | 2 | import { EmptyComponent, ErrorComponent, ListHasNoMoreDataUI } from 'wdComponent/Index' |
| 3 | import CustomRefreshLoadLayout from 'wdComponent/src/main/ets/components/page/CustomRefreshLoadLayout' | 3 | import CustomRefreshLoadLayout from 'wdComponent/src/main/ets/components/page/CustomRefreshLoadLayout' |
| 4 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' | 4 | import LoadMoreLayout from 'wdComponent/src/main/ets/components/page/LoadMoreLayout' |
| @@ -14,6 +14,7 @@ export struct TabChatComponent { | @@ -14,6 +14,7 @@ export struct TabChatComponent { | ||
| 14 | @State private pageModel: PageModel = new PageModel() | 14 | @State private pageModel: PageModel = new PageModel() |
| 15 | liveViewModel: LiveViewModel = new LiveViewModel() | 15 | liveViewModel: LiveViewModel = new LiveViewModel() |
| 16 | @State liveChatList: Array<LiveRoomItemBean> = [] | 16 | @State liveChatList: Array<LiveRoomItemBean> = [] |
| 17 | + @Consume liveDetailsBean: LiveDetailsBean | ||
| 17 | 18 | ||
| 18 | aboutToAppear(): void { | 19 | aboutToAppear(): void { |
| 19 | this.getLiveChatList() | 20 | this.getLiveChatList() |
| @@ -77,7 +78,11 @@ export struct TabChatComponent { | @@ -77,7 +78,11 @@ export struct TabChatComponent { | ||
| 77 | 78 | ||
| 78 | getLiveChatList() { | 79 | getLiveChatList() { |
| 79 | this.pageModel.currentPage = 1 | 80 | this.pageModel.currentPage = 1 |
| 80 | - this.liveViewModel.getLiveChatList(1, '20000016257', '20000016229', 20,) | 81 | + this.liveViewModel.getLiveChatList( |
| 82 | + 1, | ||
| 83 | + this.liveDetailsBean?.liveInfo?.mlive?.mliveId, | ||
| 84 | + this.liveDetailsBean?.newsId, | ||
| 85 | + 20,) | ||
| 81 | .then( | 86 | .then( |
| 82 | (data) => { | 87 | (data) => { |
| 83 | if (data.barrageResponses && data.barrageResponses.length > 0) { | 88 | if (data.barrageResponses && data.barrageResponses.length > 0) { |
| 1 | -import { LiveRoomItemBean } from 'wdBean/Index' | 1 | +import { LiveDetailsBean, LiveRoomItemBean } from 'wdBean/Index' |
| 2 | import { ListHasNoMoreDataUI } from 'wdComponent/Index' | 2 | import { ListHasNoMoreDataUI } from 'wdComponent/Index' |
| 3 | +import { StringUtils } from 'wdKit/Index' | ||
| 3 | import { LiveViewModel } from '../../viewModel/LiveViewModel' | 4 | import { LiveViewModel } from '../../viewModel/LiveViewModel' |
| 4 | import { TabLiveItemComponent } from './TabLiveItemComponent' | 5 | import { TabLiveItemComponent } from './TabLiveItemComponent' |
| 5 | 6 | ||
| @@ -7,6 +8,7 @@ import { TabLiveItemComponent } from './TabLiveItemComponent' | @@ -7,6 +8,7 @@ import { TabLiveItemComponent } from './TabLiveItemComponent' | ||
| 7 | export struct TabLiveComponent { | 8 | export struct TabLiveComponent { |
| 8 | liveViewModel: LiveViewModel = new LiveViewModel() | 9 | liveViewModel: LiveViewModel = new LiveViewModel() |
| 9 | @State liveList: Array<LiveRoomItemBean> = [] | 10 | @State liveList: Array<LiveRoomItemBean> = [] |
| 11 | + @Consume liveDetailsBean: LiveDetailsBean | ||
| 10 | 12 | ||
| 11 | aboutToAppear(): void { | 13 | aboutToAppear(): void { |
| 12 | this.getLiveList() | 14 | this.getLiveList() |
| @@ -37,9 +39,27 @@ export struct TabLiveComponent { | @@ -37,9 +39,27 @@ export struct TabLiveComponent { | ||
| 37 | } | 39 | } |
| 38 | 40 | ||
| 39 | getLiveList() { | 41 | getLiveList() { |
| 40 | - this.liveViewModel.getLiveList(1, '20000016257', '20000016229', 20,) | 42 | + this.liveViewModel.getLiveList( |
| 43 | + 1, | ||
| 44 | + this.liveDetailsBean?.liveInfo?.mlive?.mliveId, | ||
| 45 | + this.liveDetailsBean?.newsId, | ||
| 46 | + 20) | ||
| 41 | .then( | 47 | .then( |
| 42 | (data) => { | 48 | (data) => { |
| 49 | + /** | ||
| 50 | + * 在直播聊天添加一条新内容逻辑: | ||
| 51 | + 判断 oldNewsId:迁移id非空 且 直播状态不是预约:"wait" | ||
| 52 | + 消息内容: | ||
| 53 | + 1.头像固定:APP默认头像 | ||
| 54 | + 2.名称固定:人民日报主持人 | ||
| 55 | + 3.内容:详情接口的简介,newIntroduction | ||
| 56 | + */ | ||
| 57 | + if (StringUtils.isNotEmpty(this.liveDetailsBean.oldNewsId) && this.liveDetailsBean && this.liveDetailsBean.liveInfo.liveState != 'wait') { | ||
| 58 | + let liveRoomItemBeanTemp: LiveRoomItemBean = {} as LiveRoomItemBean | ||
| 59 | + liveRoomItemBeanTemp.text = this.liveDetailsBean.newIntroduction | ||
| 60 | + liveRoomItemBeanTemp.senderUserName = '人民日报主持人' | ||
| 61 | + data.barrageResponses.push(liveRoomItemBeanTemp) | ||
| 62 | + } | ||
| 43 | this.liveList = data.barrageResponses | 63 | this.liveList = data.barrageResponses |
| 44 | }, | 64 | }, |
| 45 | () => { | 65 | () => { |
| 1 | import { LiveRoomItemBean } from 'wdBean/Index' | 1 | import { LiveRoomItemBean } from 'wdBean/Index' |
| 2 | -import { DateTimeUtils } from 'wdKit/Index' | 2 | +import { DateTimeUtils, StringUtils } from 'wdKit/Index' |
| 3 | 3 | ||
| 4 | @Component | 4 | @Component |
| 5 | export struct TabLiveItemComponent { | 5 | export struct TabLiveItemComponent { |
| @@ -12,7 +12,7 @@ export struct TabLiveItemComponent { | @@ -12,7 +12,7 @@ export struct TabLiveItemComponent { | ||
| 12 | build() { | 12 | build() { |
| 13 | Column() { | 13 | Column() { |
| 14 | Row() { | 14 | Row() { |
| 15 | - Image(this.item.senderUserAvatarUrl) | 15 | + Image(StringUtils.isEmpty(this.item.senderUserAvatarUrl) ? $r('app.media.default_head') : this.item.senderUserAvatarUrl) |
| 16 | .borderRadius(90) | 16 | .borderRadius(90) |
| 17 | .width(24) | 17 | .width(24) |
| 18 | .height(24) | 18 | .height(24) |
| @@ -46,6 +46,7 @@ export struct TabLiveItemComponent { | @@ -46,6 +46,7 @@ export struct TabLiveItemComponent { | ||
| 46 | .fontWeight(400) | 46 | .fontWeight(400) |
| 47 | .fontColor('#999999') | 47 | .fontColor('#999999') |
| 48 | .margin({ left: 8 }) | 48 | .margin({ left: 8 }) |
| 49 | + .visibility(StringUtils.isNotEmpty(this.item.time) ? Visibility.Visible : Visibility.None) | ||
| 49 | Blank() | 50 | Blank() |
| 50 | Text('置顶') | 51 | Text('置顶') |
| 51 | .maxLines(1) | 52 | .maxLines(1) |
| @@ -74,6 +75,8 @@ export struct TabLiveItemComponent { | @@ -74,6 +75,8 @@ export struct TabLiveItemComponent { | ||
| 74 | left: 32, | 75 | left: 32, |
| 75 | top: 6 | 76 | top: 6 |
| 76 | }) | 77 | }) |
| 78 | + .width('100%') | ||
| 79 | + .textAlign(TextAlign.Start) | ||
| 77 | List() { | 80 | List() { |
| 78 | ForEach(this.item.pictureUrls, (item: string, index: number) => { | 81 | ForEach(this.item.pictureUrls, (item: string, index: number) => { |
| 79 | ListItem() { | 82 | ListItem() { |
sight_harmony/features/wdDetailPlayLive/src/main/ets/widgets/details/video/PlayUIComponent.ets
0 → 100644
| 1 | +import { window } from '@kit.ArkUI' | ||
| 2 | +import { NumberFormatterUtils, WindowModel } from 'wdKit/Index' | ||
| 3 | + | ||
| 4 | +import { devicePLSensorManager } from 'wdDetailPlayApi/Index' | ||
| 5 | +import { DateFormatUtil, WDPlayerController } from 'wdPlayer/Index' | ||
| 6 | +import { LiveDetailsBean, LiveRoomDataBean } from 'wdBean/Index' | ||
| 7 | + | ||
| 8 | +@Entry | ||
| 9 | +@Component | ||
| 10 | +export struct PlayUIComponent { | ||
| 11 | + playerController: WDPlayerController = new WDPlayerController(); | ||
| 12 | + //菜单键是否可见 | ||
| 13 | + @State isMenuVisible: boolean = true | ||
| 14 | + @State isFullScreen: boolean = false | ||
| 15 | + @Consume liveDetailsBean: LiveDetailsBean | ||
| 16 | + @Consume liveRoomDataBean: LiveRoomDataBean | ||
| 17 | + @State currentTime: string = '' | ||
| 18 | + @State totalTime: string = '' | ||
| 19 | + @State progressVal: number = 0; | ||
| 20 | + //是否处于播放状态中 | ||
| 21 | + @State isPlayStatus: boolean = true | ||
| 22 | + | ||
| 23 | + aboutToAppear(): void { | ||
| 24 | + //播放进度监听 | ||
| 25 | + this.playerController.onTimeUpdate = (position: number, duration: number) => { | ||
| 26 | + this.currentTime = DateFormatUtil.secondToTime(Math.floor(position / 1000)); | ||
| 27 | + this.totalTime = DateFormatUtil.secondToTime(Math.floor(duration / 1000)); | ||
| 28 | + this.progressVal = Math.floor(position * 100 / duration); | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + build() { | ||
| 33 | + Column() { | ||
| 34 | + this.getTopUIComponent() | ||
| 35 | + this.getMiddleUIComponent() | ||
| 36 | + this.getBottomUIComponent() | ||
| 37 | + } | ||
| 38 | + .width('100%') | ||
| 39 | + .height('100%') | ||
| 40 | + .alignItems(HorizontalAlign.Start) | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + @Builder | ||
| 44 | + getTopUIComponent() { | ||
| 45 | + Column() { | ||
| 46 | + Row() { | ||
| 47 | + Image($r('app.media.icon_arrow_left_white')) | ||
| 48 | + .width(24) | ||
| 49 | + .aspectRatio(1) | ||
| 50 | + .visibility(Visibility.None) | ||
| 51 | + .margin({ | ||
| 52 | + right: 10 | ||
| 53 | + }) | ||
| 54 | + Text(this.liveDetailsBean.newsTitle) | ||
| 55 | + .maxLines(1) | ||
| 56 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 57 | + .fontSize('16fp') | ||
| 58 | + .fontWeight(500) | ||
| 59 | + .fontColor(Color.White) | ||
| 60 | + .textAlign(TextAlign.Start) | ||
| 61 | + .layoutWeight(1) | ||
| 62 | + Image($r('app.media.icon_share')) | ||
| 63 | + .width(24) | ||
| 64 | + .aspectRatio(1) | ||
| 65 | + .visibility(Visibility.None) | ||
| 66 | + } | ||
| 67 | + .width('100%') | ||
| 68 | + .alignItems(VerticalAlign.Center) | ||
| 69 | + .margin({ | ||
| 70 | + bottom: 10 | ||
| 71 | + }) | ||
| 72 | + | ||
| 73 | + this.getLiveStatusView() | ||
| 74 | + }.width('100%') | ||
| 75 | + .padding({ | ||
| 76 | + top: 20, | ||
| 77 | + bottom: 6, | ||
| 78 | + left: 10, | ||
| 79 | + right: 10 | ||
| 80 | + }) | ||
| 81 | + .alignItems(HorizontalAlign.Start) | ||
| 82 | + .visibility(this.isMenuVisible ? Visibility.Visible : Visibility.None) | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Builder | ||
| 86 | + getLiveStatusView() { | ||
| 87 | + // 直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 | ||
| 88 | + // 预约 | ||
| 89 | + // 直播中 | ||
| 90 | + if (this.liveDetailsBean.liveInfo?.liveState == 'running') { | ||
| 91 | + Row() { | ||
| 92 | + Image($r('app.media.icon_live_status_running')) | ||
| 93 | + .width(22) | ||
| 94 | + .height(18) | ||
| 95 | + Text('直播中') | ||
| 96 | + .fontSize('11fp') | ||
| 97 | + .fontWeight(400) | ||
| 98 | + .fontColor(Color.White) | ||
| 99 | + Image($r('app.media.icon_live_player_status_end')) | ||
| 100 | + .width(12) | ||
| 101 | + .height(12) | ||
| 102 | + Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`) | ||
| 103 | + .fontSize('11fp') | ||
| 104 | + .fontWeight(400) | ||
| 105 | + .fontColor(Color.White) | ||
| 106 | + } | ||
| 107 | + .backgroundColor('#4D000000') | ||
| 108 | + .padding({ | ||
| 109 | + top: 1, | ||
| 110 | + right: 4, | ||
| 111 | + bottom: 1 | ||
| 112 | + }) | ||
| 113 | + } | ||
| 114 | + //回看 | ||
| 115 | + else if (this.liveDetailsBean.liveInfo?.liveState == 'end') { | ||
| 116 | + Row() { | ||
| 117 | + Text('回看') | ||
| 118 | + .fontSize('11fp') | ||
| 119 | + .fontWeight(400) | ||
| 120 | + .fontColor(Color.White) | ||
| 121 | + Image($r('app.media.icon_live_player_status_end')) | ||
| 122 | + .width(12) | ||
| 123 | + .height(12) | ||
| 124 | + Text(`${NumberFormatterUtils.formatNumberWithWan(this.liveRoomDataBean.pv)}人参与`) | ||
| 125 | + .fontSize('11fp') | ||
| 126 | + .fontWeight(400) | ||
| 127 | + .fontColor(Color.White) | ||
| 128 | + } | ||
| 129 | + .backgroundColor('#4D000000') | ||
| 130 | + .padding({ | ||
| 131 | + left: 4, | ||
| 132 | + top: 1, | ||
| 133 | + right: 4, | ||
| 134 | + bottom: 1 | ||
| 135 | + }) | ||
| 136 | + } | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + @Builder | ||
| 140 | + getMiddleUIComponent() { | ||
| 141 | + Stack() | ||
| 142 | + .layoutWeight(1) | ||
| 143 | + .width('100%') | ||
| 144 | + .onClick(() => { | ||
| 145 | + this.isMenuVisible = !this.isMenuVisible | ||
| 146 | + }) | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @Builder | ||
| 150 | + getBottomUIComponent() { | ||
| 151 | + Row() { | ||
| 152 | + if (this.liveDetailsBean?.liveInfo?.liveState == 'end') { | ||
| 153 | + this.playOrPauseBtn() | ||
| 154 | + Text(this.currentTime) | ||
| 155 | + .fontColor(Color.White) | ||
| 156 | + .fontWeight(600) | ||
| 157 | + .fontSize('12fp') | ||
| 158 | + .margin({ | ||
| 159 | + left: 16 | ||
| 160 | + }) | ||
| 161 | + | ||
| 162 | + this.playProgressView() | ||
| 163 | + | ||
| 164 | + Text(this.totalTime) | ||
| 165 | + .fontColor(Color.White) | ||
| 166 | + .fontWeight(600) | ||
| 167 | + .fontSize('12fp') | ||
| 168 | + .margin({ | ||
| 169 | + right: 16 | ||
| 170 | + }) | ||
| 171 | + } else { | ||
| 172 | + Blank() | ||
| 173 | + } | ||
| 174 | + Image($r('app.media.icon_live_player_full_screen')) | ||
| 175 | + .width(24) | ||
| 176 | + .height(24) | ||
| 177 | + .onClick(() => { | ||
| 178 | + this.isFullScreen = !this.isFullScreen | ||
| 179 | + WindowModel.shared.setPreferredOrientation(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT); | ||
| 180 | + devicePLSensorManager.devicePLSensorOn(this.isFullScreen ? window.Orientation.LANDSCAPE : window.Orientation.PORTRAIT); | ||
| 181 | + }) | ||
| 182 | + } | ||
| 183 | + .alignItems(VerticalAlign.Center) | ||
| 184 | + .linearGradient({ angle: 0, colors: [['#99000000', 0], ['#00000000', 1]] }) | ||
| 185 | + .width('100%') | ||
| 186 | + .padding({ | ||
| 187 | + left: 10, | ||
| 188 | + right: 10, | ||
| 189 | + top: 15, | ||
| 190 | + bottom: 15 | ||
| 191 | + }) | ||
| 192 | + .visibility(this.isMenuVisible ? Visibility.Visible : Visibility.None) | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + @Builder | ||
| 196 | + playOrPauseBtn() { | ||
| 197 | + //暂停、播放 | ||
| 198 | + Image(this.isPlayStatus ? $r('app.media.icon_live_player_pause') : $r('app.media.player_play_ic')) | ||
| 199 | + .width(24) | ||
| 200 | + .height(24) | ||
| 201 | + .onClick(() => { | ||
| 202 | + if (this.isPlayStatus) { | ||
| 203 | + this.isPlayStatus = false | ||
| 204 | + this.playerController.pause() | ||
| 205 | + } else { | ||
| 206 | + this.isPlayStatus = true | ||
| 207 | + this.playerController.play() | ||
| 208 | + } | ||
| 209 | + }) | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + @Builder | ||
| 213 | + playProgressView() { | ||
| 214 | + Slider({ | ||
| 215 | + value: this.progressVal, | ||
| 216 | + step: 1, | ||
| 217 | + style: SliderStyle.OutSet | ||
| 218 | + }) | ||
| 219 | + .blockSize({ | ||
| 220 | + width: 18, | ||
| 221 | + height: 12 | ||
| 222 | + })// .blockStyle({ | ||
| 223 | + // type: SliderBlockType.IMAGE, | ||
| 224 | + // image: $r('app.media.ic_player_block') | ||
| 225 | + // }) | ||
| 226 | + .blockColor(Color.White) | ||
| 227 | + .trackColor('#4DFFFFFF') | ||
| 228 | + .selectedColor('#FFED2800') | ||
| 229 | + .height(14) | ||
| 230 | + .trackThickness(1) | ||
| 231 | + .layoutWeight(1) | ||
| 232 | + .margin({ | ||
| 233 | + left: 8, | ||
| 234 | + right: 8 | ||
| 235 | + }) | ||
| 236 | + .onChange((value: number, mode: SliderChangeMode) => { | ||
| 237 | + this.playerController?.setSeekTime(value, mode); | ||
| 238 | + }) | ||
| 239 | + } | ||
| 240 | +} |
| 1 | -import { WDPlayerController, WDPlayerRenderView } from 'wdPlayer/Index'; | 1 | +import { LiveDetailsBean } from 'wdBean/Index'; |
| 2 | +import { WDPlayerController, WDPlayerRenderLiveView } from 'wdPlayer/Index'; | ||
| 3 | +import { PlayUIComponent } from './PlayUIComponent'; | ||
| 2 | 4 | ||
| 3 | @Component | 5 | @Component |
| 4 | export struct TopPlayComponent { | 6 | export struct TopPlayComponent { |
| 5 | - @Prop playUrl: string='' | ||
| 6 | - aspectRatioPlayer: number = 375 / 211 | ||
| 7 | - @State playerController: WDPlayerController = new WDPlayerController(); | 7 | + @Consume @Watch('updateData') liveDetailsBean: LiveDetailsBean |
| 8 | + playerController: WDPlayerController = new WDPlayerController(); | ||
| 8 | 9 | ||
| 9 | aboutToAppear(): void { | 10 | aboutToAppear(): void { |
| 10 | - setTimeout(() => { | ||
| 11 | - this.playerController.switchPlayOrPause() | ||
| 12 | - },2000) | 11 | + this.playerController.onCanplay = () => { |
| 12 | + this.playerController.play() | ||
| 13 | + } | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + updateData() { | ||
| 17 | + //直播新闻-直播状态 wait待开播running直播中end已结束cancel已取消paused暂停 | ||
| 18 | + if (this.liveDetailsBean.liveInfo && this.liveDetailsBean.liveInfo.vlive.length > 0) { | ||
| 19 | + let playUrl = '' | ||
| 20 | + if (this.liveDetailsBean.liveInfo.liveState == 'running') { | ||
| 21 | + playUrl = this.liveDetailsBean.liveInfo.vlive[0].liveUrl | ||
| 22 | + } else if (this.liveDetailsBean.liveInfo.liveState == 'end') { | ||
| 23 | + playUrl = this.liveDetailsBean.liveInfo.vlive[0].replayUri | ||
| 24 | + } | ||
| 25 | + this.playerController.firstPlay(playUrl); | ||
| 26 | + } | ||
| 13 | } | 27 | } |
| 14 | 28 | ||
| 15 | build() { | 29 | build() { |
| 16 | Stack() { | 30 | Stack() { |
| 17 | - WDPlayerRenderView({ | 31 | + WDPlayerRenderLiveView({ |
| 18 | playerController: this.playerController, | 32 | playerController: this.playerController, |
| 19 | onLoad: async () => { | 33 | onLoad: async () => { |
| 20 | - this.playerController.firstPlay(this.playUrl); | ||
| 21 | } | 34 | } |
| 22 | }) | 35 | }) |
| 23 | .height('100%') | 36 | .height('100%') |
| 24 | .width('100%') | 37 | .width('100%') |
| 25 | - .onClick(() => { | ||
| 26 | - console.error('WDPlayerRenderView=== onClick') | ||
| 27 | - this.playerController?.switchPlayOrPause(); | ||
| 28 | - }) | 38 | + PlayUIComponent({ playerController: this.playerController }) |
| 29 | } | 39 | } |
| 30 | .height(211) | 40 | .height(211) |
| 31 | - .aspectRatio(this.aspectRatioPlayer) | ||
| 32 | - .backgroundColor(Color.Black) | 41 | + .width('100%') |
| 33 | } | 42 | } |
| 34 | 43 | ||
| 35 | aboutToDisappear(): void { | 44 | aboutToDisappear(): void { |
| 45 | + this.playerController.pause() | ||
| 36 | } | 46 | } |
| 37 | } | 47 | } |
| @@ -9,6 +9,11 @@ | @@ -9,6 +9,11 @@ | ||
| 9 | "2in1" | 9 | "2in1" |
| 10 | ], | 10 | ], |
| 11 | "deliveryWithInstall": true, | 11 | "deliveryWithInstall": true, |
| 12 | - "pages": "$profile:main_pages" | 12 | + "pages": "$profile:main_pages", |
| 13 | + "requestPermissions": [ | ||
| 14 | + { | ||
| 15 | + "name":"ohos.permission.ACCELEROMETER" | ||
| 16 | + } | ||
| 17 | + ] | ||
| 13 | } | 18 | } |
| 14 | } | 19 | } |
4.9 KB
sight_harmony/features/wdDetailPlayLive/src/main/resources/base/media/ic_player_block.png
0 → 100644
736 Bytes
sight_harmony/features/wdDetailPlayLive/src/main/resources/base/media/icon_arrow_left_white.png
0 → 100644
570 Bytes
439 Bytes
sight_harmony/features/wdDetailPlayLive/src/main/resources/base/media/icon_live_player_pause.png
0 → 100644
581 Bytes
318 Bytes
sight_harmony/features/wdDetailPlayLive/src/main/resources/base/media/icon_live_status_running.png
0 → 100644
1.26 KB
2.09 KB
2.13 KB
| @@ -2,6 +2,8 @@ export { WDPlayerController } from "./src/main/ets/controller/WDPlayerController | @@ -2,6 +2,8 @@ export { WDPlayerController } from "./src/main/ets/controller/WDPlayerController | ||
| 2 | 2 | ||
| 3 | export { WDPlayerRenderView } from "./src/main/ets/pages/WDPlayerRenderView" | 3 | export { WDPlayerRenderView } from "./src/main/ets/pages/WDPlayerRenderView" |
| 4 | 4 | ||
| 5 | +export { WDPlayerRenderLiveView } from "./src/main/ets/pages/WDPlayerRenderLiveView" | ||
| 6 | + | ||
| 5 | export { PlayerConstants } from "./src/main/ets/constants/PlayerConstants" | 7 | export { PlayerConstants } from "./src/main/ets/constants/PlayerConstants" |
| 6 | 8 | ||
| 7 | export { SpeedBean } from "./src/main/ets/bean/SpeedBean" | 9 | export { SpeedBean } from "./src/main/ets/bean/SpeedBean" |
| 1 | +import componentUtils from '@ohos.arkui.componentUtils'; | ||
| 2 | +import { WDPlayerController } from '../controller/WDPlayerController' | ||
| 3 | +import { WindowModel } from 'wdKit'; | ||
| 4 | +import { Logger } from '../utils/Logger'; | ||
| 5 | + | ||
| 6 | +class Size { | ||
| 7 | + width: Length = "100%"; | ||
| 8 | + height: Length = "100%"; | ||
| 9 | + | ||
| 10 | + constructor(width: Length, height: Length) { | ||
| 11 | + this.width = width; | ||
| 12 | + this.height = height; | ||
| 13 | + } | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +let insIndex: number = 0; | ||
| 17 | +const TAG = 'WDPlayerRenderLiveView' | ||
| 18 | + | ||
| 19 | +class MGPlayRenderViewIns { | ||
| 20 | + static intCount: number = 0; | ||
| 21 | + | ||
| 22 | + static add() { | ||
| 23 | + MGPlayRenderViewIns.intCount++; | ||
| 24 | + WindowModel.shared.setWindowKeepScreenOn(true); | ||
| 25 | + console.log("add-- +1") | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + static del() { | ||
| 29 | + console.log("del-- -1") | ||
| 30 | + MGPlayRenderViewIns.intCount--; | ||
| 31 | + if (MGPlayRenderViewIns.intCount <= 0) { | ||
| 32 | + WindowModel.shared.setWindowKeepScreenOn(false); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +/** | ||
| 38 | + * 播放窗口组件 | ||
| 39 | + */ | ||
| 40 | +@Component | ||
| 41 | +export struct WDPlayerRenderLiveView { | ||
| 42 | + private playerController?: WDPlayerController; | ||
| 43 | + private xComponentController: XComponentController = new XComponentController(); | ||
| 44 | + onLoad?: ((event?: object) => void); | ||
| 45 | + videoWidth: number = 0 | ||
| 46 | + videoHeight: number = 0 | ||
| 47 | + @State selfSize: Size = new Size('100%', '100%'); | ||
| 48 | + private insId: string = "WDPlayRenderView" + insIndex; | ||
| 49 | + | ||
| 50 | + aboutToAppear() { | ||
| 51 | + MGPlayRenderViewIns.add(); | ||
| 52 | + | ||
| 53 | + console.log('playerController', this.playerController) | ||
| 54 | + insIndex++; | ||
| 55 | + if (!this.playerController) { | ||
| 56 | + return | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + this.playerController.onVideoSizeChange = (width: number, height: number) => { | ||
| 60 | + // console.log(`WDPlayerRenderView onVideoSizeChange width:${width} videoTop:${height}`) | ||
| 61 | + Logger.info(TAG, ` onVideoSizeChange width:${width} videoTop:${height}`) | ||
| 62 | + this.videoWidth = width; | ||
| 63 | + this.videoHeight = height; | ||
| 64 | + this.updateLayout() | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + aboutToDisappear() { | ||
| 69 | + Logger.info(TAG, `aboutToDisappear`) | ||
| 70 | + MGPlayRenderViewIns.del(); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + build() { | ||
| 74 | + Row() { | ||
| 75 | + // 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。 | ||
| 76 | + XComponent({ | ||
| 77 | + id: 'xComponentId', | ||
| 78 | + type: 'surface', | ||
| 79 | + controller: this.xComponentController | ||
| 80 | + }) | ||
| 81 | + .onLoad(async (event) => { | ||
| 82 | + Logger.info(TAG, 'onLoad') | ||
| 83 | + let surfaceId = this.xComponentController.getXComponentSurfaceId() | ||
| 84 | + console.log('surfaceId===', surfaceId) | ||
| 85 | + console.log('insId===', this.insId) | ||
| 86 | + this.xComponentController.setXComponentSurfaceSize({ | ||
| 87 | + surfaceWidth: 1920, | ||
| 88 | + surfaceHeight: 1080 | ||
| 89 | + }); | ||
| 90 | + this.playerController?.setXComponentController(this.xComponentController) | ||
| 91 | + if (this.onLoad) { | ||
| 92 | + this.onLoad(event) | ||
| 93 | + } | ||
| 94 | + }) | ||
| 95 | + .width(this.selfSize.width) | ||
| 96 | + .height(this.selfSize.height) | ||
| 97 | + } | ||
| 98 | + .id(this.insId) | ||
| 99 | + .onAreaChange(() => { | ||
| 100 | + // this.updateLayout() | ||
| 101 | + }) | ||
| 102 | + .backgroundColor("#000000") | ||
| 103 | + .justifyContent(FlexAlign.Center) | ||
| 104 | + .height('100%') | ||
| 105 | + .width('100%') | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + updateLayout() { | ||
| 109 | + let info = componentUtils.getRectangleById(this.insId); | ||
| 110 | + if (info.size.width > 0 && info.size.height > 0 && this.videoHeight > 0 && this.videoWidth > 0) { | ||
| 111 | + if (info.size.width / info.size.height > this.videoWidth / this.videoHeight) { | ||
| 112 | + let scale = info.size.height / this.videoHeight; | ||
| 113 | + this.selfSize = new Size((this.videoWidth * scale / info.size.width) * 100 + "%", '100%'); | ||
| 114 | + } else { | ||
| 115 | + let scale = info.size.width / this.videoWidth; | ||
| 116 | + this.selfSize = new Size('100%', (this.videoHeight * scale / info.size.height) * 100 + "%"); | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | +} |
| @@ -17,7 +17,7 @@ export default struct CustomDialogComponent { | @@ -17,7 +17,7 @@ export default struct CustomDialogComponent { | ||
| 17 | Text($r('app.string.dialog_text_title')) | 17 | Text($r('app.string.dialog_text_title')) |
| 18 | .width("90%") | 18 | .width("90%") |
| 19 | .fontColor($r('app.color.dialog_text_color')) | 19 | .fontColor($r('app.color.dialog_text_color')) |
| 20 | - .fontSize($r('app.float.dialog_text_privacy_size')) | 20 | + .fontSize(18) |
| 21 | .textAlign(TextAlign.Center) | 21 | .textAlign(TextAlign.Center) |
| 22 | .fontWeight('500') | 22 | .fontWeight('500') |
| 23 | .margin({ | 23 | .margin({ |
| @@ -25,10 +25,25 @@ export default struct CustomDialogComponent { | @@ -25,10 +25,25 @@ export default struct CustomDialogComponent { | ||
| 25 | bottom: $r('app.float.dialog_text_privacy_bottom') | 25 | bottom: $r('app.float.dialog_text_privacy_bottom') |
| 26 | }) | 26 | }) |
| 27 | Text($r('app.string.dialog_text_subTitle')) | 27 | Text($r('app.string.dialog_text_subTitle')) |
| 28 | - .fontSize($r('app.float.dialog_common_text_size')) | 28 | + .fontSize(14) |
| 29 | + .fontColor($r('app.color.dialog_private_text_color')) | ||
| 29 | .width('90%') | 30 | .width('90%') |
| 30 | - Text($r('app.string.dialog_text_privacy_content')) | ||
| 31 | - .fontSize($r('app.float.dialog_common_text_size')) | 31 | + Text(){ |
| 32 | + Span('为了更好地为您提供阅读新闻、发布评论等相关服务,我们会根据您使用服务的具体功能需要,收集必要的用户信息。您可通过阅读') | ||
| 33 | + .fontSize(14).fontColor($r('app.color.dialog_private_text_color')) | ||
| 34 | + Span('《隐私政策》').fontSize(14).fontColor("#ED2800").onClick(()=>{ | ||
| 35 | + let bean={contentID:"2",pageID:""} as Params | ||
| 36 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 37 | + }) | ||
| 38 | + Span('和').fontSize(14).fontColor($r('app.color.dialog_private_text_color')).fontColor($r('app.color.dialog_private_text_color')) | ||
| 39 | + Span('《用户协议》').fontSize(14).fontColor("#ED2800").onClick(()=>{ | ||
| 40 | + let bean={contentID:"1",pageID:""} as Params | ||
| 41 | + WDRouterRule.jumpWithPage(WDRouterPage.loginProtocolPage,bean) | ||
| 42 | + }) | ||
| 43 | + Span('了解我们收集、使用、存储和共享个人信息的情况,以及对您个人隐私的保护措施。人民日报客户端深知个人信息对您的重要性,我们将以最高标准遵守法律法规要求,尽全力保护您的个人信息安全。') | ||
| 44 | + .fontSize(14) | ||
| 45 | + .fontColor($r('app.color.dialog_private_text_color')) | ||
| 46 | + } | ||
| 32 | .width('90%') | 47 | .width('90%') |
| 33 | Row(){ | 48 | Row(){ |
| 34 | 49 | ||
| @@ -115,11 +130,11 @@ export default struct CustomDialogComponent { | @@ -115,11 +130,11 @@ export default struct CustomDialogComponent { | ||
| 115 | .margin({ | 130 | .margin({ |
| 116 | top:'36lpx', | 131 | top:'36lpx', |
| 117 | bottom:'21lpx' | 132 | bottom:'21lpx' |
| 118 | - }) | 133 | + }).visibility(Visibility.None) |
| 119 | Text($r('app.string.dialog_text_privacy_statement')) | 134 | Text($r('app.string.dialog_text_privacy_statement')) |
| 120 | .width('90%') | 135 | .width('90%') |
| 121 | .fontColor($r('app.color.dialog_text_color')) | 136 | .fontColor($r('app.color.dialog_text_color')) |
| 122 | - .fontSize($r('app.float.dialog_common_text_size')) | 137 | + .fontSize(13).margin({top:20}) |
| 123 | Row() { | 138 | Row() { |
| 124 | Text($r('app.string.dialog_button_disagree')) | 139 | Text($r('app.string.dialog_button_disagree')) |
| 125 | .fancy() | 140 | .fancy() |
| @@ -154,7 +169,7 @@ export default struct CustomDialogComponent { | @@ -154,7 +169,7 @@ export default struct CustomDialogComponent { | ||
| 154 | // Common text styles. | 169 | // Common text styles. |
| 155 | @Extend(Text) function fancy () { | 170 | @Extend(Text) function fancy () { |
| 156 | .fontColor($r("app.color.dialog_fancy_text_left_color")) | 171 | .fontColor($r("app.color.dialog_fancy_text_left_color")) |
| 157 | - .fontSize($r("app.float.dialog_fancy_text_size")) | 172 | + .fontSize(16) |
| 158 | .textAlign(TextAlign.Center) | 173 | .textAlign(TextAlign.Center) |
| 159 | .fontWeight(FontWeight.Medium) | 174 | .fontWeight(FontWeight.Medium) |
| 160 | .layoutWeight('1') | 175 | .layoutWeight('1') |
| @@ -162,7 +177,7 @@ export default struct CustomDialogComponent { | @@ -162,7 +177,7 @@ export default struct CustomDialogComponent { | ||
| 162 | // Common text styles. | 177 | // Common text styles. |
| 163 | @Extend(Text) function fancyAgree () { | 178 | @Extend(Text) function fancyAgree () { |
| 164 | .fontColor($r("app.color.dialog_fancy_text_right_color")) | 179 | .fontColor($r("app.color.dialog_fancy_text_right_color")) |
| 165 | - .fontSize($r("app.float.dialog_fancy_text_size")) | 180 | + .fontSize(16) |
| 166 | .textAlign(TextAlign.Center) | 181 | .textAlign(TextAlign.Center) |
| 167 | .fontWeight(FontWeight.Medium) | 182 | .fontWeight(FontWeight.Medium) |
| 168 | .layoutWeight('1') | 183 | .layoutWeight('1') |
-
Please register or login to post a comment