Showing
11 changed files
with
893 additions
and
13 deletions
| @@ -207,6 +207,14 @@ export class HttpUrlUtils { | @@ -207,6 +207,14 @@ export class HttpUrlUtils { | ||
| 207 | */ | 207 | */ |
| 208 | static readonly LIVE_ROOM_DATA_PATH: string = "/api/live-center-message/zh/a/live/room/number/all"; | 208 | static readonly LIVE_ROOM_DATA_PATH: string = "/api/live-center-message/zh/a/live/room/number/all"; |
| 209 | /** | 209 | /** |
| 210 | + * 直播详情-C端点赞接口 | ||
| 211 | + */ | ||
| 212 | + static readonly LIVE_ROOM_NUMBER_LIKE: string = "/api/live-center-message/zh/c/live/room/number/like"; | ||
| 213 | + /** | ||
| 214 | + * 直播详情-查询是否点赞接口 | ||
| 215 | + */ | ||
| 216 | + static readonly LIVE_LIKE: string = "/api/live-center-message/zh/a/live/like"; | ||
| 217 | + /** | ||
| 210 | * 直播详情-预约直播状态 | 218 | * 直播详情-预约直播状态 |
| 211 | */ | 219 | */ |
| 212 | static readonly LIVE_APPOINTMENT_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe/query"; | 220 | static readonly LIVE_APPOINTMENT_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe/query"; |
| @@ -633,11 +641,21 @@ export class HttpUrlUtils { | @@ -633,11 +641,21 @@ export class HttpUrlUtils { | ||
| 633 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_CHAT_LIST_PATH | 641 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_CHAT_LIST_PATH |
| 634 | return url | 642 | return url |
| 635 | } | 643 | } |
| 636 | - | 644 | + // 直播详情-直播数据 |
| 637 | static getLiveRoomDataUrl() { | 645 | static getLiveRoomDataUrl() { |
| 638 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_DATA_PATH | 646 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_DATA_PATH |
| 639 | return url | 647 | return url |
| 640 | } | 648 | } |
| 649 | + // 直播详情-C端点赞接口 | ||
| 650 | + static getLiveRoomNumberLikeUrl() { | ||
| 651 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_ROOM_NUMBER_LIKE | ||
| 652 | + return url | ||
| 653 | + } | ||
| 654 | + // 直播详情-查询是否点赞接口 | ||
| 655 | + static getLiveLikeUrl() { | ||
| 656 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_LIKE | ||
| 657 | + return url | ||
| 658 | + } | ||
| 641 | 659 | ||
| 642 | static getLiveAppointmentStatusUrl() { | 660 | static getLiveAppointmentStatusUrl() { |
| 643 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_STATUS_PATH | 661 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.LIVE_APPOINTMENT_STATUS_PATH |
| @@ -122,7 +122,7 @@ export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO | @@ -122,7 +122,7 @@ export { appStyleImagesDTO } from './src/main/ets/bean/content/appStyleImagesDTO | ||
| 122 | 122 | ||
| 123 | export { LiveRoomBean, LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoomBean'; | 123 | export { LiveRoomBean, LiveRoomItemBean } from './src/main/ets/bean/live/LiveRoomBean'; |
| 124 | 124 | ||
| 125 | -export { LiveRoomDataBean } from './src/main/ets/bean/live/LiveRoomDataBean'; | 125 | +export { LiveRoomDataBean, ValueType } from './src/main/ets/bean/live/LiveRoomDataBean'; |
| 126 | 126 | ||
| 127 | export { ReserveBean } from './src/main/ets/bean/live/ReserveBean'; | 127 | export { ReserveBean } from './src/main/ets/bean/live/ReserveBean'; |
| 128 | 128 |
| @@ -4,4 +4,6 @@ export interface LiveRoomDataBean { | @@ -4,4 +4,6 @@ export interface LiveRoomDataBean { | ||
| 4 | liveId: number, | 4 | liveId: number, |
| 5 | pv: number, | 5 | pv: number, |
| 6 | subscribeNum: number, | 6 | subscribeNum: number, |
| 7 | -} | ||
| 7 | +} | ||
| 8 | + | ||
| 9 | +export type ValueType = number | string | boolean | Array<number> | Array<string> | Array<boolean> | Uint8Array | object | bigint; |
| @@ -90,6 +90,8 @@ export { MultiPictureDetailItemComponent } from './src/main/ets/components/Multi | @@ -90,6 +90,8 @@ export { MultiPictureDetailItemComponent } from './src/main/ets/components/Multi | ||
| 90 | 90 | ||
| 91 | export { OperRowListView } from './src/main/ets/components/view/OperRowListView'; | 91 | export { OperRowListView } from './src/main/ets/components/view/OperRowListView'; |
| 92 | 92 | ||
| 93 | +export { LiveOperRowListView } from './src/main/ets/components/view/LiveOperRowListView'; | ||
| 94 | + | ||
| 93 | export { ImageDownloadComponent } from './src/main/ets/components/ImageDownloadComponent'; | 95 | export { ImageDownloadComponent } from './src/main/ets/components/ImageDownloadComponent'; |
| 94 | 96 | ||
| 95 | export { PageRepository } from './src/main/ets/repository/PageRepository'; | 97 | export { PageRepository } from './src/main/ets/repository/PageRepository'; |
| 1 | +import { DisplayUtils, NumberFormatterUtils } from 'wdKit/Index' | ||
| 2 | +import { SPHelper } from 'wdKit'; | ||
| 3 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 4 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 5 | +import measure from '@ohos.measure' | ||
| 6 | +import { | ||
| 7 | + ContentDetailRequest, | ||
| 8 | + postExecuteLikeParams, | ||
| 9 | +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 10 | +import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index'; | ||
| 11 | +import { | ||
| 12 | + ContentDetailDTO, | ||
| 13 | + contentListParams, | ||
| 14 | +} from 'wdBean'; | ||
| 15 | +import { PageRepository } from '../../repository/PageRepository'; | ||
| 16 | +import { LiveModel } from '../../viewmodel/LiveModel'; | ||
| 17 | +import { HttpUtils } from 'wdNetwork/Index'; | ||
| 18 | + | ||
| 19 | +const TAG = 'LiveLikeComponent'; | ||
| 20 | + | ||
| 21 | +interface ILikeStyleResp { | ||
| 22 | + url: Resource; | ||
| 23 | + name: string; | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +@Component | ||
| 27 | +export struct LiveLikeComponent { | ||
| 28 | + private LiveModel: LiveModel = new LiveModel() | ||
| 29 | + @Consume contentDetailData: ContentDetailDTO | ||
| 30 | + @Prop pageComponentType: number | ||
| 31 | + @State likesStyle: string = "love" // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福 | ||
| 32 | + @State likeStatus: boolean = false | ||
| 33 | + @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 | ||
| 34 | + @Prop @Watch('onDataUpdated') data: Record<string, string> | ||
| 35 | + enableBtn = true | ||
| 36 | + styleType: number = 1 //1: 白色背景(图文底部栏) 2: 黑色背景(图集底部栏) 3 透明背景 | ||
| 37 | + @State likeCount: number = 0 //点赞数 | ||
| 38 | + pageParam: ParamType = {} | ||
| 39 | + PageName: string = '' | ||
| 40 | + | ||
| 41 | + //上层传值 样例 | ||
| 42 | + // this.data['contentId'] = '30035444649' //必须 | ||
| 43 | + // this.data['userName'] = '人民日报网友2kD2xW' | ||
| 44 | + // this.data['contentType'] = '8' //必须 | ||
| 45 | + // this.data['title'] = '开创两校交流先河!克罗地亚教育代表团访问同济大学' | ||
| 46 | + // this.data['userHeaderUrl'] = "" | ||
| 47 | + // this.data['channelId'] = "2059" //必须 | ||
| 48 | + // this.data['status'] = "1" | ||
| 49 | + // 内容用 是否开启点赞 1是 0否; | ||
| 50 | + // this.contentDetailData.openLikes == 1 | ||
| 51 | + async aboutToAppear() { | ||
| 52 | + // 2:竖屏直播页 4:横屏直播页 | ||
| 53 | + // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福 | ||
| 54 | + this.likesStyle = this.contentDetailData?.liveInfo?.likesStyle | ||
| 55 | + this.openLikes = this.contentDetailData?.liveInfo?.likeEnable == 1 ? true : false | ||
| 56 | + console.log(TAG, 'this.contentDetailData', JSON.stringify(this.contentDetailData)) | ||
| 57 | + console.log(TAG, 'this.likesStyle', this.likesStyle) | ||
| 58 | + console.log(TAG, 'this.openLikes', this.openLikes) | ||
| 59 | + this.onDataUpdated() | ||
| 60 | + this.contentTrackingDict() | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + onDataUpdated() { | ||
| 64 | + console.log(TAG, '点赞点击') | ||
| 65 | + if (this.data) { | ||
| 66 | + if (this.data['contentType'] !== 'undefined') { | ||
| 67 | + //获取点赞状态 | ||
| 68 | + this.getLikeStatus() | ||
| 69 | + //获取点赞数 | ||
| 70 | + this.getLikeCount() | ||
| 71 | + } | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + contentTrackingDict(){ | ||
| 76 | + this.pageParam = { | ||
| 77 | + 'contentType': `${this.contentDetailData.newsType}`, | ||
| 78 | + 'contentId': `${this.contentDetailData.newsId}`, | ||
| 79 | + 'contentName': `${this.contentDetailData.newsTitle || ''}`, | ||
| 80 | + } | ||
| 81 | + if(this.contentDetailData.newsType == 2) { | ||
| 82 | + this.PageName = TrackConstants.PageName.Live_Detail // 直播 | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + build() { | ||
| 87 | + // 直播,点赞按钮底测有灰色圆角背景+右上点赞数量 | ||
| 88 | + this.likeCompStyle() | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 将点赞样式转换为icon | ||
| 93 | + */ | ||
| 94 | + transLikeStyle(): ILikeStyleResp { | ||
| 95 | + if (this.likesStyle === 'love' || this.likesStyle === 'thumb') { | ||
| 96 | + return { | ||
| 97 | + url: this.likeStatus ? $r(`app.media.ic_like_check`) : | ||
| 98 | + this.styleType == 1 ? $r('app.media.icon_like_default') : $r(`app.media.ic_like_uncheck`), | ||
| 99 | + name: '赞' | ||
| 100 | + } | ||
| 101 | + } else if (this.likesStyle === 'pray') { | ||
| 102 | + return { | ||
| 103 | + url: this.likeStatus ? $r(`app.media.ic_thub_check`) : $r(`app.media.ic_thub_uncheck`), | ||
| 104 | + name: '祈祷' | ||
| 105 | + } | ||
| 106 | + } else if (this.likesStyle === 'mourning') { | ||
| 107 | + return { | ||
| 108 | + url: this.likeStatus ? $r(`app.media.ic_candle_check`) : | ||
| 109 | + $r(`app.media.ic_candle_uncheck`), | ||
| 110 | + name: '默哀' | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + return { | ||
| 114 | + url: this.likeStatus ? $r(`app.media.ic_like_check`) : | ||
| 115 | + this.styleType == 1 ? $r('app.media.icon_like_default') : $r(`app.media.ic_like_uncheck`), | ||
| 116 | + name: '点赞' | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + @Builder | ||
| 121 | + likeCompStyle() { | ||
| 122 | + Stack({ alignContent: Alignment.Bottom }) { | ||
| 123 | + Column() { | ||
| 124 | + Image(this.transLikeStyle().url) | ||
| 125 | + .width(24) | ||
| 126 | + .height(24) | ||
| 127 | + .onClick(() => { | ||
| 128 | + this.clickButtonEvent() | ||
| 129 | + }) | ||
| 130 | + } | ||
| 131 | + .justifyContent(FlexAlign.Center) | ||
| 132 | + .width(36) | ||
| 133 | + .height(36) | ||
| 134 | + .borderRadius(18) | ||
| 135 | + .backgroundColor((this.pageComponentType === 4 || this.pageComponentType === 2) ? '#4D000000' : this.pageComponentType === 8 ? Color.Transparent : '#FFF5F5F5') | ||
| 136 | + Row() { | ||
| 137 | + Text(NumberFormatterUtils.formatNumberWithWan(this.likeCount || '')) | ||
| 138 | + .fontSize(8) | ||
| 139 | + .fontColor(Color.White) | ||
| 140 | + .padding({ left: 8, right: 2 }) | ||
| 141 | + } | ||
| 142 | + .height(12) | ||
| 143 | + .alignItems(VerticalAlign.Center) | ||
| 144 | + .position({ x: '100%', y: 10 }) | ||
| 145 | + .markAnchor({ x: '100%' }) | ||
| 146 | + .backgroundImage($r('app.media.ic_like_back')) | ||
| 147 | + .backgroundImageSize({height: 13}) | ||
| 148 | + .width(this.getMeasureText(NumberFormatterUtils.formatNumberWithWan(this.likeCount || '')) + | ||
| 149 | + 12) | ||
| 150 | + .visibility(this.likeCount > 0 ? Visibility.Visible : Visibility.Hidden) | ||
| 151 | + } | ||
| 152 | + .width(36) | ||
| 153 | + .height(42) | ||
| 154 | + .visibility(this.likesStyle == 'empty' || !this.openLikes ? Visibility.None : Visibility.Visible) | ||
| 155 | + | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + async clickButtonEvent() { | ||
| 159 | + console.log(TAG, '点赞点击') | ||
| 160 | + // 未登录,跳转登录 | ||
| 161 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 162 | + if (!user_id) { | ||
| 163 | + console.log(TAG, '点赞点击,未登录') | ||
| 164 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 165 | + return | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + // if (!this.enableBtn) { | ||
| 169 | + // return | ||
| 170 | + // } | ||
| 171 | + this.executeLike(this.likeStatus ? '0' : '1') | ||
| 172 | + | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + executeLike(status: string) { | ||
| 176 | + console.log(TAG, '点赞接口调用', status) | ||
| 177 | + | ||
| 178 | + const params: postExecuteLikeParams = { | ||
| 179 | + status: Number(status), | ||
| 180 | + contentId: this.data['contentId'], | ||
| 181 | + contentType: this.data['contentType'] | ||
| 182 | + } | ||
| 183 | + if(this.data['relType']) { | ||
| 184 | + params.relType = this.data['relType'] | ||
| 185 | + } | ||
| 186 | + if(this.data['contentRelId']) { | ||
| 187 | + params.contentRelId = this.data['contentRelId'] | ||
| 188 | + } | ||
| 189 | + if(this.data['channelId']) { | ||
| 190 | + params.channelId = this.data['channelId'] | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + console.log(TAG, "点赞 params", JSON.stringify(params)) | ||
| 194 | + ContentDetailRequest.postExecuteLike(params).then((data) => { | ||
| 195 | + | ||
| 196 | + console.log(TAG, '点赞接口调用成功', JSON.stringify(data)) | ||
| 197 | + | ||
| 198 | + // 直播点赞一直增加 | ||
| 199 | + if (this.contentDetailData.liveInfo) { | ||
| 200 | + this.likeStatus = true | ||
| 201 | + this.likeCount++ | ||
| 202 | + TrackingContent.like(true,this.PageName,this.PageName,this.pageParam) | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + if (this.likeCount <= 0) { | ||
| 206 | + this.likeCount = 0 | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + this.enableBtn = true | ||
| 210 | + }).catch(() => { | ||
| 211 | + this.enableBtn = true | ||
| 212 | + }) | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + async getLikeStatus() { | ||
| 216 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 217 | + if (!user_id) { | ||
| 218 | + console.log(TAG, '查询点赞状态,未登录') | ||
| 219 | + return | ||
| 220 | + } | ||
| 221 | + this.LiveModel.getLiveLike(this.data['contentId'], user_id, HttpUtils.getDeviceId()).then(data => { | ||
| 222 | + console.log(TAG, '查询点赞、收藏状态==', JSON.stringify(data)) | ||
| 223 | + this.likeStatus = data | ||
| 224 | + }).catch(() => { | ||
| 225 | + this.likeStatus = false | ||
| 226 | + }) | ||
| 227 | + } | ||
| 228 | + | ||
| 229 | + /** | ||
| 230 | + * 获取点赞数 | ||
| 231 | + */ | ||
| 232 | + getLikeCount() { | ||
| 233 | + // console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData)) | ||
| 234 | + const params: contentListParams = { | ||
| 235 | + contentList: [{ | ||
| 236 | + contentId: this.contentDetailData?.newsId + '', | ||
| 237 | + contentType: this.contentDetailData?.newsType, | ||
| 238 | + }] | ||
| 239 | + } | ||
| 240 | + console.log(TAG, '查询点赞、收藏数量', JSON.stringify(params)) | ||
| 241 | + PageRepository.getContentInteract(params).then(res => { | ||
| 242 | + console.log(TAG, '查询点赞、收藏数量 res', JSON.stringify(res)) | ||
| 243 | + if (res.data) { | ||
| 244 | + this.likeCount = Number(res.data[0]?.likeNum) | ||
| 245 | + } else { | ||
| 246 | + this.likeCount = 0 | ||
| 247 | + } | ||
| 248 | + }).catch(() => { | ||
| 249 | + this.likeCount = 0 | ||
| 250 | + }) | ||
| 251 | + } | ||
| 252 | + private getMeasureText(text: string) { | ||
| 253 | + let width = measure.measureText({ | ||
| 254 | + textContent: text, | ||
| 255 | + fontSize: 8, | ||
| 256 | + lineHeight: 12, | ||
| 257 | + constraintWidth: DisplayUtils.getDeviceWidth(), | ||
| 258 | + }) | ||
| 259 | + width = px2vp(width) | ||
| 260 | + return width | ||
| 261 | + } | ||
| 262 | +} |
| 1 | +import { NumberFormatterUtils, SPHelper } from 'wdKit'; | ||
| 2 | +import promptAction from '@ohos.promptAction'; | ||
| 3 | +import { | ||
| 4 | + batchLikeAndCollectResult, | ||
| 5 | + batchLikeAndCollectParams, | ||
| 6 | + ContentDetailDTO, | ||
| 7 | + contentListParams, | ||
| 8 | + InteractDataDTO, | ||
| 9 | + postExecuteCollectRecordParams | ||
| 10 | +} from 'wdBean'; | ||
| 11 | +import router from '@ohos.router'; | ||
| 12 | +import { MultiPictureDetailViewModel } from '../../viewmodel/MultiPictureDetailViewModel'; | ||
| 13 | +import { LiveLikeComponent } from './LiveLikeComponent'; | ||
| 14 | +import { CommentTabComponent, CommentIconComponent, } from '../comment/view/CommentTabComponent'; | ||
| 15 | +import { publishCommentModel } from '../comment/model/PublishCommentModel' | ||
| 16 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 17 | +import { PageRepository } from '../../repository/PageRepository'; | ||
| 18 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 19 | +import { WDShare } from 'wdShare/Index'; | ||
| 20 | +import { EmitterEventId, EmitterUtils } from 'wdKit/Index' | ||
| 21 | +import { ParamType, TrackConstants, TrackingContent } from 'wdTracking/Index'; | ||
| 22 | + | ||
| 23 | +const TAG = 'LiveOperRowListView'; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * 直播详情页底部通栏组件:包含返回、评论、点赞、收藏、分享 | ||
| 27 | + * 上层传值: | ||
| 28 | + * 1、(必传) contentDetailData---直播详情 | ||
| 29 | + * 2、(非必传) operationButtonList---组件展示条件, | ||
| 30 | + * ['comment', 'like', 'collect', 'share'],需要展示什么传什么 | ||
| 31 | + * comment--评论;like--点赞;collect--收藏;share--分享; | ||
| 32 | + * 注意:外层需注册 @Provide contentDetailData:contentDetailData = {} as contentDetailData | ||
| 33 | + * 传值示例: | ||
| 34 | + LiveOperRowListView({ | ||
| 35 | + | ||
| 36 | + contentDetailData: this.contentDetailData[0], | ||
| 37 | + operationButtonList: ['comment', 'like', 'collect', 'share'] | ||
| 38 | + }) | ||
| 39 | + */ | ||
| 40 | + | ||
| 41 | +@Preview | ||
| 42 | +@Component | ||
| 43 | +export struct LiveOperRowListView { | ||
| 44 | + private onBack: () => void = () => { | ||
| 45 | + } | ||
| 46 | + private onCommentFocus: () => void = () => { | ||
| 47 | + } | ||
| 48 | + private onCommentIconClick: () => void = () => { | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Provide inDialog: boolean = false | ||
| 52 | + | ||
| 53 | + @Prop @Watch('onDetailUpdated') contentDetailData: ContentDetailDTO // 稿件详情 | ||
| 54 | + /** | ||
| 55 | + * 用于区分页面类型,在哪个页面嵌套就传相应的值 | ||
| 56 | + * 2:竖屏直播页 4:横屏直播页 | ||
| 57 | + * 8: 评论弹框内 | ||
| 58 | + */ | ||
| 59 | + @Prop pageComponentType?: number = -1 | ||
| 60 | + @Prop showBackIcon?: boolean = true | ||
| 61 | + @Prop operationButtonList?: string[] = ['comment', 'collect', 'share'] // 组件展示条件 | ||
| 62 | + @State needLike: boolean = true | ||
| 63 | + @ObjectLink publishCommentModel: publishCommentModel | ||
| 64 | + @State styleType: number = -1 | ||
| 65 | + @State showCommentIcon: boolean = true // 评论图标 | ||
| 66 | + @State bgColor: ResourceColor = Color.White | ||
| 67 | + @State interactData: InteractDataDTO = {} as InteractDataDTO | ||
| 68 | + @State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | ||
| 69 | + @State likeBean: Record<string, string> = {} | ||
| 70 | + @State bottomSafeHeight: number = AppStorage.get<number>('bottomSafeHeight') || 0 | ||
| 71 | + @State dialogController: CustomDialogController | null = null; | ||
| 72 | + pageParam: ParamType = {} | ||
| 73 | + PageName: string = '' | ||
| 74 | + @State likesStyle: number | string = "love" // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福 | ||
| 75 | + @State openLikes: boolean = false // 是否可以点赞 1:可以 0:不可以 | ||
| 76 | + | ||
| 77 | + async aboutToAppear() { | ||
| 78 | + console.info(TAG, 'this.needLike', this.needLike) | ||
| 79 | + this.handleStyle() | ||
| 80 | + this.onDetailUpdated() | ||
| 81 | + //注册通知,来自别的组件的评论成功通知 | ||
| 82 | + EmitterUtils.receiveEvent(EmitterEventId.COMMENT_PUBLISH, (targetId?: string) => { | ||
| 83 | + if (targetId) { | ||
| 84 | + if (targetId == this.publishCommentModel.targetId) { | ||
| 85 | + //新增评论 | ||
| 86 | + this.queryContentInteractCount() | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + }) | ||
| 90 | + this.contentTrackingDict() | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + contentTrackingDict(){ | ||
| 94 | + this.pageParam = { | ||
| 95 | + 'contentType': `${this.contentDetailData.newsType}`, | ||
| 96 | + 'contentId': `${this.contentDetailData.newsId}`, | ||
| 97 | + 'contentName': `${this.contentDetailData.newsTitle || ''}`, | ||
| 98 | + } | ||
| 99 | + if(this.contentDetailData.newsType == 2) { | ||
| 100 | + this.PageName = TrackConstants.PageName.Live_Detail // 直播 | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + async onDetailUpdated() { | ||
| 105 | + console.info(TAG, 'this.styleType', this.styleType) | ||
| 106 | + this.handleStyle() | ||
| 107 | + if (!this.contentDetailData) { | ||
| 108 | + return | ||
| 109 | + } | ||
| 110 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 111 | + if (user_id) { | ||
| 112 | + this.getInteractDataStatus() | ||
| 113 | + } | ||
| 114 | + await this.queryContentInteractCount() | ||
| 115 | + // 点赞需要数据 | ||
| 116 | + this.likeBean['contentId'] = this.contentDetailData.newsId + '' | ||
| 117 | + if(this.contentDetailData.userInfo?.userName) { | ||
| 118 | + this.likeBean['userName'] = this.contentDetailData.userInfo?.userName + '' | ||
| 119 | + } | ||
| 120 | + this.likeBean['contentType'] = this.contentDetailData.newsType + '' | ||
| 121 | + if(this.contentDetailData.newsTitle) { | ||
| 122 | + this.likeBean['title'] = this.contentDetailData.newsTitle + '' | ||
| 123 | + } | ||
| 124 | + if(this.contentDetailData.userInfo?.headPhotoUrl) { | ||
| 125 | + this.likeBean['userHeaderUrl'] = this.contentDetailData.userInfo?.headPhotoUrl + '' | ||
| 126 | + } | ||
| 127 | + if(this.contentDetailData.reLInfo?.channelId) { | ||
| 128 | + this.likeBean['channelId'] = this.contentDetailData.reLInfo?.channelId + '' | ||
| 129 | + } | ||
| 130 | + if(this.contentDetailData?.reLInfo?.relType) { | ||
| 131 | + this.likeBean['relType'] = this.contentDetailData?.reLInfo?.relType + '' | ||
| 132 | + } | ||
| 133 | + if(this.contentDetailData?.reLInfo?.relId) { | ||
| 134 | + this.likeBean['contentRelId'] = this.contentDetailData?.reLInfo?.relId + '' | ||
| 135 | + } | ||
| 136 | + console.info(TAG, 'contentDetailData----', JSON.stringify(this.contentDetailData)) | ||
| 137 | + console.info(TAG, 'likeBean----', JSON.stringify(this.likeBean)) | ||
| 138 | + console.info(TAG, 'this.operationButtonList', JSON.stringify(this.operationButtonList)) | ||
| 139 | + // 评论需要数据 | ||
| 140 | + /* this.publishCommentModel.targetId = this.contentDetailData.newsId + '' | ||
| 141 | + this.publishCommentModel.targetRelId = this.contentDetailData.reLInfo?.relId + '' | ||
| 142 | + this.publishCommentModel.targetTitle = this.contentDetailData.newsTitle + '' | ||
| 143 | + this.publishCommentModel.targetRelType = this.contentDetailData.reLInfo?.relType + '' | ||
| 144 | + this.publishCommentModel.targetRelObjectId = this.contentDetailData.reLInfo?.relObjectId + '' | ||
| 145 | + this.publishCommentModel.keyArticle = this.contentDetailData.keyArticle + '' | ||
| 146 | + this.publishCommentModel.targetType = this.contentDetailData.newsType + ''*/ | ||
| 147 | + // 2:竖屏直播页 3:图集 4:横屏直播页 | ||
| 148 | + // 点赞样式 love爱心型 thumb点赞手势 mourning 蜡烛(默哀) pray 祈福 | ||
| 149 | + this.likesStyle = this.contentDetailData?.liveInfo?.likesStyle | ||
| 150 | + this.openLikes = this.contentDetailData?.liveInfo?.likeEnable == 1 ? true : false | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + build() { | ||
| 154 | + // 直播详情页 | ||
| 155 | + | ||
| 156 | + Column() { | ||
| 157 | + if(this.styleType != 3) { | ||
| 158 | + Divider().strokeWidth(1).color(this.styleType == 1 ? '#F5F5F5' : this.styleType == 2 ? '#262626' : 'rgba(0,0,0,0)') | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { | ||
| 162 | + Row() { | ||
| 163 | + Column() { | ||
| 164 | + Image(this.styleType == 1 ? $r('app.media.icon_arrow_left') : | ||
| 165 | + $r('app.media.icon_arrow_left_white')) | ||
| 166 | + .width(24) | ||
| 167 | + .height(24) | ||
| 168 | + .aspectRatio(1) | ||
| 169 | + .interpolation(ImageInterpolation.High) | ||
| 170 | + } | ||
| 171 | + .width(48) | ||
| 172 | + .hoverEffect(HoverEffect.Scale) | ||
| 173 | + .visibility(this.showBackIcon ? Visibility.Visible : Visibility.None) | ||
| 174 | + .onClick(() => { | ||
| 175 | + if (this.onBack) { | ||
| 176 | + this.onBack() | ||
| 177 | + } | ||
| 178 | + router.back(); | ||
| 179 | + }) | ||
| 180 | + | ||
| 181 | + | ||
| 182 | + if (this.contentDetailData?.newsId) { | ||
| 183 | + ForEach(this.operationButtonList, (item: string, index: number) => { | ||
| 184 | + if (item == 'comment') { | ||
| 185 | + this.builderComment() | ||
| 186 | + } else if (item == 'like' && this.needLike) { | ||
| 187 | + this.builderLike() | ||
| 188 | + } else if (item == 'collect') { | ||
| 189 | + this.builderCollect() | ||
| 190 | + } else if (item == 'share') { | ||
| 191 | + this.builderShare() | ||
| 192 | + } else { | ||
| 193 | + } | ||
| 194 | + }) | ||
| 195 | + } | ||
| 196 | + } | ||
| 197 | + .width('100%') | ||
| 198 | + .justifyContent(FlexAlign.Start) | ||
| 199 | + } | ||
| 200 | + .width('100%') | ||
| 201 | + .backgroundColor(this.bgColor) | ||
| 202 | + .padding({ | ||
| 203 | + top: 10, | ||
| 204 | + // bottom: 10 | ||
| 205 | + bottom: `${this.bottomSafeHeight}px` | ||
| 206 | + // bottom: 50 | ||
| 207 | + }) | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + /** | ||
| 213 | + * 评论组件 | ||
| 214 | + */ | ||
| 215 | + @Builder | ||
| 216 | + builderComment() { | ||
| 217 | + Column() { | ||
| 218 | + if (this.contentDetailData.openComment == 1 | ||
| 219 | + && this.contentDetailData.commentDisplay == 1 | ||
| 220 | + && this.publishCommentModel?.targetId) { | ||
| 221 | + CommentTabComponent({ | ||
| 222 | + publishCommentModel: this.publishCommentModel, | ||
| 223 | + contentDetail: this.contentDetailData, | ||
| 224 | + onCommentFocus: this.onCommentFocus, | ||
| 225 | + pageComponentType: this.pageComponentType, | ||
| 226 | + onLoad: (dialogController: CustomDialogController | null) => { | ||
| 227 | + this.dialogController = dialogController | ||
| 228 | + } | ||
| 229 | + }) | ||
| 230 | + } else { | ||
| 231 | + Blank() | ||
| 232 | + } | ||
| 233 | + } | ||
| 234 | + .layoutWeight(1) | ||
| 235 | + .margin({ | ||
| 236 | + right: this.pageComponentType === 1 ? 20 : 0, | ||
| 237 | + left: 16 | ||
| 238 | + }) | ||
| 239 | + | ||
| 240 | + if (this.showCommentIcon // 页面控制开关,直播传false | ||
| 241 | + && this.contentDetailData.openComment == 1 // 内容开关 | ||
| 242 | + && this.publishCommentModel?.targetId) { | ||
| 243 | + Column() { | ||
| 244 | + CommentIconComponent({ | ||
| 245 | + publishCommentModel: this.publishCommentModel, | ||
| 246 | + styleType: this.styleType, | ||
| 247 | + contentDetail: this.contentDetailData | ||
| 248 | + }) | ||
| 249 | + .onClick(() => { | ||
| 250 | + this.onCommentIconClick() | ||
| 251 | + | ||
| 252 | + console.log(JSON.stringify(this.dialogController?.open)) | ||
| 253 | + | ||
| 254 | + // 评论弹框内部嵌入 | ||
| 255 | + !this.showBackIcon && this.dialogController?.open() | ||
| 256 | + }) | ||
| 257 | + } | ||
| 258 | + .width(48) | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + /** | ||
| 264 | + * 点赞组件 | ||
| 265 | + */ | ||
| 266 | + @Builder | ||
| 267 | + builderLike() { | ||
| 268 | + Column() { | ||
| 269 | + LiveLikeComponent({ | ||
| 270 | + data: this.likeBean, | ||
| 271 | + styleType: this.styleType, | ||
| 272 | + pageComponentType: this.pageComponentType | ||
| 273 | + }) | ||
| 274 | + } | ||
| 275 | + .width(48) | ||
| 276 | + .visibility(this.likesStyle == 4 || this.likesStyle == 'empty' || !this.openLikes ? Visibility.None : Visibility.Visible) | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + /** | ||
| 280 | + * 收藏组件 | ||
| 281 | + */ | ||
| 282 | + @Builder | ||
| 283 | + builderCollect() { | ||
| 284 | + | ||
| 285 | + Stack() { | ||
| 286 | + Image(this.newsStatusOfUser?.collectStatus == 1 ? $r('app.media.ic_collect_check1') : | ||
| 287 | + this.styleType == 1 ? $r('app.media.iv_live_comment_collect_un') : | ||
| 288 | + $r('app.media.iv_live_comment_collect_un_white')) | ||
| 289 | + .width(24) | ||
| 290 | + .height(24) | ||
| 291 | + .interpolation(ImageInterpolation.High) | ||
| 292 | + /*Text(`${this.interactData?.collectNum}`) | ||
| 293 | + .fontSize(8) | ||
| 294 | + .fontColor(Color.White) | ||
| 295 | + .height(12) | ||
| 296 | + .margin({ left: 6 }) | ||
| 297 | + .backgroundImage($r('app.media.comment_icon_number')) | ||
| 298 | + .offset({ | ||
| 299 | + x: 12 | ||
| 300 | + })*/ | ||
| 301 | + } | ||
| 302 | + .height(36) | ||
| 303 | + .width(48) | ||
| 304 | + .borderRadius(18) | ||
| 305 | + .backgroundColor(this.pageComponentType === 2 ? '#4D000000' : Color.Transparent) | ||
| 306 | + .onClick(() => { | ||
| 307 | + this.toggleCollectStatus() | ||
| 308 | + }) | ||
| 309 | + | ||
| 310 | + } | ||
| 311 | + | ||
| 312 | + /** | ||
| 313 | + * 分享组件 | ||
| 314 | + */ | ||
| 315 | + @Builder | ||
| 316 | + builderShare() { | ||
| 317 | + Column() { | ||
| 318 | + Image(this.styleType == 1 ? $r('app.media.iv_live_comment_share') : | ||
| 319 | + $r('app.media.iv_live_comment_share_white')) | ||
| 320 | + .width(24) | ||
| 321 | + .height(24) | ||
| 322 | + .aspectRatio(1) | ||
| 323 | + .interpolation(ImageInterpolation.High) | ||
| 324 | + .onClick((event: ClickEvent) => { | ||
| 325 | + // ToastUtils.showToast('分享为公共方法,待开发', 1000); | ||
| 326 | + this.share() | ||
| 327 | + }) | ||
| 328 | + } | ||
| 329 | + .justifyContent(FlexAlign.Center) | ||
| 330 | + .height(36) | ||
| 331 | + .width(48) | ||
| 332 | + .borderRadius(18) | ||
| 333 | + .backgroundColor(this.pageComponentType === 2 ? '#4D000000' : Color.Transparent) | ||
| 334 | + } | ||
| 335 | + | ||
| 336 | + handleStyle() { | ||
| 337 | + if (this.styleType == 1) { | ||
| 338 | + this.bgColor = Color.White | ||
| 339 | + } else if (this.styleType == 2) { | ||
| 340 | + this.bgColor = Color.Black | ||
| 341 | + } else if (this.styleType == 3) { | ||
| 342 | + this.bgColor = Color.Transparent | ||
| 343 | + } | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + share() { | ||
| 347 | + WDShare.shareContent(this.contentDetailData) | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + // 已登录->查询用户对作品收藏状态 | ||
| 351 | + private async getInteractDataStatus() { | ||
| 352 | + try { | ||
| 353 | + const params: batchLikeAndCollectParams = { | ||
| 354 | + contentList: [ | ||
| 355 | + { | ||
| 356 | + contentId: this.contentDetailData?.newsId + '', | ||
| 357 | + contentType: this.contentDetailData?.newsType + '', | ||
| 358 | + contentRelId: this.contentDetailData?.reLInfo?.relId || '' + '', | ||
| 359 | + } | ||
| 360 | + ] | ||
| 361 | + } | ||
| 362 | + console.info(TAG, '查询用户对作品收藏1', JSON.stringify(params)) | ||
| 363 | + // console.info(TAG, '查询用户对作品收藏11', JSON.stringify(params)) | ||
| 364 | + let data = await MultiPictureDetailViewModel.getInteractDataStatus(params) | ||
| 365 | + console.info(TAG, '查询用户对作品收藏22', JSON.stringify(data)) | ||
| 366 | + this.newsStatusOfUser = data[0]; | ||
| 367 | + } catch (exception) { | ||
| 368 | + // console.error(TAG, JSON.stringify(exception)) | ||
| 369 | + } | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + /** | ||
| 373 | + * 收藏、取消收藏 | ||
| 374 | + */ | ||
| 375 | + async toggleCollectStatus() { | ||
| 376 | + // 未登录,跳转登录 | ||
| 377 | + const user_id = await SPHelper.default.get(SpConstants.USER_ID, '') | ||
| 378 | + console.log(TAG, '收藏点击,登录', user_id) | ||
| 379 | + if (!user_id) { | ||
| 380 | + console.log(TAG, '收藏点击,用户未登录') | ||
| 381 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 382 | + return | ||
| 383 | + } | ||
| 384 | + const params: postExecuteCollectRecordParams = { | ||
| 385 | + status: this.newsStatusOfUser?.collectStatus === 1 ? '0' : '1', | ||
| 386 | + contentList: [{ | ||
| 387 | + contentId: this.contentDetailData?.newsId + '', | ||
| 388 | + contentType: this.contentDetailData?.newsType + '', | ||
| 389 | + relType: this.contentDetailData?.reLInfo?.relType || '' + '', | ||
| 390 | + contentRelId: this.contentDetailData?.reLInfo?.relId || '' + '', | ||
| 391 | + }], | ||
| 392 | + | ||
| 393 | + } | ||
| 394 | + console.log(TAG, '收藏点击', JSON.stringify(params)) | ||
| 395 | + PageRepository.postExecuteCollectRecord(params).then(res => { | ||
| 396 | + if (this.newsStatusOfUser) { | ||
| 397 | + this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 | ||
| 398 | + if (this.newsStatusOfUser.collectStatus === 1) { | ||
| 399 | + promptAction.showToast({ message: '收藏成功' }) | ||
| 400 | + TrackingContent.collect(true,this.PageName,this.PageName,this.pageParam) | ||
| 401 | + } else { | ||
| 402 | + TrackingContent.collect(false,this.PageName,this.PageName,this.pageParam) | ||
| 403 | + } | ||
| 404 | + this.queryContentInteractCount() | ||
| 405 | + } | ||
| 406 | + console.log(TAG, '收藏点击 this.newsStatusOfUser', JSON.stringify(this.newsStatusOfUser)) | ||
| 407 | + }) | ||
| 408 | + | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + /** | ||
| 412 | + * 查询点赞、收藏数量 | ||
| 413 | + */ | ||
| 414 | + queryContentInteractCount() { | ||
| 415 | + // console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData)) | ||
| 416 | + const params: contentListParams = { | ||
| 417 | + contentList: [{ | ||
| 418 | + contentId: this.contentDetailData?.newsId + '', | ||
| 419 | + contentType: this.contentDetailData?.newsType, | ||
| 420 | + }] | ||
| 421 | + } | ||
| 422 | + console.log(TAG, '查询点赞、收藏数量', JSON.stringify(params)) | ||
| 423 | + PageRepository.getContentInteract(params).then(res => { | ||
| 424 | + console.log(TAG, '查询点赞、收藏数量 res', JSON.stringify(res)) | ||
| 425 | + if (res.data) { | ||
| 426 | + this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum) | ||
| 427 | + this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum) | ||
| 428 | + this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum) | ||
| 429 | + // 评论组件需要数据 | ||
| 430 | + if (Number.parseInt(this.interactData.commentNum) > | ||
| 431 | + Number.parseInt(this.publishCommentModel.totalCommentNumer)) { | ||
| 432 | + this.publishCommentModel.totalCommentNumer = this.interactData.commentNum + '' || '0' | ||
| 433 | + } | ||
| 434 | + } | ||
| 435 | + // console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res)) | ||
| 436 | + console.log(TAG, 'this.interactData44', JSON.stringify(this.interactData)) | ||
| 437 | + console.log(TAG, 'this.publishCommentModel', JSON.stringify(this.publishCommentModel)) | ||
| 438 | + }) | ||
| 439 | + } | ||
| 440 | +} |
| 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, joinPeopleNum } from 'wdBean/Index'; | 4 | +import { LiveDetailsBean, ReserveBean, ReserveItemBean, joinPeopleNum, LiveRoomDataBean, ValueType } from 'wdBean/Index'; |
| 5 | 5 | ||
| 6 | const TAG = 'LiveModel' | 6 | const TAG = 'LiveModel' |
| 7 | 7 | ||
| @@ -73,6 +73,88 @@ export class LiveModel { | @@ -73,6 +73,88 @@ export class LiveModel { | ||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | /** | 75 | /** |
| 76 | + * 获取直播数据 | ||
| 77 | + * @param liveId | ||
| 78 | + * @returns | ||
| 79 | + */ | ||
| 80 | + getLiveRoomData(liveId: string) { | ||
| 81 | + return new Promise<LiveRoomDataBean>((success, fail) => { | ||
| 82 | + HttpRequest.get<ResponseDTO<LiveRoomDataBean>>( | ||
| 83 | + HttpUrlUtils.getLiveRoomDataUrl() + `?liveId=${liveId}`, | ||
| 84 | + ).then((data: ResponseDTO<LiveRoomDataBean>) => { | ||
| 85 | + if (!data || !data.data) { | ||
| 86 | + fail("数据为空") | ||
| 87 | + return | ||
| 88 | + } | ||
| 89 | + if (data.code != 0) { | ||
| 90 | + fail(data.message) | ||
| 91 | + return | ||
| 92 | + } | ||
| 93 | + success(data.data) | ||
| 94 | + }, (error: Error) => { | ||
| 95 | + fail(error.message) | ||
| 96 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 97 | + }) | ||
| 98 | + }) | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * 直播详情-C端点赞接口 | ||
| 103 | + * @param liveId | ||
| 104 | + * @param number | ||
| 105 | + * @param deviceId | ||
| 106 | + * @returns | ||
| 107 | + */ | ||
| 108 | + getLiveRoomNumberLike(liveId: string, number: number, deviceId: string | number) { | ||
| 109 | + return new Promise<number>((success, fail) => { | ||
| 110 | + HttpRequest.get<ResponseDTO<number>>( | ||
| 111 | + HttpUrlUtils.getLiveRoomNumberLikeUrl() + `?liveId=${liveId}&number=${number}&deviceId=${deviceId}`, | ||
| 112 | + ).then((data: ResponseDTO<number>) => { | ||
| 113 | + if (!data || !data.data) { | ||
| 114 | + fail("数据为空") | ||
| 115 | + return | ||
| 116 | + } | ||
| 117 | + if (data.code != 0) { | ||
| 118 | + fail(data.message) | ||
| 119 | + return | ||
| 120 | + } | ||
| 121 | + success(data.data) | ||
| 122 | + }, (error: Error) => { | ||
| 123 | + fail(error.message) | ||
| 124 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 125 | + }) | ||
| 126 | + }) | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * 直播详情-查询是否点赞接口 | ||
| 131 | + * @param liveId | ||
| 132 | + * @param userId | ||
| 133 | + * @param deviceId | ||
| 134 | + * @returns | ||
| 135 | + */ | ||
| 136 | + getLiveLike(liveId: string, userId: ValueType, deviceId: string | number) { | ||
| 137 | + return new Promise<boolean>((success, fail) => { | ||
| 138 | + HttpRequest.get<ResponseDTO<boolean>>( | ||
| 139 | + HttpUrlUtils.getLiveLikeUrl() + `?liveId=${liveId}&userId=${userId}&deviceId=${deviceId}`, | ||
| 140 | + ).then((data: ResponseDTO<boolean>) => { | ||
| 141 | + if (!data || !data.data) { | ||
| 142 | + fail("数据为空") | ||
| 143 | + return | ||
| 144 | + } | ||
| 145 | + if (data.code != 0) { | ||
| 146 | + fail(data.message) | ||
| 147 | + return | ||
| 148 | + } | ||
| 149 | + success(data.data) | ||
| 150 | + }, (error: Error) => { | ||
| 151 | + fail(error.message) | ||
| 152 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 153 | + }) | ||
| 154 | + }) | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + /** | ||
| 76 | * 查询预约状态 | 158 | * 查询预约状态 |
| 77 | * | 159 | * |
| 78 | [{"relationId":"500002824823","liveId":"20000120522"},{"relationId":"500002845517","liveId":"20000120782"}] | 160 | [{"relationId":"500002824823","liveId":"20000120522"},{"relationId":"500002845517","liveId":"20000120782"}] |
| @@ -7,9 +7,8 @@ import mediaquery from '@ohos.mediaquery'; | @@ -7,9 +7,8 @@ import mediaquery from '@ohos.mediaquery'; | ||
| 7 | import { Logger, WindowModel } from 'wdKit/Index'; | 7 | import { Logger, WindowModel } from 'wdKit/Index'; |
| 8 | import { router, window } from '@kit.ArkUI'; | 8 | import { router, window } from '@kit.ArkUI'; |
| 9 | import { devicePLSensorManager } from 'wdDetailPlayApi/Index'; | 9 | import { devicePLSensorManager } from 'wdDetailPlayApi/Index'; |
| 10 | -import { LiveCommentComponent } from 'wdComponent/Index'; | 10 | +import { LiveCommentComponent, LiveOperRowListView } from 'wdComponent/Index'; |
| 11 | import { WDAliPlayerController, WDPlayerController } from 'wdPlayer/Index'; | 11 | import { WDAliPlayerController, WDPlayerController } from 'wdPlayer/Index'; |
| 12 | -import { OperRowListView } from 'wdComponent/src/main/ets/components/view/OperRowListView'; | ||
| 13 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'; | 12 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel'; |
| 14 | import { ResponseDTO } from 'wdNetwork/Index'; | 13 | import { ResponseDTO } from 'wdNetwork/Index'; |
| 15 | 14 | ||
| @@ -70,8 +69,8 @@ export struct DetailPlayLivePage { | @@ -70,8 +69,8 @@ export struct DetailPlayLivePage { | ||
| 70 | TabComponent({ tabs: this.tabs, changeToTab: this.changeToTab }) | 69 | TabComponent({ tabs: this.tabs, changeToTab: this.changeToTab }) |
| 71 | .layoutWeight(1) | 70 | .layoutWeight(1) |
| 72 | .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) | 71 | .visibility(this.displayDirection == DisplayDirection.VERTICAL ? Visibility.Visible : Visibility.None) |
| 73 | - OperRowListView({ | ||
| 74 | - componentType: 4, | 72 | + LiveOperRowListView({ |
| 73 | + pageComponentType: 4, // 4:横屏直播页 | ||
| 75 | operationButtonList: ['comment', 'collect', 'share', 'like'], | 74 | operationButtonList: ['comment', 'collect', 'share', 'like'], |
| 76 | styleType: 1, | 75 | styleType: 1, |
| 77 | contentDetailData: this.contentDetailData, | 76 | contentDetailData: this.contentDetailData, |
| 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 { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean } from 'wdBean/Index'; | 4 | +import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ReserveItemBean, ValueType } from 'wdBean/Index'; |
| 5 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index'; | 5 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index'; |
| 6 | 6 | ||
| 7 | const TAG = 'LiveModel' | 7 | const TAG = 'LiveModel' |
| @@ -151,6 +151,62 @@ export class LiveModel { | @@ -151,6 +151,62 @@ export class LiveModel { | ||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | /** | 153 | /** |
| 154 | + * 直播详情-C端点赞接口 | ||
| 155 | + * @param liveId | ||
| 156 | + * @param number | ||
| 157 | + * @param deviceId | ||
| 158 | + * @returns | ||
| 159 | + */ | ||
| 160 | + getLiveRoomNumberLike(liveId: string, number: number, deviceId: string | number) { | ||
| 161 | + return new Promise<number>((success, fail) => { | ||
| 162 | + HttpRequest.get<ResponseDTO<number>>( | ||
| 163 | + HttpUrlUtils.getLiveRoomNumberLikeUrl() + `?liveId=${liveId}&number=${number}&deviceId=${deviceId}`, | ||
| 164 | + ).then((data: ResponseDTO<number>) => { | ||
| 165 | + if (!data || !data.data) { | ||
| 166 | + fail("数据为空") | ||
| 167 | + return | ||
| 168 | + } | ||
| 169 | + if (data.code != 0) { | ||
| 170 | + fail(data.message) | ||
| 171 | + return | ||
| 172 | + } | ||
| 173 | + success(data.data) | ||
| 174 | + }, (error: Error) => { | ||
| 175 | + fail(error.message) | ||
| 176 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 177 | + }) | ||
| 178 | + }) | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + /** | ||
| 182 | + * 直播详情-查询是否点赞接口 | ||
| 183 | + * @param liveId | ||
| 184 | + * @param userId | ||
| 185 | + * @param deviceId | ||
| 186 | + * @returns | ||
| 187 | + */ | ||
| 188 | + getLiveLike(liveId: string, userId: ValueType, deviceId: string | number) { | ||
| 189 | + return new Promise<boolean>((success, fail) => { | ||
| 190 | + HttpRequest.get<ResponseDTO<boolean>>( | ||
| 191 | + HttpUrlUtils.getLiveLikeUrl() + `?liveId=${liveId}&userId=${userId}&deviceId=${deviceId}`, | ||
| 192 | + ).then((data: ResponseDTO<boolean>) => { | ||
| 193 | + if (!data || !data.data) { | ||
| 194 | + fail("数据为空") | ||
| 195 | + return | ||
| 196 | + } | ||
| 197 | + if (data.code != 0) { | ||
| 198 | + fail(data.message) | ||
| 199 | + return | ||
| 200 | + } | ||
| 201 | + success(data.data) | ||
| 202 | + }, (error: Error) => { | ||
| 203 | + fail(error.message) | ||
| 204 | + Logger.debug(TAG + ":error ", error.toString()) | ||
| 205 | + }) | ||
| 206 | + }) | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + /** | ||
| 154 | * 获取直播预约状态 | 210 | * 获取直播预约状态 |
| 155 | * @param relationId | 211 | * @param relationId |
| 156 | * @param liveId | 212 | * @param liveId |
| 1 | -import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean } from 'wdBean/Index' | 1 | +import { ContentDetailDTO, LiveDetailsBean, LiveRoomBean, LiveRoomDataBean, ValueType } from 'wdBean/Index' |
| 2 | 2 | ||
| 3 | import { ResponseDTO } from 'wdNetwork/Index' | 3 | import { ResponseDTO } from 'wdNetwork/Index' |
| 4 | import { LiveModel } from './LiveModel' | 4 | import { LiveModel } from './LiveModel' |
| @@ -68,6 +68,26 @@ export class LiveViewModel { | @@ -68,6 +68,26 @@ export class LiveViewModel { | ||
| 68 | }) | 68 | }) |
| 69 | }) | 69 | }) |
| 70 | } | 70 | } |
| 71 | + // 直播详情-C端点赞接口 | ||
| 72 | + getLiveRoomNumberLike(liveId: string, number: number, deviceId: string | number) { | ||
| 73 | + return new Promise<number>((success, fail) => { | ||
| 74 | + this.liveModel.getLiveRoomNumberLike(liveId, number, deviceId).then((data) => { | ||
| 75 | + success(data) | ||
| 76 | + }).catch((message: string) => { | ||
| 77 | + fail(message) | ||
| 78 | + }) | ||
| 79 | + }) | ||
| 80 | + } | ||
| 81 | + // 直播详情-查询是否点赞接口 | ||
| 82 | + getLiveLike(liveId: string, userId: ValueType, deviceId: string | number) { | ||
| 83 | + return new Promise<boolean>((success, fail) => { | ||
| 84 | + this.liveModel.getLiveLike(liveId, userId, deviceId).then((data) => { | ||
| 85 | + success(data) | ||
| 86 | + }).catch((message: string) => { | ||
| 87 | + fail(message) | ||
| 88 | + }) | ||
| 89 | + }) | ||
| 90 | + } | ||
| 71 | 91 | ||
| 72 | //直播预约状态查询 | 92 | //直播预约状态查询 |
| 73 | getLiveAppointmentStatus(relationId: string, liveId: string) { | 93 | getLiveAppointmentStatus(relationId: string, liveId: string) { |
| 1 | import { Action, ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean, LiveRoomItemBean } from 'wdBean/Index' | 1 | import { Action, ContentDetailDTO, LiveDetailsBean, LiveRoomDataBean, LiveRoomItemBean } from 'wdBean/Index' |
| 2 | import { LiveCommentComponent } from 'wdComponent/Index' | 2 | import { LiveCommentComponent } from 'wdComponent/Index' |
| 3 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel' | 3 | import { publishCommentModel } from 'wdComponent/src/main/ets/components/comment/model/PublishCommentModel' |
| 4 | -import { OperRowListView } from 'wdComponent/src/main/ets/components/view/OperRowListView' | 4 | +import { LiveOperRowListView } from 'wdComponent' |
| 5 | import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' | 5 | import PageModel from 'wdComponent/src/main/ets/viewmodel/PageModel' |
| 6 | import { DisplayDirection, SpConstants, ViewType } from 'wdConstant/Index' | 6 | import { DisplayDirection, SpConstants, ViewType } from 'wdConstant/Index' |
| 7 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' | 7 | import { ContentDetailRequest } from 'wdDetailPlayApi/Index' |
| @@ -113,9 +113,8 @@ export struct PlayerCommentComponent { | @@ -113,9 +113,8 @@ export struct PlayerCommentComponent { | ||
| 113 | .margin({ bottom: 20 }) | 113 | .margin({ bottom: 20 }) |
| 114 | 114 | ||
| 115 | // 收藏、分享、点赞是否需要根据字段显隐 | 115 | // 收藏、分享、点赞是否需要根据字段显隐 |
| 116 | - OperRowListView({ | 116 | + LiveOperRowListView({ |
| 117 | styleType: 3, | 117 | styleType: 3, |
| 118 | - componentType: 4, | ||
| 119 | pageComponentType: 2, // 竖屏直播页 | 118 | pageComponentType: 2, // 竖屏直播页 |
| 120 | operationButtonList: ['comment', 'collect', 'share', 'like'], | 119 | operationButtonList: ['comment', 'collect', 'share', 'like'], |
| 121 | contentDetailData: this.contentDetailData, | 120 | contentDetailData: this.contentDetailData, |
-
Please register or login to post a comment