chengen02

Merge remote-tracking branch 'origin/main'

@@ -114,7 +114,7 @@ export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo'; @@ -114,7 +114,7 @@ export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo';
114 114
115 export { slideShows } from './src/main/ets/bean/morningevening/slideShows'; 115 export { slideShows } from './src/main/ets/bean/morningevening/slideShows';
116 116
117 -export { LiveDetailsBean } from './src/main/ets/bean/live/LiveDetailsBean'; 117 +export { LiveDetailsBean, joinPeopleNum } from './src/main/ets/bean/live/LiveDetailsBean';
118 118
119 export { ArticleListDTO } from './src/main/ets/bean/component/ArticleListDTO'; 119 export { ArticleListDTO } from './src/main/ets/bean/component/ArticleListDTO';
120 120
@@ -208,3 +208,11 @@ export interface Vlive { @@ -208,3 +208,11 @@ export interface Vlive {
208 export interface ReLInfo { 208 export interface ReLInfo {
209 relId: string 209 relId: string
210 } 210 }
  211 +
  212 +export interface joinPeopleNum {
  213 + barrageNum: number,
  214 + likeNum: number,
  215 + liveId: number,
  216 + pv: number,
  217 + subscribeNum: number
  218 +}
1 -import { ContentDTO } from 'wdBean/Index' 1 +import { ContentDTO, joinPeopleNum } from 'wdBean/Index'
2 import { DateTimeUtils } from 'wdKit/Index' 2 import { DateTimeUtils } from 'wdKit/Index'
3 import { LottieView } from '../../components/lottie/LottieView'; 3 import { LottieView } from '../../components/lottie/LottieView';
  4 +import { LiveModel } from '../../viewmodel/LiveModel'
  5 +import font from '@ohos.font';
4 6
5 /** 7 /**
6 * 这里是样式卡中,右下角显示的音视频信息 8 * 这里是样式卡中,右下角显示的音视频信息
@@ -11,10 +13,55 @@ import { LottieView } from '../../components/lottie/LottieView'; @@ -11,10 +13,55 @@ import { LottieView } from '../../components/lottie/LottieView';
11 @Component 13 @Component
12 export struct CardMediaInfo { 14 export struct CardMediaInfo {
13 @State contentDTO: ContentDTO = new ContentDTO() // 如果有duraion,代表点播,显示时长;如果不传或者传0,显示直播中 15 @State contentDTO: ContentDTO = new ContentDTO() // 如果有duraion,代表点播,显示时长;如果不传或者传0,显示直播中
14 - 16 + @State joinPeopleNum: number = 0;
15 // objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频, 17 // objectType 0:不跳转 1:点播,2:直播,3:活动,4:广告,5:专题,6:链接,7:榜单,8:图文,9:组图,10:H5新闻,11:频道,12:组件,13:音频,
16 // 14动态图文,15动态视频16问政;100人民号,101标签 18 // 14动态图文,15动态视频16问政;100人民号,101标签
17 19
  20 + aboutToAppear(): void {
  21 + this.getJoinPeopleNum();
  22 +
  23 + font.registerFont({
  24 + familyName: 'BebasNeue',
  25 + familySrc: $rawfile('font/BebasNeue.ttf')
  26 + })
  27 + }
  28 +
  29 + /**
  30 + * 全域数字显示规则
  31 + * 1、当数量为千位以內时,显示数字,不保留小数点,比如 4585
  32 + * 2、当数量为万位~1亿时,显示xx 万,保留小数点后一位,比如1517.9w、2.9w
  33 + * 3、当数量为1亿~千亿时,显示XX 亿,保留小数点后一位,比如1517.9亿、2.9亿
  34 + * 4、不进行四舍五入
  35 + * 5、0 和空 不显示
  36 + */
  37 + handlerNum(number: string) {
  38 + const num = number??'0';
  39 + if (Number.parseInt(num) <= 9999) {
  40 + return Number.parseInt(num).toString()
  41 + } else if (Number.parseInt(num) > 9999 && Number.parseInt(num) <= 99999999) {
  42 + const num1: string = num.slice(0, -4); // 万
  43 + const num2: string = num.slice(-4, -3); // 千
  44 + return num2 === '0' ? num1 +'万' : num1 + '.' + num2 + '万'
  45 + } else if (Number.parseInt(num) > 99999999) {
  46 + const num1: string = num.slice(0, -8); // 亿
  47 + const num2: string = num.slice(-8, -7);
  48 + return num2 === '0' ? num1 +'亿' : num1 + '.' + num2 + '亿'
  49 + }
  50 + return num
  51 + }
  52 +
  53 + //
  54 + /**
  55 + * 获取直播节目参与人数
  56 + */
  57 + async getJoinPeopleNum() {
  58 + if (this.contentDTO.objectType !== '2') return;
  59 + console.log('getJoinPeopleNum-ContentDTO', JSON.stringify(this.contentDTO.objectId))
  60 + let liveIdList: string = this.contentDTO.objectId
  61 + let data: joinPeopleNum[] = await LiveModel.getJoinPeopleNum(liveIdList)
  62 + this.joinPeopleNum = data[0].pv;
  63 + }
  64 +
18 build() { 65 build() {
19 Row() { 66 Row() {
20 if (this.contentDTO?.objectType === '1' || this.contentDTO?.objectType === '15') { 67 if (this.contentDTO?.objectType === '1' || this.contentDTO?.objectType === '15') {
@@ -25,6 +72,7 @@ export struct CardMediaInfo { @@ -25,6 +72,7 @@ export struct CardMediaInfo {
25 if (this.contentDTO.videoInfo != null) { 72 if (this.contentDTO.videoInfo != null) {
26 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000)) 73 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.videoInfo.videoDuration * 1000))
27 .mediaText() 74 .mediaText()
  75 + .fontFamily('BebasNeue')
28 } 76 }
29 } 77 }
30 } else if (this.contentDTO.objectType === '2') { 78 } else if (this.contentDTO.objectType === '2') {
@@ -62,6 +110,12 @@ export struct CardMediaInfo { @@ -62,6 +110,12 @@ export struct CardMediaInfo {
62 Text('已结束') 110 Text('已结束')
63 .mediaText() 111 .mediaText()
64 } 112 }
  113 + if (!!this.joinPeopleNum) {
  114 + Text(' | ')
  115 + .mediaText()
  116 + Text(`${this.handlerNum(this.joinPeopleNum.toString())}人参加`)
  117 + .mediaText()
  118 + }
65 // } else if (this.contentDTO?.liveInfo?.liveState === 'end' && this.contentDTO?.liveInfo 119 // } else if (this.contentDTO?.liveInfo?.liveState === 'end' && this.contentDTO?.liveInfo
66 // ?.replayUri) { 120 // ?.replayUri) {
67 // // Image($r('app.media.card_live')) 121 // // Image($r('app.media.card_live'))
@@ -85,6 +139,7 @@ export struct CardMediaInfo { @@ -85,6 +139,7 @@ export struct CardMediaInfo {
85 .mediaLogo() 139 .mediaLogo()
86 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000)) 140 Text(DateTimeUtils.getFormattedDuration(this.contentDTO.voiceInfo.voiceDuration * 1000))
87 .mediaText() 141 .mediaText()
  142 + .fontFamily('BebasNeue')
88 } 143 }
89 } else if (this.contentDTO.objectType === '4') {//广告标签 144 } else if (this.contentDTO.objectType === '4') {//广告标签
90 Text($r('app.string.comp_advertisement')) 145 Text($r('app.string.comp_advertisement'))
@@ -155,7 +155,7 @@ export struct RmhTitle { @@ -155,7 +155,7 @@ export struct RmhTitle {
155 155
156 Text(Number(this.followStatus) === 0 ? '关注' : '已关注') 156 Text(Number(this.followStatus) === 0 ? '关注' : '已关注')
157 .fontSize($r('app.float.font_size_13')) 157 .fontSize($r('app.float.font_size_13'))
158 - .fontColor($r('app.color.color_ED2800')) 158 + .fontColor(Number(this.followStatus) === 0 ? $r('app.color.color_ED2800') : 0xc6c6c6)
159 } 159 }
160 .flexShrink(0) 160 .flexShrink(0)
161 .alignSelf(ItemAlign.Center) 161 .alignSelf(ItemAlign.Center)
@@ -67,6 +67,7 @@ export struct Card2Component { @@ -67,6 +67,7 @@ export struct Card2Component {
67 .fontSize($r('app.float.font_size_18')) 67 .fontSize($r('app.float.font_size_18'))
68 .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222')) 68 .fontColor(this.clicked ? 0x848484 : $r('app.color.color_222222'))
69 .maxLines(2) 69 .maxLines(2)
  70 + .lineHeight(27)
70 .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。 71 .textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
71 .align(Alignment.Start) 72 .align(Alignment.Start)
72 .textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 : 73 .textIndent(this.contentDTO.newTags?.length < 5 && this.contentDTO.newTags?.length > 2 ? 58 :
1 import MinePageDatasModel from '../../../model/MinePageDatasModel' 1 import MinePageDatasModel from '../../../model/MinePageDatasModel'
  2 +import { onlyWifiLoadImg } from '../../../utils/lazyloadImg'
2 import { AppointmentOperationRequestItem } from '../../../viewmodel/AppointmentOperationRequestItem' 3 import { AppointmentOperationRequestItem } from '../../../viewmodel/AppointmentOperationRequestItem'
3 import { MineAppointmentItem } from '../../../viewmodel/MineAppointmentItem' 4 import { MineAppointmentItem } from '../../../viewmodel/MineAppointmentItem'
4 import { MyCustomDialog } from '../../reusable/MyCustomDialog' 5 import { MyCustomDialog } from '../../reusable/MyCustomDialog'
5 6
6 @Component 7 @Component
7 -export struct AppointmentListChildComponent{ 8 +export struct AppointmentListChildComponent {
8 @ObjectLink item: MineAppointmentItem 9 @ObjectLink item: MineAppointmentItem
  10 + @State loadImg: boolean = false;
  11 +
  12 + async aboutToAppear(): Promise<void> {
  13 + this.loadImg = await onlyWifiLoadImg();
  14 + }
  15 +
9 dialogController: CustomDialogController = new CustomDialogController({ 16 dialogController: CustomDialogController = new CustomDialogController({
10 builder: MyCustomDialog({ 17 builder: MyCustomDialog({
11 cancel: this.onCancel, 18 cancel: this.onCancel,
@@ -20,18 +27,20 @@ export struct AppointmentListChildComponent{ @@ -20,18 +27,20 @@ export struct AppointmentListChildComponent{
20 customStyle: true 27 customStyle: true
21 }) 28 })
22 29
23 -  
24 build() { 30 build() {
25 - Column(){  
26 - Stack(){  
27 - Image(this.item?.imageUrl[0]) 31 + Column() {
  32 + Stack() {
  33 + Image(this.loadImg ? this.item?.imageUrl[0] : '')
  34 + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5)
  35 + .width('100%')
  36 + .aspectRatio(16 / 9)
28 .objectFit(ImageFit.Auto) 37 .objectFit(ImageFit.Auto)
29 .interpolation(ImageInterpolation.High) 38 .interpolation(ImageInterpolation.High)
30 39
31 40
32 - if(this.item.relType === 1){  
33 - Row(){  
34 - Row(){ 41 + if (this.item.relType === 1) {
  42 + Row() {
  43 + Row() {
35 Image($r('app.media.reserve_icon')) 44 Image($r('app.media.reserve_icon'))
36 .width('42lpx') 45 .width('42lpx')
37 .height('35lpx') 46 .height('35lpx')
@@ -47,7 +56,7 @@ export struct AppointmentListChildComponent{ @@ -47,7 +56,7 @@ export struct AppointmentListChildComponent{
47 .layoutWeight(1) 56 .layoutWeight(1)
48 .textAlign(TextAlign.Center) 57 .textAlign(TextAlign.Center)
49 }.width('94lpx') 58 }.width('94lpx')
50 - .margin({bottom:'15lpx',right:'15lpx'}) 59 + .margin({ bottom: '15lpx', right: '15lpx' })
51 }.width('100%') 60 }.width('100%')
52 .height('100%') 61 .height('100%')
53 .alignItems(VerticalAlign.Bottom) 62 .alignItems(VerticalAlign.Bottom)
@@ -56,7 +65,7 @@ export struct AppointmentListChildComponent{ @@ -56,7 +65,7 @@ export struct AppointmentListChildComponent{
56 }.width('100%') 65 }.width('100%')
57 .height('376lpx') 66 .height('376lpx')
58 67
59 - Column(){ 68 + Column() {
60 Text(this.item.title) 69 Text(this.item.title)
61 .fontWeight('400lpx') 70 .fontWeight('400lpx')
62 .fontSize('33lpx') 71 .fontSize('33lpx')
@@ -64,28 +73,28 @@ export struct AppointmentListChildComponent{ @@ -64,28 +73,28 @@ export struct AppointmentListChildComponent{
64 .lineHeight('48lpx') 73 .lineHeight('48lpx')
65 .maxLines(2) 74 .maxLines(2)
66 .textOverflow({ overflow: TextOverflow.Ellipsis }) 75 .textOverflow({ overflow: TextOverflow.Ellipsis })
67 - .margin({bottom:'23lpx'}) 76 + .margin({ bottom: '23lpx' })
68 .textAlign(TextAlign.Start) 77 .textAlign(TextAlign.Start)
69 .width('100%') 78 .width('100%')
70 - Row(){  
71 - Row(){  
72 - if(this.item.relType === 2){ 79 + Row() {
  80 + Row() {
  81 + if (this.item.relType === 2) {
73 Image($r('app.media.play_status_history_icon')) 82 Image($r('app.media.play_status_history_icon'))
74 .objectFit(ImageFit.Auto) 83 .objectFit(ImageFit.Auto)
75 .interpolation(ImageInterpolation.High) 84 .interpolation(ImageInterpolation.High)
76 .width('38lpx') 85 .width('38lpx')
77 .height('38lpx') 86 .height('38lpx')
78 - .margin({right:'12lpx'}) 87 + .margin({ right: '12lpx' })
79 Text('已结束').fontColor($r('app.color.color_999999')) 88 Text('已结束').fontColor($r('app.color.color_999999'))
80 .fontWeight('500lpx') 89 .fontWeight('500lpx')
81 .fontSize('23lpx') 90 .fontSize('23lpx')
82 - }else { 91 + } else {
83 Image($r('app.media.play_status_icon')) 92 Image($r('app.media.play_status_icon'))
84 .objectFit(ImageFit.Auto) 93 .objectFit(ImageFit.Auto)
85 .interpolation(ImageInterpolation.High) 94 .interpolation(ImageInterpolation.High)
86 .width('38lpx') 95 .width('38lpx')
87 .height('38lpx') 96 .height('38lpx')
88 - .margin({right:'12lpx'}) 97 + .margin({ right: '12lpx' })
89 Text(this.item.timePre).fontColor($r('app.color.color_ED2800')) 98 Text(this.item.timePre).fontColor($r('app.color.color_ED2800'))
90 .fontWeight('500lpx') 99 .fontWeight('500lpx')
91 .fontSize('23lpx') 100 .fontSize('23lpx')
@@ -94,35 +103,37 @@ export struct AppointmentListChildComponent{ @@ -94,35 +103,37 @@ export struct AppointmentListChildComponent{
94 .interpolation(ImageInterpolation.High) 103 .interpolation(ImageInterpolation.High)
95 .width('12lpx') 104 .width('12lpx')
96 .height('31lpx') 105 .height('31lpx')
97 - .margin({right:'4lpx'}) 106 + .margin({ right: '4lpx' })
98 Text(`${this.item.timeBack}开始`).fontColor($r('app.color.color_ED2800')) 107 Text(`${this.item.timeBack}开始`).fontColor($r('app.color.color_ED2800'))
99 .fontWeight('500lpx') 108 .fontWeight('500lpx')
100 .fontSize('23lpx') 109 .fontSize('23lpx')
101 .lineHeight('31lpx') 110 .lineHeight('31lpx')
102 } 111 }
103 - }.padding({left:'19lpx',right:'19lpx'}) 112 + }
  113 + .padding({ left: '19lpx', right: '19lpx' })
104 .height('46lpx') 114 .height('46lpx')
105 .alignItems(VerticalAlign.Center) 115 .alignItems(VerticalAlign.Center)
106 .backgroundColor($r('app.color.color_F5F5F5')) 116 .backgroundColor($r('app.color.color_F5F5F5'))
107 .borderRadius('4lpx') 117 .borderRadius('4lpx')
  118 +
108 Blank() 119 Blank()
109 - .layoutWeight(1)  
110 - if(this.item.relType === 1){  
111 - Text(this.item.isAppointment?"已预约":"预约")  
112 - .fontWeight(400)  
113 - .fontSize('23lpx')  
114 - .backgroundColor(this.item.isAppointment?$r('app.color.color_F5F5F5'):$r('app.color.color_ED2800'))  
115 - .fontColor(this.item.isAppointment?$r('app.color.color_CCCCCC'):$r('app.color.white'))  
116 - .lineHeight('31lpx')  
117 - .textAlign(TextAlign.Center)  
118 - .width('100lpx')  
119 - .height('46lpx')  
120 - .borderRadius('6lpx')  
121 - .onClick(()=>{  
122 - this.dialogController.open()  
123 - })  
124 - }else {  
125 - Text(this.item.relType === 2?"去观看":"看回放") 120 + .layoutWeight(1)
  121 + if (this.item.relType === 1) {
  122 + Text(this.item.isAppointment ? "已预约" : "预约")
  123 + .fontWeight(400)
  124 + .fontSize('23lpx')
  125 + .backgroundColor(this.item.isAppointment ? $r('app.color.color_F5F5F5') : $r('app.color.color_ED2800'))
  126 + .fontColor(this.item.isAppointment ? $r('app.color.color_CCCCCC') : $r('app.color.white'))
  127 + .lineHeight('31lpx')
  128 + .textAlign(TextAlign.Center)
  129 + .width('100lpx')
  130 + .height('46lpx')
  131 + .borderRadius('6lpx')
  132 + .onClick(() => {
  133 + this.dialogController.open()
  134 + })
  135 + } else {
  136 + Text(this.item.relType === 2 ? "去观看" : "看回放")
126 .fontWeight(400) 137 .fontWeight(400)
127 .fontSize('23lpx') 138 .fontSize('23lpx')
128 .backgroundColor($r('app.color.color_ED2800')) 139 .backgroundColor($r('app.color.color_ED2800'))
@@ -135,7 +146,12 @@ export struct AppointmentListChildComponent{ @@ -135,7 +146,12 @@ export struct AppointmentListChildComponent{
135 } 146 }
136 } 147 }
137 } 148 }
138 - .padding({left:'23lpx',right:'23lpx',top:'15lpx',bottom:'23lpx'}) 149 + .padding({
  150 + left: '23lpx',
  151 + right: '23lpx',
  152 + top: '15lpx',
  153 + bottom: '23lpx'
  154 + })
139 }.margin({ left: 10, right: 10 }) 155 }.margin({ left: 10, right: 10 })
140 .backgroundColor($r('app.color.white')) 156 .backgroundColor($r('app.color.white'))
141 .borderRadius('8lpx') 157 .borderRadius('8lpx')
@@ -145,20 +161,19 @@ export struct AppointmentListChildComponent{ @@ -145,20 +161,19 @@ export struct AppointmentListChildComponent{
145 console.info('Callback when the first button is clicked') 161 console.info('Callback when the first button is clicked')
146 } 162 }
147 163
148 - onAccept(){ 164 + onAccept() {
149 console.info('Callback when the second button is clicked') 165 console.info('Callback when the second button is clicked')
150 this.appointmentOperation() 166 this.appointmentOperation()
151 } 167 }
152 168
153 - appointmentOperation(){  
154 - let item = new AppointmentOperationRequestItem(this.item.relId,this.item.liveId+"",!this.item.isAppointment)  
155 - MinePageDatasModel.getAppointmentOperation(item,getContext(this)).then((value)=>{  
156 - if(value!=null){ 169 + appointmentOperation() {
  170 + let item = new AppointmentOperationRequestItem(this.item.relId, this.item.liveId + "", !this.item.isAppointment)
  171 + MinePageDatasModel.getAppointmentOperation(item, getContext(this)).then((value) => {
  172 + if (value != null) {
157 if (value.code === 0 || value.code.toString() === "0") { 173 if (value.code === 0 || value.code.toString() === "0") {
158 this.item.isAppointment = !this.item.isAppointment 174 this.item.isAppointment = !this.item.isAppointment
159 } 175 }
160 } 176 }
161 }) 177 })
162 } 178 }
163 -  
164 } 179 }
@@ -12,6 +12,7 @@ import LoadMoreLayout from '../page/LoadMoreLayout'; @@ -12,6 +12,7 @@ import LoadMoreLayout from '../page/LoadMoreLayout';
12 import { LottieView } from '../../components/lottie/LottieView'; 12 import { LottieView } from '../../components/lottie/LottieView';
13 import dataPreferences from '@ohos.data.preferences'; 13 import dataPreferences from '@ohos.data.preferences';
14 import { BusinessError } from '@ohos.base'; 14 import { BusinessError } from '@ohos.base';
  15 +import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
15 16
16 const TAG: string = 'LiveMorePage'; 17 const TAG: string = 'LiveMorePage';
17 18
@@ -45,8 +46,12 @@ struct LiveMorePage { @@ -45,8 +46,12 @@ struct LiveMorePage {
45 // 点击过的数据 46 // 点击过的数据
46 @State clickDatas: Array<string> = [] 47 @State clickDatas: Array<string> = []
47 48
48 - async aboutToAppear() { 49 + @State loadImg: boolean = false;
  50 +
  51 +
  52 + async aboutToAppear() : Promise<void>{
49 await this.getPreferencesFromStorage() 53 await this.getPreferencesFromStorage()
  54 + this.loadImg = await onlyWifiLoadImg();
50 this.getLivMoreClickPreference() 55 this.getLivMoreClickPreference()
51 Logger.debug(TAG, '数据:' + JSON.stringify(this.clickDatas)) 56 Logger.debug(TAG, '数据:' + JSON.stringify(this.clickDatas))
52 this.currentPage = 1 57 this.currentPage = 1
@@ -155,9 +160,10 @@ struct LiveMorePage { @@ -155,9 +160,10 @@ struct LiveMorePage {
155 .fontColor(this.isClicked(item.objectId) ? $r('app.color.color_848484') : $r('app.color.color_222222')) 160 .fontColor(this.isClicked(item.objectId) ? $r('app.color.color_848484') : $r('app.color.color_222222'))
156 Stack() { 161 Stack() {
157 if (item.fullColumnImgUrls && item.fullColumnImgUrls.length > 0) { 162 if (item.fullColumnImgUrls && item.fullColumnImgUrls.length > 0) {
158 - Image(item.fullColumnImgUrls[0].url) 163 + Image(this.loadImg?item.fullColumnImgUrls[0].url:'')
  164 + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : 0xf5f5f5)
159 .width('100%') 165 .width('100%')
160 - .height(196) 166 + .aspectRatio(16 / 9)
161 .borderRadius(4) 167 .borderRadius(4)
162 } 168 }
163 this.LiveImage(item) 169 this.LiveImage(item)
1 import { ContentDTO, ReserveBean, ReserveItemBean } from 'wdBean/Index'; 1 import { ContentDTO, ReserveBean, ReserveItemBean } from 'wdBean/Index';
2 import { ProcessUtils } from 'wdRouter/Index'; 2 import { ProcessUtils } from 'wdRouter/Index';
3 import PageViewModel from '../../viewmodel/PageViewModel'; 3 import PageViewModel from '../../viewmodel/PageViewModel';
4 -import { Logger, EmitterEventId, EmitterUtils, ToastUtils } from 'wdKit/Index'; 4 +import { Logger, EmitterEventId, EmitterUtils, ToastUtils } from 'wdKit/Index';
5 import { router } from '@kit.ArkUI'; 5 import { router } from '@kit.ArkUI';
6 import { LiveModel } from '../../viewmodel/LiveModel'; 6 import { LiveModel } from '../../viewmodel/LiveModel';
7 import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType'; 7 import { ViewType } from 'wdConstant/src/main/ets/enum/ViewType';
@@ -9,10 +9,11 @@ import { EmptyComponent } from '../view/EmptyComponent'; @@ -9,10 +9,11 @@ import { EmptyComponent } from '../view/EmptyComponent';
9 import { ErrorComponent } from '../view/ErrorComponent'; 9 import { ErrorComponent } from '../view/ErrorComponent';
10 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh'; 10 import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
11 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData'; 11 import { PeopleShipNoMoreData } from '../reusable/PeopleShipNoMoreData';
12 -import { HttpUtils } from 'wdNetwork/Index'; 12 +import { HttpUtils } from 'wdNetwork/Index';
13 import { WDRouterPage, WDRouterRule } from 'wdRouter' 13 import { WDRouterPage, WDRouterRule } from 'wdRouter'
14 -import { LazyDataSource } from 'wdKit/Index'; 14 +import { LazyDataSource } from 'wdKit/Index';
15 import LoadMoreLayout from '../page/LoadMoreLayout' 15 import LoadMoreLayout from '../page/LoadMoreLayout'
  16 +import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
16 17
17 const TAG: string = 'ReserveMorePage'; 18 const TAG: string = 'ReserveMorePage';
18 19
@@ -43,11 +44,12 @@ struct ReserveMorePage { @@ -43,11 +44,12 @@ struct ReserveMorePage {
43 private scroller: Scroller = new Scroller() 44 private scroller: Scroller = new Scroller()
44 @State reservedIds: string[] = [] 45 @State reservedIds: string[] = []
45 @State isShow: boolean = false 46 @State isShow: boolean = false
46 - @State private liveId: string = '' 47 + @State private liveId: string = ''
47 @State isLoadingAttention: boolean = false 48 @State isLoadingAttention: boolean = false
  49 + @State loadImg: boolean = false;
48 50
49 build() { 51 build() {
50 - Column(){ 52 + Column() {
51 this.TabbarNormal() 53 this.TabbarNormal()
52 if (this.viewType == ViewType.LOADING) { 54 if (this.viewType == ViewType.LOADING) {
53 this.LoadingLayout() 55 this.LoadingLayout()
@@ -85,7 +87,7 @@ struct ReserveMorePage { @@ -85,7 +87,7 @@ struct ReserveMorePage {
85 87
86 @Builder 88 @Builder
87 ListLayout() { 89 ListLayout() {
88 - List({scroller: this.scroller}) { 90 + List({ scroller: this.scroller }) {
89 // 下拉刷新 91 // 下拉刷新
90 LazyForEach(this.data, (contentDTO: ContentDTO, index: number) => { 92 LazyForEach(this.data, (contentDTO: ContentDTO, index: number) => {
91 ListItem() { 93 ListItem() {
@@ -110,7 +112,7 @@ struct ReserveMorePage { @@ -110,7 +112,7 @@ struct ReserveMorePage {
110 .height('calc(100% - 44vp)') 112 .height('calc(100% - 44vp)')
111 .onReachEnd(() => { 113 .onReachEnd(() => {
112 Logger.debug(TAG, "触底了"); 114 Logger.debug(TAG, "触底了");
113 - if(!this.isLoading && this.hasMore){ 115 + if (!this.isLoading && this.hasMore) {
114 //加载分页数据 116 //加载分页数据
115 this.currentPage++; 117 this.currentPage++;
116 this.getData() 118 this.getData()
@@ -127,9 +129,13 @@ struct ReserveMorePage { @@ -127,9 +129,13 @@ struct ReserveMorePage {
127 buildItem(item: ContentDTO, index: number) { 129 buildItem(item: ContentDTO, index: number) {
128 Column() { 130 Column() {
129 Stack() { 131 Stack() {
130 - Image(item.fullColumnImgUrls[0]?.url) 132 + Image(this.loadImg ? item.fullColumnImgUrls[0]?.url : '')
131 .width('100%') 133 .width('100%')
  134 + .aspectRatio(16 / 9)
  135 + .backgroundColor(this.loadImg ? $r('app.color.color_B0B0B0') : $r('app.color.color_33A3A3A3'))
132 .objectFit(ImageFit.Contain) 136 .objectFit(ImageFit.Contain)
  137 + .borderWidth(0.5)
  138 + .borderColor($r('app.color.color_0D000000'))
133 .borderRadius({ 139 .borderRadius({
134 topLeft: '4vp', 140 topLeft: '4vp',
135 topRight: '4vp' 141 topRight: '4vp'
@@ -152,7 +158,12 @@ struct ReserveMorePage { @@ -152,7 +158,12 @@ struct ReserveMorePage {
152 Image($r('app.media.reserve_play_icon')) 158 Image($r('app.media.reserve_play_icon'))
153 .width(20) 159 .width(20)
154 .height(20) 160 .height(20)
155 - .margin({ left: 10, top: 2, bottom: 2, right: 6 }) 161 + .margin({
  162 + left: 10,
  163 + top: 2,
  164 + bottom: 2,
  165 + right: 6
  166 + })
156 167
157 Text(this.getReserveDate(item.liveInfo.liveStartTime, 1)) 168 Text(this.getReserveDate(item.liveInfo.liveStartTime, 1))
158 .fontSize(12) 169 .fontSize(12)
@@ -190,7 +201,8 @@ struct ReserveMorePage { @@ -190,7 +201,8 @@ struct ReserveMorePage {
190 .width(20) 201 .width(20)
191 .height(20) 202 .height(20)
192 .color(!this.isReserved(item) ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC')) 203 .color(!this.isReserved(item) ? $r('app.color.color_fff') : $r('app.color.color_CCCCCC'))
193 - .visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.Visible : Visibility.None) 204 + .visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.Visible :
  205 + Visibility.None)
194 206
195 Text(!this.isReserved(item) ? '预约' : '已预约') 207 Text(!this.isReserved(item) ? '预约' : '已预约')
196 .fontSize($r('app.float.vp_12')) 208 .fontSize($r('app.float.vp_12'))
@@ -199,14 +211,21 @@ struct ReserveMorePage { @@ -199,14 +211,21 @@ struct ReserveMorePage {
199 .width('100%') 211 .width('100%')
200 .height('100%') 212 .height('100%')
201 .textAlign(TextAlign.Center) 213 .textAlign(TextAlign.Center)
202 - .visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.None : Visibility.Visible) 214 + .visibility((this.isLoadingAttention && this.liveId == item.objectId) ? Visibility.None :
  215 + Visibility.Visible)
203 .margin({ 216 .margin({
204 right: '10vp' 217 right: '10vp'
205 }) 218 })
  219 + .textShadow({
  220 + radius: 2,
  221 + color: 'rgba(0,0,0,0.3)',
  222 + offsetY: 2
  223 + })
206 .backgroundColor(!this.isReserved(item) ? $r('app.color.color_ED2800') : $r('app.color.color_F5F5F5')) 224 .backgroundColor(!this.isReserved(item) ? $r('app.color.color_ED2800') : $r('app.color.color_F5F5F5'))
207 .borderRadius(3) 225 .borderRadius(3)
208 226
209 - }.onClick(() => { 227 + }
  228 + .onClick(() => {
210 this.bookAndCancel(item) 229 this.bookAndCancel(item)
211 }) 230 })
212 .justifyContent(FlexAlign.Center) 231 .justifyContent(FlexAlign.Center)
@@ -214,7 +233,7 @@ struct ReserveMorePage { @@ -214,7 +233,7 @@ struct ReserveMorePage {
214 .borderRadius(3) 233 .borderRadius(3)
215 .width('52vp') 234 .width('52vp')
216 .height('24vp') 235 .height('24vp')
217 - .margin({right: 12}) 236 + .margin({ right: 12 })
218 237
219 } 238 }
220 .width('100%') 239 .width('100%')
@@ -285,12 +304,18 @@ struct ReserveMorePage { @@ -285,12 +304,18 @@ struct ReserveMorePage {
285 .fontSize('12vp') 304 .fontSize('12vp')
286 .fontWeight(400) 305 .fontWeight(400)
287 .fontColor(Color.White) 306 .fontColor(Color.White)
  307 + .textShadow({
  308 + radius: 2,
  309 + color: 'rgba(0,0,0,0.3)',
  310 + offsetY: 2
  311 + })
288 } 312 }
289 .backgroundColor(Color.Transparent) 313 .backgroundColor(Color.Transparent)
290 .margin({ right: 8, bottom: 8 }) 314 .margin({ right: 8, bottom: 8 })
291 } 315 }
292 316
293 async aboutToAppear(): Promise<void> { 317 async aboutToAppear(): Promise<void> {
  318 + this.loadImg = await onlyWifiLoadImg();
294 // PageViewModel.get 319 // PageViewModel.get
295 this.currentPage = 1 320 this.currentPage = 1
296 this.getData() 321 this.getData()
@@ -301,24 +326,24 @@ struct ReserveMorePage { @@ -301,24 +326,24 @@ struct ReserveMorePage {
301 }) 326 })
302 327
303 // 获取预约 328 // 获取预约
304 - EmitterUtils.receiveEvent(EmitterEventId.LIVE_ROOM_SUBSCRIBE, (str?: string) => { 329 + EmitterUtils.receiveEvent(EmitterEventId.LIVE_ROOM_SUBSCRIBE, (str?: string) => {
305 Logger.debug(TAG, 'receiveEvent LIVE_ROOM_SUBSCRIBE: ' + str) 330 Logger.debug(TAG, 'receiveEvent LIVE_ROOM_SUBSCRIBE: ' + str)
306 if (str) { 331 if (str) {
307 // 跳转指定频道场景,传参底导id、频道id 332 // 跳转指定频道场景,传参底导id、频道id
308 const model: ReserveItemBean = JSON.parse(str) 333 const model: ReserveItemBean = JSON.parse(str)
309 - Logger.debug(TAG,'是否关注元数据0:' +` ${model.liveId}`)  
310 - if (model && model.liveId && this.reserveList) { 334 + Logger.debug(TAG, '是否关注元数据0:' + ` ${model.liveId}`)
  335 + if (model && model.liveId && this.reserveList) {
311 // 修改源数据 336 // 修改源数据
312 this.reserveList.forEach((element) => { 337 this.reserveList.forEach((element) => {
313 if (element.liveId == model.liveId) { 338 if (element.liveId == model.liveId) {
314 if (element && element.subscribe != model.subscribe) { 339 if (element && element.subscribe != model.subscribe) {
315 - Logger.debug(TAG,'是否关注元数据2:' +` ${JSON.stringify(element.subscribe)}`) 340 + Logger.debug(TAG, '是否关注元数据2:' + ` ${JSON.stringify(element.subscribe)}`)
316 element.subscribe = !element.subscribe 341 element.subscribe = !element.subscribe
317 - Logger.debug(TAG,'是否关注元数据3:' +` ${JSON.stringify(element.subscribe)}`) 342 + Logger.debug(TAG, '是否关注元数据3:' + ` ${JSON.stringify(element.subscribe)}`)
318 this.isShow = true 343 this.isShow = true
319 if (element.subscribe) { 344 if (element.subscribe) {
320 this.reservedIds.push(element.liveId.toString()) 345 this.reservedIds.push(element.liveId.toString())
321 - }else { 346 + } else {
322 const num = this.reservedIds.indexOf(element.liveId.toString()) 347 const num = this.reservedIds.indexOf(element.liveId.toString())
323 if (num >= 0 && num < this.reservedIds.length) { 348 if (num >= 0 && num < this.reservedIds.length) {
324 this.reservedIds.splice(num, 1) 349 this.reservedIds.splice(num, 1)
@@ -364,14 +389,14 @@ struct ReserveMorePage { @@ -364,14 +389,14 @@ struct ReserveMorePage {
364 this.data.push(...liveReviewDTO.list) 389 this.data.push(...liveReviewDTO.list)
365 //批量查询关注状态 390 //批量查询关注状态
366 this.getAppointmentInfo(liveReviewDTO.list) 391 this.getAppointmentInfo(liveReviewDTO.list)
367 - } else { 392 + } else {
368 this.hasMore = false; 393 this.hasMore = false;
369 } 394 }
370 this.resolveEnd(true, resolve) 395 this.resolveEnd(true, resolve)
371 if (liveReviewDTO.list.length == 0 && this.currentPage == 1) { 396 if (liveReviewDTO.list.length == 0 && this.currentPage == 1) {
372 this.viewType = ViewType.EMPTY 397 this.viewType = ViewType.EMPTY
373 } 398 }
374 - }catch (exception) { 399 + } catch (exception) {
375 this.resolveEnd(false, resolve) 400 this.resolveEnd(false, resolve)
376 } 401 }
377 // PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => { 402 // PageViewModel.getLiveMoreUrl(this.type, this.currentPage, this.pageSize).then(async (liveReviewDTO) => {
@@ -387,7 +412,7 @@ struct ReserveMorePage { @@ -387,7 +412,7 @@ struct ReserveMorePage {
387 if (resolve) { 412 if (resolve) {
388 if (this.currentPage == 1 && isTop) { 413 if (this.currentPage == 1 && isTop) {
389 resolve('已更新至最新') 414 resolve('已更新至最新')
390 - }else { 415 + } else {
391 resolve('') 416 resolve('')
392 } 417 }
393 } 418 }
@@ -402,9 +427,9 @@ struct ReserveMorePage { @@ -402,9 +427,9 @@ struct ReserveMorePage {
402 async getAppointmentInfo(list: ContentDTO[]) { 427 async getAppointmentInfo(list: ContentDTO[]) {
403 if (HttpUtils.getUserId()) { 428 if (HttpUtils.getUserId()) {
404 const reserveBean = this.transformToLiveDetailsBeans(list) 429 const reserveBean = this.transformToLiveDetailsBeans(list)
405 - Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(reserveBean)}`) 430 + Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(reserveBean)}`)
406 LiveModel.getAppointmentStatus(reserveBean).then((result) => { 431 LiveModel.getAppointmentStatus(reserveBean).then((result) => {
407 - Logger.debug(TAG,'是否预约数据:' +` ${JSON.stringify(result)}`) 432 + Logger.debug(TAG, '是否预约数据:' + ` ${JSON.stringify(result)}`)
408 if (result && result.length > 0) { 433 if (result && result.length > 0) {
409 this.reserveList.push(...result) 434 this.reserveList.push(...result)
410 // this.reserveStatus = res; 435 // this.reserveStatus = res;
@@ -414,10 +439,10 @@ struct ReserveMorePage { @@ -414,10 +439,10 @@ struct ReserveMorePage {
414 } 439 }
415 }) 440 })
416 } 441 }
417 - }).catch(() =>{ 442 + }).catch(() => {
418 // this.data.push(...list) 443 // this.data.push(...list)
419 }) 444 })
420 - }else { 445 + } else {
421 // this.data.push(...list) 446 // this.data.push(...list)
422 447
423 } 448 }
@@ -463,18 +488,19 @@ struct ReserveMorePage { @@ -463,18 +488,19 @@ struct ReserveMorePage {
463 this.isLoadingAttention = true 488 this.isLoadingAttention = true
464 this.liveId = reserveItem.liveId.toString() 489 this.liveId = reserveItem.liveId.toString()
465 try { 490 try {
466 - const res = await LiveModel.liveAppointment(reserveItem.relationId, reserveItem.liveId.toString(), !reserveItem.subscribe); 491 + const res = await LiveModel.liveAppointment(reserveItem.relationId, reserveItem.liveId.toString(),
  492 + !reserveItem.subscribe);
467 if (res.code == 0) { 493 if (res.code == 0) {
468 ToastUtils.shortToast(!reserveItem.subscribe ? '预约成功' : '取消预约成功') 494 ToastUtils.shortToast(!reserveItem.subscribe ? '预约成功' : '取消预约成功')
469 // 修改源数据 495 // 修改源数据
470 this.reserveList.forEach((element) => { 496 this.reserveList.forEach((element) => {
471 if (element.liveId.toString() == item.objectId) { 497 if (element.liveId.toString() == item.objectId) {
472 - Logger.debug(TAG,'是否关注元数据:' +` ${JSON.stringify(element.subscribe)}`) 498 + Logger.debug(TAG, '是否关注元数据:' + ` ${JSON.stringify(element.subscribe)}`)
473 element.subscribe = !element.subscribe 499 element.subscribe = !element.subscribe
474 - Logger.debug(TAG,'是否关注元数据1:' +` ${JSON.stringify(element.subscribe)}`) 500 + Logger.debug(TAG, '是否关注元数据1:' + ` ${JSON.stringify(element.subscribe)}`)
475 if (element.subscribe) { 501 if (element.subscribe) {
476 this.reservedIds.push(element.liveId.toString()) 502 this.reservedIds.push(element.liveId.toString())
477 - }else { 503 + } else {
478 const num = this.reservedIds.indexOf(element.liveId.toString()) 504 const num = this.reservedIds.indexOf(element.liveId.toString())
479 if (num >= 0 && num < this.reservedIds.length) { 505 if (num >= 0 && num < this.reservedIds.length) {
480 this.reservedIds.splice(num, 1) 506 this.reservedIds.splice(num, 1)
@@ -490,13 +516,12 @@ struct ReserveMorePage { @@ -490,13 +516,12 @@ struct ReserveMorePage {
490 this.liveId = '' 516 this.liveId = ''
491 this.isLoadingAttention = false 517 this.isLoadingAttention = false
492 } 518 }
493 - }else { 519 + } else {
494 this.liveId = '' 520 this.liveId = ''
495 this.isLoadingAttention = false 521 this.isLoadingAttention = false
496 } 522 }
497 } 523 }
498 } 524 }
499 -  
500 getReserveDate(eventDateTimeString: string, type: number): string { 525 getReserveDate(eventDateTimeString: string, type: number): string {
501 // 解析事件的日期和时间 526 // 解析事件的日期和时间
502 const eventDateTime = new Date(eventDateTimeString); 527 const eventDateTime = new Date(eventDateTimeString);
@@ -509,17 +534,47 @@ struct ReserveMorePage { @@ -509,17 +534,47 @@ struct ReserveMorePage {
509 534
510 if (type === 1) { 535 if (type === 1) {
511 // 如果是今天 536 // 如果是今天
512 - if (eventDateTime.setHours(0,0,0,0) === currentDateTime.setHours(0,0,0,0)) {  
513 - return `今天`; 537 + if (eventDateTime.setHours(0, 0, 0, 0) === currentDateTime.setHours(0, 0, 0, 0)) {
  538 + const eventDate = eventDateTime.setHours(0, 0, 0, 0);
  539 + const currentDate = currentDateTime.setHours(0, 0, 0, 0);
  540 + if (eventDate === currentDate) {
  541 + return `今天`;
  542 + } else {
  543 + // 如果事件不在今天
  544 + // 将来的日期
  545 + const month = eventDateTime.getMonth() + 1;
  546 + const date = eventDateTime.getDate();
  547 + return `${month}月${date}日`;
  548 + }
514 } else { 549 } else {
515 - // 如果事件不在今天  
516 - const month = eventDateTime.getMonth() + 1; // 月份从0开始  
517 - const date = eventDateTime.getDate();  
518 - return `${month}月${date}日`; 550 + return `${eventTimeStr}`;
519 } 551 }
520 - } else {  
521 - return `${eventTimeStr}`;  
522 } 552 }
  553 +
  554 + // getReserveDate(eventDateTimeString: string, type: number): string {
  555 + // // 解析事件的日期和时间
  556 + // const eventDateTime = new Date(eventDateTimeString);
  557 + // const currentDateTime = new Date();
  558 + //
  559 + // // 截取事件时间的小时和分钟(假设事件时间是按照24小时制)
  560 + // const eventHour = eventDateTime.getHours();
  561 + // const eventMinutes = eventDateTime.getMinutes();
  562 + // const eventTimeStr = `${eventHour}:${eventMinutes.toString().padStart(2, '0')}开始`; // 格式化时间,确保分钟是两位数
  563 + //
  564 + // if (type === 1) {
  565 + // // 如果是今天
  566 + // if (eventDateTime.setHours(0,0,0,0) === currentDateTime.setHours(0,0,0,0)) {
  567 + // return `今天`;
  568 + // } else {
  569 + // // 如果事件不在今天
  570 + // const month = eventDateTime.getMonth() + 1; // 月份从0开始
  571 + // const date = eventDateTime.getDate();
  572 + // return `${month}月${date}日`;
  573 + // }
  574 + // } else {
  575 + // return `${eventTimeStr}`;
  576 + // }
  577 + // }
523 } 578 }
524 579
525 580
1 import { HttpUrlUtils, ResponseDTO } from 'wdNetwork'; 1 import { HttpUrlUtils, ResponseDTO } from 'wdNetwork';
2 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest'; 2 import { HttpRequest } from 'wdNetwork/src/main/ets/http/HttpRequest';
3 import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit'; 3 import { Logger, ToastUtils, EmitterEventId, EmitterUtils } from 'wdKit';
4 -import { LiveDetailsBean, ReserveBean, ReserveItemBean } from 'wdBean/Index'; 4 +import { LiveDetailsBean, ReserveBean, ReserveItemBean, joinPeopleNum } from 'wdBean/Index';
5 5
6 const TAG = 'LiveModel' 6 const TAG = 'LiveModel'
7 7
@@ -105,5 +105,34 @@ export class LiveModel { @@ -105,5 +105,34 @@ export class LiveModel {
105 }) 105 })
106 }) 106 })
107 } 107 }
  108 +
  109 + /**
  110 + * 查询直播参与人数
  111 + */
  112 + static getJoinPeopleNum(liveIdList: string) {
  113 + return new Promise<Array<joinPeopleNum>>((success, fail) => {
  114 + HttpRequest.get<ResponseDTO<Array<joinPeopleNum>>>(
  115 + HttpUrlUtils.getJoinPeopleNum() + `?liveIdList=${liveIdList}`,
  116 + ).then((data: ResponseDTO<Array<joinPeopleNum>>) => {
  117 + Logger.debug(TAG, 'getJoinPeopleNum:' + `${JSON.stringify(data)}`)
  118 + Logger.debug(TAG, 'liveIdList:' + liveIdList)
  119 + if (!data || !data.data) {
  120 + fail("数据为空")
  121 + return
  122 + }
  123 + if (data.code != 0) {
  124 + fail(data.message)
  125 + ToastUtils.shortToast(data.message)
  126 + return
  127 + }
  128 + success(data.data)
  129 + Logger.info('getJoinPeopleNum', JSON.stringify(data.data))
  130 + }, (error: Error) => {
  131 + fail(error.message)
  132 + Logger.debug(TAG + ":error ", JSON.stringify(error))
  133 + })
  134 + })
  135 + }
  136 +
108 } 137 }
109 138
@@ -409,6 +409,8 @@ export class PageHelper { @@ -409,6 +409,8 @@ export class PageHelper {
409 // 批查直播观看人数 409 // 批查直播观看人数
410 this.getLiveRoomDataInfo(compList) 410 this.getLiveRoomDataInfo(compList)
411 411
  412 + //
  413 +
412 414
413 // 测试数据 415 // 测试数据
414 // setTimeout(() => { 416 // setTimeout(() => {
@@ -177,6 +177,7 @@ @@ -177,6 +177,7 @@
177 { 177 {
178 "name": "color_848484", 178 "name": "color_848484",
179 "value": "#848484" 179 "value": "#848484"
180 - } 180 + },
  181 + {"name": "color_33A3A3A3","value": "#33A3A3A3"}
181 ] 182 ]
182 } 183 }