zhangfengjin

fix: 16717 功能缺陷-【uat】-双列流小卡-运营位标签增加参加人数内容

1 -import { CompDTO, ContentDTO } from 'wdBean'; 1 +import { CompDTO, ContentDTO, LiveRoomDataBean } from 'wdBean';
2 import { CommonConstants } from 'wdConstant/Index'; 2 import { CommonConstants } from 'wdConstant/Index';
3 -import { Logger } from 'wdKit/Index'; 3 +import { Logger, LazyDataSource } from 'wdKit/Index';
4 import { ProcessUtils } from 'wdRouter'; 4 import { ProcessUtils } from 'wdRouter';
5 import PageViewModel from '../../viewmodel/PageViewModel'; 5 import PageViewModel from '../../viewmodel/PageViewModel';
6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; 6 import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
@@ -8,7 +8,6 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg'; @@ -8,7 +8,6 @@ import { onlyWifiLoadImg } from '../../utils/lazyloadImg';
8 const TAG = 'Zh_Grid_Layout-02'; 8 const TAG = 'Zh_Grid_Layout-02';
9 const FULL_PARENT: string = '100%'; 9 const FULL_PARENT: string = '100%';
10 let listSize: number = 2; 10 let listSize: number = 2;
11 -  
12 /** 11 /**
13 * 双图卡 12 * 双图卡
14 * 枚举值Zh_Grid_Layout-02 13 * 枚举值Zh_Grid_Layout-02
@@ -20,6 +19,7 @@ export struct ZhGridLayout02 { @@ -20,6 +19,7 @@ export struct ZhGridLayout02 {
20 @State compDTO: CompDTO = {} as CompDTO 19 @State compDTO: CompDTO = {} as CompDTO
21 @State operDataList: ContentDTO[] = [] 20 @State operDataList: ContentDTO[] = []
22 @State loadImg: boolean = false; 21 @State loadImg: boolean = false;
  22 + @State liveRoomList: LiveRoomDataBean[] = []
23 23
24 async aboutToAppear(): Promise<void> { 24 async aboutToAppear(): Promise<void> {
25 Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle) 25 Logger.debug(TAG, 'aboutToAppear ' + this.compDTO.objectTitle)
@@ -27,6 +27,7 @@ export struct ZhGridLayout02 { @@ -27,6 +27,7 @@ export struct ZhGridLayout02 {
27 PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => { 27 PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {
28 this.operDataList = [] 28 this.operDataList = []
29 this.operDataList.push(...liveReviewDTO.list) 29 this.operDataList.push(...liveReviewDTO.list)
  30 + this.getLiveRoomDataInfo(this.operDataList)
30 }) 31 })
31 32
32 this.loadImg = await onlyWifiLoadImg(); 33 this.loadImg = await onlyWifiLoadImg();
@@ -100,11 +101,23 @@ export struct ZhGridLayout02 { @@ -100,11 +101,23 @@ export struct ZhGridLayout02 {
100 @Builder 101 @Builder
101 buildItemCard(item: ContentDTO) { 102 buildItemCard(item: ContentDTO) {
102 Column() { 103 Column() {
103 - Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')  
104 - .backgroundColor(0xf5f5f5)  
105 - .width('100%')  
106 - .height(95)  
107 - .borderRadius(4) 104 + Stack({alignContent: Alignment.BottomEnd}) {
  105 + Image(this.loadImg ? item.fullColumnImgUrls[0].url : '')
  106 + .backgroundColor(0xf5f5f5)
  107 + .width('100%')
  108 + .height(95)
  109 + .borderRadius(4)
  110 + if (this.getLiveRoomNumber(item).length > 0) {
  111 + Text(this.getLiveRoomNumber(item))
  112 + .fontSize('11vp')
  113 + .fontWeight(400)
  114 + .fontColor(Color.White)
  115 + .margin({
  116 + right: '5vp',
  117 + bottom:'5vp'
  118 + })
  119 + }
  120 + }
108 Text(item.newsTitle) 121 Text(item.newsTitle)
109 .margin({top:'5'}) 122 .margin({top:'5'})
110 .fontSize(13) 123 .fontSize(13)
@@ -117,11 +130,52 @@ export struct ZhGridLayout02 { @@ -117,11 +130,52 @@ export struct ZhGridLayout02 {
117 }) 130 })
118 } 131 }
119 132
  133 +
  134 + private getLiveDetailIds(list: ContentDTO[]): string {
  135 + let idList: string[] = []
  136 + list.forEach(item => {
  137 + idList.push(item.objectId)
  138 + });
  139 + return idList.join(',')
  140 + }
  141 + // 获取评论数
  142 + async getLiveRoomDataInfo(list: ContentDTO[]) {
  143 + const reserveIds = this.getLiveDetailIds(list)
  144 + PageViewModel.getLiveRoomBatchInfo(reserveIds).then((result) => {
  145 + if (result && result.length > 0) {
  146 + this.liveRoomList.push(...result)
  147 + }
  148 + }).catch(() =>{
  149 + })
  150 + }
  151 +
  152 + // 判断是否预约
  153 + getLiveRoomNumber(item: ContentDTO): string {
  154 + const objc = this.liveRoomList.find((element: LiveRoomDataBean) => {
  155 + return element.liveId.toString() == item.objectId
  156 + })
  157 + if (objc && objc.pv && objc.pv > 0) {
  158 + return this.computeShowNum(objc.pv)
  159 + }
  160 + return ''
  161 + }
  162 +
  163 + private computeShowNum(count: number): string {
  164 + if (count >= 10000) {
  165 + let num = ( count / 10000).toFixed(1)
  166 + if (Number(num.substring(num.length-1)) == 0) {
  167 + num = num.substring(0, num.length-2)
  168 + }
  169 + return num + '万人参加'
  170 + }
  171 + return `${count}人参加`
  172 + }
120 addItems() { 173 addItems() {
121 Logger.debug(TAG, 'addItems') 174 Logger.debug(TAG, 'addItems')
122 this.currentPage++ 175 this.currentPage++
123 PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => { 176 PageViewModel.getLiveReviewUrl(this.currentPage, this.pageSize).then((liveReviewDTO) => {
124 this.operDataList.push(...liveReviewDTO.list) 177 this.operDataList.push(...liveReviewDTO.list)
  178 + this.getLiveRoomDataInfo(this.operDataList)
125 Logger.debug(TAG, 'addItems after: ' + this.operDataList.length) 179 Logger.debug(TAG, 'addItems after: ' + this.operDataList.length)
126 }) 180 })
127 } 181 }