Showing
11 changed files
with
736 additions
and
219 deletions
| @@ -41,13 +41,29 @@ export class HttpUrlUtils { | @@ -41,13 +41,29 @@ export class HttpUrlUtils { | ||
| 41 | /** | 41 | /** |
| 42 | * 批查接口,查询互动相关数据,如收藏数、评论数等 | 42 | * 批查接口,查询互动相关数据,如收藏数、评论数等 |
| 43 | */ | 43 | */ |
| 44 | - static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/v2/content/interactData"; | 44 | + static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData"; |
| 45 | // 多图(图集)详情页 | 45 | // 多图(图集)详情页 |
| 46 | /** | 46 | /** |
| 47 | * 批量查询内容当前用户点赞、收藏状态 | 47 | * 批量查询内容当前用户点赞、收藏状态 |
| 48 | */ | 48 | */ |
| 49 | static readonly INTERACT_DATA_STATUS: string = "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status"; | 49 | static readonly INTERACT_DATA_STATUS: string = "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status"; |
| 50 | /** | 50 | /** |
| 51 | + * 点赞、取消点赞 | ||
| 52 | + */ | ||
| 53 | + static readonly INTERACT_EXECUTELIKE: string = "/api/rmrb-interact/interact/zh/c/like/executeLike"; | ||
| 54 | + /** | ||
| 55 | + * 收藏、取消收藏 | ||
| 56 | + */ | ||
| 57 | + static readonly INTERACT_EXECUTECOLLECTRECORD: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord"; | ||
| 58 | + /** | ||
| 59 | + * 用户等级/积分-APP根据业务场景动态增减成长值(APP) | ||
| 60 | + */ | ||
| 61 | + static readonly USERPOINT_OPERATE: string = "/api/rmrb-user-point/auth/pointLevel/zh/operate"; | ||
| 62 | + /** | ||
| 63 | + * 评论发布 | ||
| 64 | + */ | ||
| 65 | + static readonly COMMENT_PUBLISH: string = "/api/rmrb-comment/comment/zh/c/publish"; | ||
| 66 | + /** | ||
| 51 | * 沉浸式視頻批量查詢20條數據 | 67 | * 沉浸式視頻批量查詢20條數據 |
| 52 | */ | 68 | */ |
| 53 | static readonly RECOMMEND_VIDEOLIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/videoList"; | 69 | static readonly RECOMMEND_VIDEOLIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/videoList"; |
| @@ -128,12 +144,10 @@ export class HttpUrlUtils { | @@ -128,12 +144,10 @@ export class HttpUrlUtils { | ||
| 128 | * 个人中心 我的关注列表 | 144 | * 个人中心 我的关注列表 |
| 129 | */ | 145 | */ |
| 130 | static readonly OTHER_USER_FOLLOW_LIST_DATA_PATH: string = "/api/rmrb-interact/interact/zh/c/userAttention/list"; | 146 | static readonly OTHER_USER_FOLLOW_LIST_DATA_PATH: string = "/api/rmrb-interact/interact/zh/c/userAttention/list"; |
| 131 | - | ||
| 132 | /** | 147 | /** |
| 133 | * 预约操作 | 148 | * 预约操作 |
| 134 | */ | 149 | */ |
| 135 | static readonly APPOINTMENT_OPERATION_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe"; | 150 | static readonly APPOINTMENT_OPERATION_STATUS_PATH: string = "/api/live-center-message/zh/c/live/subscribe"; |
| 136 | - | ||
| 137 | /** | 151 | /** |
| 138 | * 点赞操作 | 152 | * 点赞操作 |
| 139 | */ | 153 | */ |
| @@ -153,7 +167,7 @@ export class HttpUrlUtils { | @@ -153,7 +167,7 @@ export class HttpUrlUtils { | ||
| 153 | * */ | 167 | * */ |
| 154 | static readonly MORNING_EVENING_PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo"; | 168 | static readonly MORNING_EVENING_PAGE_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/pageInfo"; |
| 155 | static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; | 169 | static readonly MORNING_EVENING_COMP_INFO_PATH: string = "/api/rmrb-bff-display-zh/display/zh/c/compInfo"; |
| 156 | - private static hostUrl: string = HttpUrlUtils.HOST_PRODUCT; | 170 | + private static hostUrl: string = HttpUrlUtils.HOST_UAT; |
| 157 | private static userId = '' | 171 | private static userId = '' |
| 158 | private static userType = '' | 172 | private static userType = '' |
| 159 | private static token = '' | 173 | private static token = '' |
| @@ -169,8 +183,8 @@ export class HttpUrlUtils { | @@ -169,8 +183,8 @@ export class HttpUrlUtils { | ||
| 169 | headers.set('timestamp', HttpUrlUtils.getTimestamp()) | 183 | headers.set('timestamp', HttpUrlUtils.getTimestamp()) |
| 170 | headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken()) | 184 | headers.set('RMRB-X-TOKEN', HttpUrlUtils.getXToken()) |
| 171 | headers.set('device_id', HttpUrlUtils.getDeviceId()) | 185 | headers.set('device_id', HttpUrlUtils.getDeviceId()) |
| 172 | - if(HttpUrlUtils.getXToken()!=''){ | ||
| 173 | - headers.set('cookie', 'RMRB-X-TOKEN='+HttpUrlUtils.getXToken()) | 186 | + if (HttpUrlUtils.getXToken() != '') { |
| 187 | + headers.set('cookie', 'RMRB-X-TOKEN=' + HttpUrlUtils.getXToken()) | ||
| 174 | } | 188 | } |
| 175 | headers.set('build_version', HttpUrlUtils.getVersion()) | 189 | headers.set('build_version', HttpUrlUtils.getVersion()) |
| 176 | headers.set('adcode', HttpUrlUtils.getAdCode()) | 190 | headers.set('adcode', HttpUrlUtils.getAdCode()) |
| @@ -251,20 +265,20 @@ export class HttpUrlUtils { | @@ -251,20 +265,20 @@ export class HttpUrlUtils { | ||
| 251 | } | 265 | } |
| 252 | 266 | ||
| 253 | private static getXToken() { | 267 | private static getXToken() { |
| 254 | - if(StringUtils.isNotEmpty(HttpUrlUtils.token)){ | 268 | + if (StringUtils.isNotEmpty(HttpUrlUtils.token)) { |
| 255 | return HttpUrlUtils.token | 269 | return HttpUrlUtils.token |
| 256 | } | 270 | } |
| 257 | - HttpUrlUtils.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN,"") as string | ||
| 258 | - if(StringUtils.isNotEmpty(HttpUrlUtils.token)) { | ||
| 259 | - return HttpUrlUtils.token | 271 | + HttpUrlUtils.token = SPHelper.default.getSync(SpConstants.USER_JWT_TOKEN, "") as string |
| 272 | + if (StringUtils.isNotEmpty(HttpUrlUtils.token)) { | ||
| 273 | + return HttpUrlUtils.token | ||
| 260 | } | 274 | } |
| 261 | return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc'; | 275 | return 'eyJhbGciOiJIUzI1NiIsImtpZCI6ImQ4WkI2QkhxSEZrdjJ2U25BNlRwZEdKRjBHcjItVzBvS2FaYzdLOUUycmcifQ.eyJpc3MiOiJwZW9wbGVzLWRhaWx5LWZvdXJhIiwic3ViIjoicGVvcGxlcy1kYWlseS1mb3VyYSIsImV4cCI6MTcwMzY0OTYwNiwidXNlcklkIjo0NTk3NzYyOTc0NzQ5NDksInVzZXJWZXJzaW9uIjoiNDU5Nzc2Mjk3NDc0OTQ5XzIiLCJ1c2VyTmFtZSI6IkJ1bGlraWtpMTgxIiwidXNlclR5cGUiOjIsImNyZWF0b3JJZCI6NDI2NTM5MH0.jhQ9kylcm3FxWf0-lBMZuLkdtIQ6XpFnAi0AFZJNwfc'; |
| 262 | } | 276 | } |
| 263 | 277 | ||
| 264 | - static getRefreshToken() { | ||
| 265 | - let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN,"") | ||
| 266 | - if(StringUtils.isNotEmpty(refreshToken)) { | ||
| 267 | - return refreshToken as string; | 278 | + static getRefreshToken() { |
| 279 | + let refreshToken = SPHelper.default.getSync(SpConstants.USER_REFRESH_TOKEN, "") | ||
| 280 | + if (StringUtils.isNotEmpty(refreshToken)) { | ||
| 281 | + return refreshToken as string; | ||
| 268 | } | 282 | } |
| 269 | return ''; | 283 | return ''; |
| 270 | } | 284 | } |
| @@ -327,18 +341,18 @@ export class HttpUrlUtils { | @@ -327,18 +341,18 @@ export class HttpUrlUtils { | ||
| 327 | 341 | ||
| 328 | public static getUserId() { | 342 | public static getUserId() { |
| 329 | // TODO 对接登录 | 343 | // TODO 对接登录 |
| 330 | - if(StringUtils.isNotEmpty(HttpUrlUtils.userId)){ | 344 | + if (StringUtils.isNotEmpty(HttpUrlUtils.userId)) { |
| 331 | return HttpUrlUtils.userId | 345 | return HttpUrlUtils.userId |
| 332 | } | 346 | } |
| 333 | - HttpUrlUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID,"") as string | 347 | + HttpUrlUtils.userId = SPHelper.default.getSync(SpConstants.USER_ID, "") as string |
| 334 | return HttpUrlUtils.userId; | 348 | return HttpUrlUtils.userId; |
| 335 | } | 349 | } |
| 336 | 350 | ||
| 337 | - public static getUserType() { | ||
| 338 | - if(StringUtils.isNotEmpty(HttpUrlUtils.userType)){ | 351 | + public static getUserType() { |
| 352 | + if (StringUtils.isNotEmpty(HttpUrlUtils.userType)) { | ||
| 339 | return HttpUrlUtils.userType | 353 | return HttpUrlUtils.userType |
| 340 | } | 354 | } |
| 341 | - HttpUrlUtils.userType = SPHelper.default.getSync(SpConstants.USER_Type,"") as string | 355 | + HttpUrlUtils.userType = SPHelper.default.getSync(SpConstants.USER_Type, "") as string |
| 342 | return HttpUrlUtils.userType; | 356 | return HttpUrlUtils.userType; |
| 343 | } | 357 | } |
| 344 | 358 |
| @@ -13,7 +13,7 @@ export interface ContentDetailRequestParams { | @@ -13,7 +13,7 @@ export interface ContentDetailRequestParams { | ||
| 13 | relType: string | 13 | relType: string |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | -export interface recommentVideoListParame { | 16 | +export interface recommentVideoListParams { |
| 17 | pageSize: number; | 17 | pageSize: number; |
| 18 | refreshCnt: number; | 18 | refreshCnt: number; |
| 19 | } | 19 | } |
| @@ -27,6 +27,94 @@ export interface contentListParams { | @@ -27,6 +27,94 @@ export interface contentListParams { | ||
| 27 | contentList: contentListItem[]; | 27 | contentList: contentListItem[]; |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | +export interface IStatusContentList { | ||
| 31 | + contentId: string; | ||
| 32 | + | ||
| 33 | + // relType: string; | ||
| 34 | + contentType: string; | ||
| 35 | + // contentRelId: string; | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +export interface batchLikeAndCollectParams { | ||
| 39 | + // userType: number; | ||
| 40 | + // userId: string; | ||
| 41 | + contentList: IStatusContentList[] | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +export interface batchLikeAndCollectResult { | ||
| 45 | + collectStatus: number; | ||
| 46 | + contentType: string; | ||
| 47 | + likeStatus: string; | ||
| 48 | + relType: string; | ||
| 49 | + contentId: string; | ||
| 50 | + contentRelId: string; | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +export interface postBatchAttentionStatusParamsItem { | ||
| 54 | + creatorId: string; | ||
| 55 | +} | ||
| 56 | + | ||
| 57 | +export interface postBatchAttentionStatusParams { | ||
| 58 | + creatorIds: postBatchAttentionStatusParamsItem[] | ||
| 59 | +} | ||
| 60 | + | ||
| 61 | +export interface postBatchAttentionStatusResult { | ||
| 62 | + creatorId: string; | ||
| 63 | + status: string; | ||
| 64 | + userId: string; | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | + | ||
| 68 | +export interface postExecuteLikeParams { | ||
| 69 | + status: string; | ||
| 70 | + contentId: string; | ||
| 71 | + contentType: string; | ||
| 72 | + relType?: string; | ||
| 73 | + userName?: string; | ||
| 74 | + title?: string; | ||
| 75 | + contentRelId?: string; | ||
| 76 | + userHeaderUrl?: string; | ||
| 77 | + channelId?: string; | ||
| 78 | +} | ||
| 79 | + | ||
| 80 | +export interface postExecuteCollectRecordParamsItem { | ||
| 81 | + contentId: string; | ||
| 82 | + contentType: string; | ||
| 83 | + relType?: string; | ||
| 84 | + contentRelId?: string; | ||
| 85 | +} | ||
| 86 | + | ||
| 87 | +export interface postExecuteCollectRecordParams { | ||
| 88 | + status: string; | ||
| 89 | + contentList: postExecuteCollectRecordParamsItem[] | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +export interface postPointLevelOperateParams { | ||
| 93 | + operateType: number; | ||
| 94 | +} | ||
| 95 | + | ||
| 96 | +export interface postCommentPublishParams { | ||
| 97 | + targetId: string; | ||
| 98 | + keyArticle: string; | ||
| 99 | + commentPics: string; | ||
| 100 | + targetTitle: string; | ||
| 101 | + commentType: string; | ||
| 102 | + targetType: string; | ||
| 103 | + commentContent: string; | ||
| 104 | + parentId: string; | ||
| 105 | + rootCommentId: string; | ||
| 106 | +} | ||
| 107 | + | ||
| 108 | +export interface postInteractBrowsOperateParamsContent { | ||
| 109 | + browseTime: string; | ||
| 110 | + contentId: string; | ||
| 111 | + contentType: number; | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +export interface postInteractBrowsOperateParams { | ||
| 115 | + delStatus: number; | ||
| 116 | + contentList: postInteractBrowsOperateParamsContent[] | ||
| 117 | +} | ||
| 30 | 118 | ||
| 31 | export class ContentDetailRequest { | 119 | export class ContentDetailRequest { |
| 32 | static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> { | 120 | static getContentDetailDataMock(context: Context): Promise<ResponseDTO<ContentDetailDTO[]>> { |
| @@ -71,23 +159,23 @@ export class ContentDetailRequest { | @@ -71,23 +159,23 @@ export class ContentDetailRequest { | ||
| 71 | } | 159 | } |
| 72 | 160 | ||
| 73 | /** | 161 | /** |
| 74 | - * | 162 | + * 批量查询作品查询点赞、收藏状态 |
| 75 | * @returns | 163 | * @returns |
| 76 | */ | 164 | */ |
| 77 | - static postBatchLikeAndCollectStatus() { | 165 | + static postBatchLikeAndCollectStatus(params: batchLikeAndCollectParams): Promise<ResponseDTO<batchLikeAndCollectResult[]>> { |
| 78 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS | 166 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS |
| 79 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 167 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 80 | - return WDHttp.post(url, headers) | 168 | + return WDHttp.post0(url, params, headers) |
| 81 | } | 169 | } |
| 82 | 170 | ||
| 83 | /** | 171 | /** |
| 84 | - * | 172 | + * 批量查号主是否为用户关注 |
| 85 | * @returns | 173 | * @returns |
| 86 | */ | 174 | */ |
| 87 | - static postBatchAttentionStatus() { | 175 | + static postBatchAttentionStatus(params: postBatchAttentionStatusParams): Promise<ResponseDTO<postBatchAttentionStatusResult[]>> { |
| 88 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH | 176 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.FOLLOW_LIST_STATUS_DATA_PATH |
| 89 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 177 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 90 | - return WDHttp.post(url, headers) | 178 | + return WDHttp.post0(url, params, headers) |
| 91 | } | 179 | } |
| 92 | 180 | ||
| 93 | 181 | ||
| @@ -96,9 +184,60 @@ export class ContentDetailRequest { | @@ -96,9 +184,60 @@ export class ContentDetailRequest { | ||
| 96 | * @returns | 184 | * @returns |
| 97 | */ | 185 | */ |
| 98 | 186 | ||
| 99 | - static postRecommendVideoList(params: recommentVideoListParame): Promise<ResponseDTO<ContentDetailDTO[]>> { | 187 | + static postRecommendVideoList(params: recommentVideoListParams): Promise<ResponseDTO<ContentDetailDTO[]>> { |
| 100 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST | 188 | let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_VIDEOLIST |
| 101 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 189 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 102 | return WDHttp.post0(url, params, headers) | 190 | return WDHttp.post0(url, params, headers) |
| 103 | } | 191 | } |
| 192 | + | ||
| 193 | + /** | ||
| 194 | + *用户点赞、取消点赞 | ||
| 195 | + * @param params | ||
| 196 | + * @returns | ||
| 197 | + */ | ||
| 198 | + static postExecuteLike(params: postExecuteLikeParams): Promise<ResponseDTO> { | ||
| 199 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTELIKE | ||
| 200 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 201 | + return WDHttp.post0(url, params, headers) | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + /** | ||
| 205 | + *用户收藏、取消收藏 | ||
| 206 | + * @param params | ||
| 207 | + * @returns | ||
| 208 | + */ | ||
| 209 | + static postExecuteCollectRecord(params: postExecuteCollectRecordParams): Promise<ResponseDTO> { | ||
| 210 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_EXECUTECOLLECTRECORD | ||
| 211 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 212 | + return WDHttp.post0(url, params, headers) | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + /** | ||
| 216 | + *用户等级/积分-APP根据业务场景动态增减成长值(APP) | ||
| 217 | + * 操作类型:1阅读 2评论 3回复(积分任务同评论) 4分享 5点赞 6关注 7打开客户端 8上传头像 9打开推送开关 | ||
| 218 | + */ | ||
| 219 | + static postPointLevelOperate(params: postPointLevelOperateParams): Promise<ResponseDTO> { | ||
| 220 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.USERPOINT_OPERATE | ||
| 221 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 222 | + return WDHttp.post0(url, params, headers) | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + /** | ||
| 226 | + * 评论发布 | ||
| 227 | + */ | ||
| 228 | + static postCommentPublish(params: postCommentPublishParams): Promise<ResponseDTO> { | ||
| 229 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.COMMENT_PUBLISH | ||
| 230 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 231 | + return WDHttp.post0(url, params, headers) | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + | ||
| 235 | + /** | ||
| 236 | + * 浏览历史新增、删除接口 | ||
| 237 | + */ | ||
| 238 | + static postInteractBrowsOperate(params: postInteractBrowsOperateParams): Promise<ResponseDTO> { | ||
| 239 | + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE | ||
| 240 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 241 | + return WDHttp.post0(url, params, headers) | ||
| 242 | + } | ||
| 104 | } | 243 | } |
| 1 | -import router from '@ohos.router'; | ||
| 2 | import mediaquery from '@ohos.mediaquery'; | 1 | import mediaquery from '@ohos.mediaquery'; |
| 3 | -import window from '@ohos.window'; | ||
| 4 | -import { Action, ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean'; | ||
| 5 | -import { Logger, SPHelper, WindowModel } from 'wdKit'; | ||
| 6 | -import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer'; | ||
| 7 | -import { devicePLSensorManager } from 'wdDetailPlayApi'; | 2 | +import { ContentDetailDTO, InteractDataDTO } from 'wdBean'; |
| 3 | +import { WDPlayerController, WDPlayerRenderView } from 'wdPlayer'; | ||
| 4 | +import { ContentDetailRequest, devicePLSensorManager } from 'wdDetailPlayApi'; | ||
| 8 | import { PlayControlViewContainer } from '../view/PlayControlViewContainer'; | 5 | import { PlayControlViewContainer } from '../view/PlayControlViewContainer'; |
| 9 | import { PlayerDetailContainer } from '../view/PlayerDetailContainer'; | 6 | import { PlayerDetailContainer } from '../view/PlayerDetailContainer'; |
| 10 | -import { PlayViewModel } from '../viewmodel/PlayViewModel'; | ||
| 11 | import { DetailContainer } from '../view/DetailContainer'; | 7 | import { DetailContainer } from '../view/DetailContainer'; |
| 8 | +import { | ||
| 9 | + batchLikeAndCollectParams, | ||
| 10 | + batchLikeAndCollectResult, | ||
| 11 | + postBatchAttentionStatusParams, | ||
| 12 | + postInteractBrowsOperateParams | ||
| 13 | +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 14 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 15 | +import { DateTimeUtils } from 'wdKit/Index'; | ||
| 12 | 16 | ||
| 13 | const TAG = 'DetailPlayShortVideoPage'; | 17 | const TAG = 'DetailPlayShortVideoPage'; |
| 14 | 18 | ||
| @@ -18,74 +22,101 @@ const TAG = 'DetailPlayShortVideoPage'; | @@ -18,74 +22,101 @@ const TAG = 'DetailPlayShortVideoPage'; | ||
| 18 | 22 | ||
| 19 | @Component | 23 | @Component |
| 20 | export struct DetailPlayShortVideoPage { | 24 | export struct DetailPlayShortVideoPage { |
| 21 | - private contentId?: string = undefined | ||
| 22 | - private relId?: string = undefined | ||
| 23 | - private relType?: string = undefined | ||
| 24 | - private contentDetailData: ContentDetailDTO | undefined = undefined | ||
| 25 | - @Provide interactData: InteractDataDTO | undefined = undefined | 25 | + @Prop index: number = 0 |
| 26 | @Prop @Watch('currentIndexChange') currentIndex: number = 0 | 26 | @Prop @Watch('currentIndexChange') currentIndex: number = 0 |
| 27 | - private index: number = 0 | ||
| 28 | - private playerController: WDPlayerController = new WDPlayerController(); | ||
| 29 | - @Watch("urlChanged") @State url?: string = undefined | ||
| 30 | - @Watch('changeContinue') @Provide nextContId?: string = ''; | ||
| 31 | - @Watch('getPlayHistory') @Provide curContId?: string = undefined; | ||
| 32 | - @Watch("playVMChanged") @Provide playVM: PlayViewModel = new PlayViewModel(); | 27 | + @State playerController: WDPlayerController = new WDPlayerController(); |
| 28 | + @Provide contentDetailData: ContentDetailDTO | undefined = undefined | ||
| 29 | + @Provide interactData: InteractDataDTO | undefined = undefined | ||
| 33 | @Provide isFullScreen: boolean = false; | 30 | @Provide isFullScreen: boolean = false; |
| 34 | - @Provide canStart?: boolean = false; | ||
| 35 | - @Provide status: number = PlayerConstants.STATUS_START; | ||
| 36 | - @Provide userId: string = ''; | ||
| 37 | - @Provide newsSourceName?: string = '' | ||
| 38 | - @Provide newsTitle?: string = '' | ||
| 39 | - @Provide editorName?: string = '' | ||
| 40 | - @Provide rmhInfo?: RmhInfoDTO | null = null | ||
| 41 | - @Provide userInfo?: UserInfoDTO | null = null | ||
| 42 | - @Provide message?: string = '' | ||
| 43 | - @Provide newsSummary?: string = '' | ||
| 44 | @Provide progressVal: number = 0; | 31 | @Provide progressVal: number = 0; |
| 45 | @Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2 | 32 | @Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2 |
| 46 | - | ||
| 47 | - playVMChanged() { | ||
| 48 | - this.url = this.playVM.url | ||
| 49 | - this.newsSourceName = this.playVM.newsSourceName | ||
| 50 | - this.newsTitle = this.playVM.newsTitle | ||
| 51 | - this.editorName = this.playVM.editorName | ||
| 52 | - this.newsSummary = this.playVM.newsSummary | ||
| 53 | - this.videoLandScape = this.playVM.videoLandScape ?? 1 | ||
| 54 | - this.curContId = this.playVM.contentId | ||
| 55 | - this.nextContId = this.playVM.nextContId | ||
| 56 | - this.canStart = this.playVM.canStart; | ||
| 57 | - this.message = this.playVM.message | ||
| 58 | - this.rmhInfo = this.playVM.rmhInfo | ||
| 59 | - this.userInfo = this.playVM.userInfo | ||
| 60 | - } | 33 | + @Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 |
| 34 | + @Provide followStatus: string = '0' // 关注状态 | ||
| 61 | 35 | ||
| 62 | currentIndexChange() { | 36 | currentIndexChange() { |
| 63 | - console.log('currentIndexChange====', this.currentIndex) | ||
| 64 | if (this.currentIndex != this.index) { | 37 | if (this.currentIndex != this.index) { |
| 65 | this.playerController.pause() | 38 | this.playerController.pause() |
| 39 | + | ||
| 40 | + // if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) { | ||
| 41 | + // this.playerController.release() | ||
| 42 | + // } | ||
| 43 | + | ||
| 66 | } else { | 44 | } else { |
| 67 | - console.log('currentIndexChange====1', this.playerController) | ||
| 68 | - this.playerController.switchPlayOrPause() | 45 | + this.queryNewsInfoOfUser() |
| 46 | + console.log('currentIndex==== ', this.currentIndex) | ||
| 47 | + if (!this.playerController.getPlayer()) { | ||
| 48 | + this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl || ''); | ||
| 49 | + } else { | ||
| 50 | + this.playerController.play() | ||
| 51 | + } | ||
| 52 | + | ||
| 69 | } | 53 | } |
| 70 | } | 54 | } |
| 71 | 55 | ||
| 72 | - aboutToAppear() { | ||
| 73 | - console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData)) | 56 | + /** |
| 57 | + * 查询用户点赞、收藏、关注等状态 | ||
| 58 | + */ | ||
| 59 | + queryNewsInfoOfUser() { | ||
| 60 | + if (HttpUrlUtils.getUserId()) { | ||
| 61 | + const params: batchLikeAndCollectParams = { | ||
| 62 | + contentList: [ | ||
| 63 | + { | ||
| 64 | + contentId: this.contentDetailData?.newsId + '', | ||
| 65 | + contentType: this.contentDetailData?.newsType + '', | ||
| 66 | + } | ||
| 67 | + ] | ||
| 68 | + } | ||
| 69 | + // 已登录->查询用户对作品点赞、收藏状态 | ||
| 70 | + ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => { | ||
| 71 | + console.log('查询点赞、收藏状态==', JSON.stringify(res.data)) | ||
| 72 | + if (res.data) { | ||
| 73 | + this.newsStatusOfUser = res.data[0] | ||
| 74 | + } | ||
| 75 | + }) | ||
| 74 | 76 | ||
| 75 | - this.playVM.setContentDetailData(this.contentDetailData) | 77 | + const params1: postBatchAttentionStatusParams = { |
| 78 | + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] | ||
| 79 | + } | ||
| 80 | + // 已登录->批量查作品是否被号主关注 | ||
| 81 | + ContentDetailRequest.postBatchAttentionStatus(params1).then(res => { | ||
| 82 | + console.log('批量查号主是否为用户关注==', JSON.stringify(res.data)) | ||
| 83 | + if (res.data) { | ||
| 84 | + this.followStatus = res.data[0]?.status | ||
| 85 | + } | ||
| 86 | + }) | ||
| 76 | 87 | ||
| 77 | - let action: Action = router.getParams() as Action | ||
| 78 | - Logger.info(TAG, "action", JSON.stringify(action)) | ||
| 79 | - if (action) { | ||
| 80 | - this.contentId = action.params?.contentID | ||
| 81 | - if (action.params && action.params.extra) { | ||
| 82 | - this.relId = action.params.extra.relId | ||
| 83 | - this.relType = action.params.extra.relType | 88 | + // 记录浏览历史 |
| 89 | + const params2: postInteractBrowsOperateParams = { | ||
| 90 | + delStatus: 0, | ||
| 91 | + contentList: [{ | ||
| 92 | + browseTime: DateTimeUtils.getCurDate(DateTimeUtils.PATTERN_DATE_TIME_HYPHEN), | ||
| 93 | + contentId: this.contentDetailData?.newsId + '', | ||
| 94 | + contentType: this.contentDetailData?.newsType || 0, | ||
| 95 | + }] | ||
| 84 | } | 96 | } |
| 97 | + ContentDetailRequest.postInteractBrowsOperate(params2).then(res => { | ||
| 98 | + console.log('记录浏览历史==', JSON.stringify(res.data)) | ||
| 99 | + | ||
| 100 | + }) | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + aboutToAppear() { | ||
| 106 | + console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData)) | ||
| 107 | + this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape | ||
| 108 | + this.queryNewsInfoOfUser() | ||
| 109 | + this.playerController.onCanplay = () => { | ||
| 110 | + if (this.index == 0 || this.currentIndex === this.index) { | ||
| 111 | + this.playerController.play() | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + this.playerController.onTimeUpdate = (position, duration) => { | ||
| 116 | + this.progressVal = Math.floor(position * 100 / duration); | ||
| 85 | } | 117 | } |
| 86 | 118 | ||
| 87 | // 设置播放地址 | 119 | // 设置播放地址 |
| 88 | - // this.url = 'https://media.w3.org/2010/05/sintel/trailer.mp4' | ||
| 89 | let listener = mediaquery.matchMediaSync('(orientation: landscape)'); | 120 | let listener = mediaquery.matchMediaSync('(orientation: landscape)'); |
| 90 | listener.on("change", (mediaQueryResult) => { | 121 | listener.on("change", (mediaQueryResult) => { |
| 91 | if (mediaQueryResult.matches) { | 122 | if (mediaQueryResult.matches) { |
| @@ -95,29 +126,24 @@ export struct DetailPlayShortVideoPage { | @@ -95,29 +126,24 @@ export struct DetailPlayShortVideoPage { | ||
| 95 | this.isFullScreen = false | 126 | this.isFullScreen = false |
| 96 | console.log("横屏 no") | 127 | console.log("横屏 no") |
| 97 | } | 128 | } |
| 98 | - WindowModel.shared.setMainWindowFullScreen(this.isFullScreen) | 129 | + // WindowModel.shared.setMainWindowFullScreen(this.isFullScreen) |
| 99 | }) | 130 | }) |
| 100 | - console.error('111,', this.index, this.currentIndex) | ||
| 101 | - if (this.index == 0 && this.currentIndex === this.index) { | ||
| 102 | - setTimeout(() => { | ||
| 103 | - this.playerController.play() | ||
| 104 | - }, 2000) | ||
| 105 | 131 | ||
| 106 | - } | ||
| 107 | } | 132 | } |
| 108 | 133 | ||
| 109 | onPageShow() { | 134 | onPageShow() { |
| 110 | - WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | 135 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); |
| 111 | } | 136 | } |
| 112 | 137 | ||
| 113 | aboutToDisappear(): void { | 138 | aboutToDisappear(): void { |
| 114 | this.playerController?.pause(); | 139 | this.playerController?.pause(); |
| 140 | + // this.playerController.onCanplay = ()={} | ||
| 115 | } | 141 | } |
| 116 | 142 | ||
| 117 | onPageHide() { | 143 | onPageHide() { |
| 118 | - WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT); | 144 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT); |
| 119 | devicePLSensorManager.devicePLSensorOff(); | 145 | devicePLSensorManager.devicePLSensorOff(); |
| 120 | - this.status = PlayerConstants.STATUS_PAUSE; | 146 | + // this.status = PlayerConstants.STATUS_PAUSE; |
| 121 | this.playerController?.pause(); | 147 | this.playerController?.pause(); |
| 122 | } | 148 | } |
| 123 | 149 | ||
| @@ -127,10 +153,10 @@ export struct DetailPlayShortVideoPage { | @@ -127,10 +153,10 @@ export struct DetailPlayShortVideoPage { | ||
| 127 | WDPlayerRenderView({ | 153 | WDPlayerRenderView({ |
| 128 | playerController: this.playerController, | 154 | playerController: this.playerController, |
| 129 | onLoad: async () => { | 155 | onLoad: async () => { |
| 130 | - console.log('onload==', this.contentId, this.relId, this.relType) | ||
| 131 | - // this.playVM.playWithContentId(this.contentId ?? "846899373") | ||
| 132 | - this.playVM.playWithIds(this.contentId, | ||
| 133 | - this.relId, this.relType) | 156 | + console.log('onload==',) |
| 157 | + // if (this.index === 0) { | ||
| 158 | + this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl); | ||
| 159 | + // } | ||
| 134 | } | 160 | } |
| 135 | }) | 161 | }) |
| 136 | .height('100%') | 162 | .height('100%') |
| @@ -177,49 +203,6 @@ export struct DetailPlayShortVideoPage { | @@ -177,49 +203,6 @@ export struct DetailPlayShortVideoPage { | ||
| 177 | } | 203 | } |
| 178 | .height('100%') | 204 | .height('100%') |
| 179 | .width('100%') | 205 | .width('100%') |
| 180 | - | ||
| 181 | .backgroundColor(Color.Black) | 206 | .backgroundColor(Color.Black) |
| 182 | } | 207 | } |
| 183 | - | ||
| 184 | - // 续播判断 | ||
| 185 | - changeContinue() { | ||
| 186 | - if (this.nextContId) { | ||
| 187 | - this.playerController.continue = () => { | ||
| 188 | - this.playerController?.stop(); | ||
| 189 | - this.playVM.playWithContentId(this.nextContId ?? ''); | ||
| 190 | - } | ||
| 191 | - return; | ||
| 192 | - } | ||
| 193 | - this.playerController.continue = undefined; | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - urlChanged() { | ||
| 197 | - if (this.url) { | ||
| 198 | - console.log("url:" + this.url); | ||
| 199 | - this.status = PlayerConstants.STATUS_START; | ||
| 200 | - this.playerController.firstPlay(this.url); | ||
| 201 | - } | ||
| 202 | - } | ||
| 203 | - | ||
| 204 | - getPlayHistory() { | ||
| 205 | - SPHelper.default.get('playHistory', '').then((str) => { | ||
| 206 | - let result = str.toString(); | ||
| 207 | - let time = 0; | ||
| 208 | - if (result != null && result != "") { | ||
| 209 | - let playHistory: Record<string, Record<string, number>> = JSON.parse(result); | ||
| 210 | - let userData: Record<string, number> = {}; | ||
| 211 | - if (this.userId) { | ||
| 212 | - userData = playHistory[this.userId] ?? {}; | ||
| 213 | - } | ||
| 214 | - if (this.curContId) { | ||
| 215 | - time = userData?.[this.curContId] ?? 0; | ||
| 216 | - } | ||
| 217 | - } | ||
| 218 | - this.playerController?.setStartTime(time); | ||
| 219 | - }).catch((err: Error) => { | ||
| 220 | - // Error: Inner error. Error code 15500000 | ||
| 221 | - Logger.error(TAG, 'catch err:' + JSON.stringify(err)); | ||
| 222 | - this.playerController?.setStartTime(0); | ||
| 223 | - }); | ||
| 224 | - } | ||
| 225 | } | 208 | } |
sight_harmony/features/wdDetailPlayShortVideo/src/main/ets/pages/DetailPlayShortVideoPageCopy.ets
0 → 100644
| 1 | +// import router from '@ohos.router'; | ||
| 2 | +import mediaquery from '@ohos.mediaquery'; | ||
| 3 | +import window from '@ohos.window'; | ||
| 4 | +import { ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean'; | ||
| 5 | +import { Logger, SPHelper, WindowModel } from 'wdKit'; | ||
| 6 | +import { PlayerConstants, WDPlayerController, WDPlayerRenderView } from 'wdPlayer'; | ||
| 7 | +import { ContentDetailRequest, devicePLSensorManager } from 'wdDetailPlayApi'; | ||
| 8 | +import { PlayControlViewContainer } from '../view/PlayControlViewContainer'; | ||
| 9 | +import { PlayerDetailContainer } from '../view/PlayerDetailContainer'; | ||
| 10 | +// import { PlayViewModel } from '../viewmodel/PlayViewModel'; | ||
| 11 | +import { DetailContainer } from '../view/DetailContainer'; | ||
| 12 | +import { | ||
| 13 | + batchLikeAndCollectParams, | ||
| 14 | + batchLikeAndCollectResult, | ||
| 15 | + postBatchAttentionStatusParams | ||
| 16 | +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 17 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 18 | + | ||
| 19 | +const TAG = 'DetailPlayShortVideoPage'; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 详情&短视频播放页面 | ||
| 23 | + */ | ||
| 24 | + | ||
| 25 | +@Component | ||
| 26 | +export struct DetailPlayShortVideoPage { | ||
| 27 | + // private contentId?: string = undefined | ||
| 28 | + // private relId?: string = undefined | ||
| 29 | + // private relType?: string = undefined | ||
| 30 | + @Provide contentDetailData: ContentDetailDTO | undefined = undefined | ||
| 31 | + @Provide interactData: InteractDataDTO | undefined = undefined | ||
| 32 | + @Prop @Watch('currentIndexChange') currentIndex: number = 0 | ||
| 33 | + private index: number = 0 | ||
| 34 | + private playerController: WDPlayerController = new WDPlayerController(); | ||
| 35 | + // @Watch("urlChanged") @State url?: string = undefined | ||
| 36 | + // @Watch('changeContinue') @Provide nextContId?: string = ''; | ||
| 37 | + // @Watch('getPlayHistory') @Provide curContId?: string = undefined; | ||
| 38 | + // @Watch("playVMChanged") @Provide playVM: PlayViewModel = new PlayViewModel(); | ||
| 39 | + @Provide isFullScreen: boolean = false; | ||
| 40 | + // @Provide canStart?: boolean = false; | ||
| 41 | + // @Provide status: number = PlayerConstants.STATUS_START; | ||
| 42 | + // @Provide userId: string = ''; | ||
| 43 | + // @Provide newsSourceName?: string = '' | ||
| 44 | + // @Provide newsTitle?: string = '' | ||
| 45 | + // @Provide editorName?: string = '' | ||
| 46 | + // @Provide rmhInfo?: RmhInfoDTO | null = null | ||
| 47 | + // @Provide userInfo?: UserInfoDTO | null = null | ||
| 48 | + // @Provide message?: string = '' | ||
| 49 | + // @Provide newsSummary?: string = '' | ||
| 50 | + @Provide progressVal: number = 0; | ||
| 51 | + @Provide videoLandScape?: number = 1; // 视频朝向, 横屏视频:1;竖屏视频:2 | ||
| 52 | + @Provide newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态 | ||
| 53 | + @Provide followStatus: string = '0' // 关注状态 | ||
| 54 | + | ||
| 55 | + // playVMChanged() { | ||
| 56 | + // this.url = this.playVM.url | ||
| 57 | + // this.newsSourceName = this.playVM.newsSourceName | ||
| 58 | + // this.newsTitle = this.playVM.newsTitle | ||
| 59 | + // this.editorName = this.playVM.editorName | ||
| 60 | + // this.newsSummary = this.playVM.newsSummary | ||
| 61 | + // this.videoLandScape = this.playVM.videoLandScape ?? 1 | ||
| 62 | + // this.curContId = this.playVM.contentId | ||
| 63 | + // this.nextContId = this.playVM.nextContId | ||
| 64 | + // this.canStart = this.playVM.canStart; | ||
| 65 | + // this.message = this.playVM.message | ||
| 66 | + // this.rmhInfo = this.playVM.rmhInfo | ||
| 67 | + // this.userInfo = this.playVM.userInfo | ||
| 68 | + // console.error('rmhInfo', this.rmhInfo) | ||
| 69 | + // console.error('userInfo', this.userInfo) | ||
| 70 | + // } | ||
| 71 | + | ||
| 72 | + currentIndexChange() { | ||
| 73 | + if (this.currentIndex != this.index) { | ||
| 74 | + this.playerController.pause() | ||
| 75 | + | ||
| 76 | + if (this.index < this.currentIndex - 5 && this.playerController.getPlayer()) { | ||
| 77 | + this.playerController.release() | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + } else { | ||
| 81 | + console.log('currentIndexChange====1', this.currentIndex) | ||
| 82 | + this.playerController.play() | ||
| 83 | + this.queryNewsInfoOfUser() | ||
| 84 | + | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 查询用户点赞、收藏、关注等状态 | ||
| 90 | + */ | ||
| 91 | + queryNewsInfoOfUser() { | ||
| 92 | + if (HttpUrlUtils.getUserId()) { | ||
| 93 | + const params: batchLikeAndCollectParams = { | ||
| 94 | + contentList: [ | ||
| 95 | + { | ||
| 96 | + contentId: this.contentDetailData?.newsId + '', | ||
| 97 | + contentType: this.contentDetailData?.newsType + '', | ||
| 98 | + } | ||
| 99 | + ] | ||
| 100 | + } | ||
| 101 | + // 已登录->查询用户对作品点赞、收藏状态 | ||
| 102 | + ContentDetailRequest.postBatchLikeAndCollectStatus(params).then(res => { | ||
| 103 | + console.log('查询点赞、收藏状态==', JSON.stringify(res.data)) | ||
| 104 | + if (res.data) { | ||
| 105 | + this.newsStatusOfUser = res.data[0] | ||
| 106 | + } | ||
| 107 | + }) | ||
| 108 | + | ||
| 109 | + const params1: postBatchAttentionStatusParams = { | ||
| 110 | + creatorIds: [{ creatorId: this.contentDetailData?.rmhInfo?.rmhId ?? '' }] | ||
| 111 | + } | ||
| 112 | + // 已登录->批量查作品是否被号主关注 | ||
| 113 | + ContentDetailRequest.postBatchAttentionStatus(params1).then(res => { | ||
| 114 | + console.log('批量查号主是否为用户关注==', JSON.stringify(res.data)) | ||
| 115 | + if (res.data) { | ||
| 116 | + this.followStatus = res.data[0]?.status | ||
| 117 | + } | ||
| 118 | + }) | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + aboutToAppear() { | ||
| 123 | + console.log('开始设置setContentDetailData', JSON.stringify(this.contentDetailData)) | ||
| 124 | + | ||
| 125 | + // this.playVM.setContentDetailData(this.contentDetailData) | ||
| 126 | + | ||
| 127 | + // this.playVMChanged() | ||
| 128 | + this.queryNewsInfoOfUser() | ||
| 129 | + this.playerController.onCanplay = () => { | ||
| 130 | + if (this.index == 0 || this.currentIndex === this.index) { | ||
| 131 | + this.videoLandScape = this.contentDetailData?.videoInfo[0]?.videoLandScape | ||
| 132 | + this.playerController.firstPlay(this.contentDetailData?.videoInfo[0]?.videoUrl); | ||
| 133 | + this.playerController.play() | ||
| 134 | + } | ||
| 135 | + } | ||
| 136 | + | ||
| 137 | + // 设置播放地址 | ||
| 138 | + // this.url = 'https://media.w3.org/2010/05/sintel/trailer.mp4' | ||
| 139 | + let listener = mediaquery.matchMediaSync('(orientation: landscape)'); | ||
| 140 | + listener.on("change", (mediaQueryResult) => { | ||
| 141 | + if (mediaQueryResult.matches) { | ||
| 142 | + console.log("横屏 yes") | ||
| 143 | + this.isFullScreen = true | ||
| 144 | + } else { | ||
| 145 | + this.isFullScreen = false | ||
| 146 | + console.log("横屏 no") | ||
| 147 | + } | ||
| 148 | + // WindowModel.shared.setMainWindowFullScreen(this.isFullScreen) | ||
| 149 | + }) | ||
| 150 | + | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + onPageShow() { | ||
| 154 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.AUTO_ROTATION_RESTRICTED); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + aboutToDisappear(): void { | ||
| 158 | + this.playerController?.pause(); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + onPageHide() { | ||
| 162 | + // WindowModel.shared.setPreferredOrientation(window.Orientation.PORTRAIT); | ||
| 163 | + devicePLSensorManager.devicePLSensorOff(); | ||
| 164 | + // this.status = PlayerConstants.STATUS_PAUSE; | ||
| 165 | + this.playerController?.pause(); | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + @Builder | ||
| 169 | + playerViewContainerBuilder() { | ||
| 170 | + // 播放窗口 | ||
| 171 | + WDPlayerRenderView({ | ||
| 172 | + playerController: this.playerController, | ||
| 173 | + onLoad: async () => { | ||
| 174 | + console.log('onload==', this.contentId, this.relId, this.relType) | ||
| 175 | + | ||
| 176 | + } | ||
| 177 | + }) | ||
| 178 | + .height('100%') | ||
| 179 | + .width('100%') | ||
| 180 | + .onClick(() => { | ||
| 181 | + console.error('WDPlayerRenderView=== onClick') | ||
| 182 | + this.playerController?.switchPlayOrPause(); | ||
| 183 | + }) | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + @Builder | ||
| 187 | + playControlViewContainerBuilder() { | ||
| 188 | + // 播放窗口控制bar | ||
| 189 | + PlayControlViewContainer({ | ||
| 190 | + playerController: this.playerController | ||
| 191 | + }) | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + @Builder | ||
| 195 | + detailContainerBuilder() { | ||
| 196 | + // DetailTabBarPageComponent({ pageId: this.pageId }).backgroundColor(Color.Black) | ||
| 197 | + DetailContainer({ | ||
| 198 | + playerController: this.playerController | ||
| 199 | + }) | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + build() { | ||
| 203 | + Row() { | ||
| 204 | + PlayerDetailContainer({ | ||
| 205 | + playerView: () => { | ||
| 206 | + this.playerViewContainerBuilder() | ||
| 207 | + }, playControlView: () => { | ||
| 208 | + // this.playControlViewContainerBuilder() | ||
| 209 | + }, detailView: () => { | ||
| 210 | + this.detailContainerBuilder() | ||
| 211 | + } | ||
| 212 | + }) | ||
| 213 | + .height('100%') | ||
| 214 | + .width('100%') | ||
| 215 | + .onClick(() => { | ||
| 216 | + console.error('PlayerDetailContainer=== onClick') | ||
| 217 | + this.playerController?.switchPlayOrPause(); | ||
| 218 | + }) | ||
| 219 | + } | ||
| 220 | + .height('100%') | ||
| 221 | + .width('100%') | ||
| 222 | + | ||
| 223 | + .backgroundColor(Color.Black) | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + // 续播判断 | ||
| 227 | + // changeContinue() { | ||
| 228 | + // if (this.nextContId) { | ||
| 229 | + // this.playerController.continue = () => { | ||
| 230 | + // this.playerController?.stop(); | ||
| 231 | + // // this.playVM.playWithContentId(this.nextContId ?? ''); | ||
| 232 | + // } | ||
| 233 | + // return; | ||
| 234 | + // } | ||
| 235 | + // this.playerController.continue = undefined; | ||
| 236 | + // } | ||
| 237 | + | ||
| 238 | + // urlChanged() { | ||
| 239 | + // console.error('urlChanged===') | ||
| 240 | + // if (this.url) { | ||
| 241 | + // this.status = PlayerConstants.STATUS_START; | ||
| 242 | + // this.playerController.firstPlay(this.url); | ||
| 243 | + // } | ||
| 244 | + // } | ||
| 245 | + | ||
| 246 | + // getPlayHistory() { | ||
| 247 | + // SPHelper.default.get('playHistory', '').then((str) => { | ||
| 248 | + // let result = str.toString(); | ||
| 249 | + // let time = 0; | ||
| 250 | + // if (result != null && result != "") { | ||
| 251 | + // let playHistory: Record<string, Record<string, number>> = JSON.parse(result); | ||
| 252 | + // let userData: Record<string, number> = {}; | ||
| 253 | + // if (this.userId) { | ||
| 254 | + // userData = playHistory[this.userId] ?? {}; | ||
| 255 | + // } | ||
| 256 | + // if (this.curContId) { | ||
| 257 | + // time = userData?.[this.curContId] ?? 0; | ||
| 258 | + // } | ||
| 259 | + // } | ||
| 260 | + // this.playerController?.setStartTime(time); | ||
| 261 | + // }).catch((err: Error) => { | ||
| 262 | + // // Error: Inner error. Error code 15500000 | ||
| 263 | + // Logger.error(TAG, 'catch err:' + JSON.stringify(err)); | ||
| 264 | + // this.playerController?.setStartTime(0); | ||
| 265 | + // }); | ||
| 266 | + // } | ||
| 267 | +} |
| @@ -21,7 +21,6 @@ export struct DetailVideoListPage { | @@ -21,7 +21,6 @@ export struct DetailVideoListPage { | ||
| 21 | @State interactDataList: InteractDataDTO[] = [] | 21 | @State interactDataList: InteractDataDTO[] = [] |
| 22 | 22 | ||
| 23 | async aboutToAppear(): Promise<void> { | 23 | async aboutToAppear(): Promise<void> { |
| 24 | - console.error('=================',) | ||
| 25 | let data: ContentDetailDTO[] = [] | 24 | let data: ContentDetailDTO[] = [] |
| 26 | let action: Action = router.getParams() as Action | 25 | let action: Action = router.getParams() as Action |
| 27 | if (action) { | 26 | if (action) { |
| @@ -37,29 +36,31 @@ export struct DetailVideoListPage { | @@ -37,29 +36,31 @@ export struct DetailVideoListPage { | ||
| 37 | }).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => { | 36 | }).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => { |
| 38 | console.error('resDTO==', JSON.stringify(resDTO.data)) | 37 | console.error('resDTO==', JSON.stringify(resDTO.data)) |
| 39 | if (resDTO.data) { | 38 | if (resDTO.data) { |
| 40 | - data.push(resDTO.data[0]) | 39 | + this.data.push(resDTO.data[0]) |
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | }) | 42 | }) |
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | - await ContentDetailRequest.postRecommendVideoList({ | ||
| 47 | - pageSize: 10, | ||
| 48 | - refreshCnt: 1 | ||
| 49 | - }).then(res => { | ||
| 50 | - if (res.data) { | ||
| 51 | - data = data.concat(res.data) | ||
| 52 | - } | ||
| 53 | - console.log('res1===', JSON.stringify(res)) | ||
| 54 | - console.log('res==' + this.data) | ||
| 55 | - }) | 45 | + await this.queryVideoList() |
| 46 | + | ||
| 47 | + // await ContentDetailRequest.postRecommendVideoList({ | ||
| 48 | + // pageSize: 5, | ||
| 49 | + // refreshCnt: 1 | ||
| 50 | + // }).then(res => { | ||
| 51 | + // if (res.data) { | ||
| 52 | + // data = data.concat(res.data) | ||
| 53 | + // } | ||
| 54 | + // console.log('res1===', JSON.stringify(res)) | ||
| 55 | + // console.log('res==' + this.data) | ||
| 56 | + // }) | ||
| 56 | 57 | ||
| 57 | 58 | ||
| 58 | - if (data.length > 0) { | 59 | + if (this.data.length > 0) { |
| 59 | const params: contentListParams = { | 60 | const params: contentListParams = { |
| 60 | contentList: [] | 61 | contentList: [] |
| 61 | } | 62 | } |
| 62 | - data.map(item => { | 63 | + this.data.map(item => { |
| 63 | params.contentList.push({ | 64 | params.contentList.push({ |
| 64 | contentId: item.newsId + '', | 65 | contentId: item.newsId + '', |
| 65 | contentType: item.newsType | 66 | contentType: item.newsType |
| @@ -76,12 +77,27 @@ export struct DetailVideoListPage { | @@ -76,12 +77,27 @@ export struct DetailVideoListPage { | ||
| 76 | 77 | ||
| 77 | } | 78 | } |
| 78 | 79 | ||
| 79 | - this.data = data | 80 | + // this.data = data |
| 80 | console.error('aboutToAppear===', this.data.length) | 81 | console.error('aboutToAppear===', this.data.length) |
| 81 | 82 | ||
| 82 | 83 | ||
| 83 | } | 84 | } |
| 84 | 85 | ||
| 86 | + async queryVideoList() { | ||
| 87 | + await ContentDetailRequest.postRecommendVideoList({ | ||
| 88 | + pageSize: 5, | ||
| 89 | + refreshCnt: 1 | ||
| 90 | + }).then(res => { | ||
| 91 | + if (res.data) { | ||
| 92 | + this.data = this.data.concat(res.data) | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + | ||
| 96 | + console.log('queryVideoList===', JSON.stringify(this.data)) | ||
| 97 | + }) | ||
| 98 | + | ||
| 99 | + } | ||
| 100 | + | ||
| 85 | build() { | 101 | build() { |
| 86 | Column() { | 102 | Column() { |
| 87 | Swiper(this.swiperController) { | 103 | Swiper(this.swiperController) { |
| @@ -107,7 +123,7 @@ export struct DetailVideoListPage { | @@ -107,7 +123,7 @@ export struct DetailVideoListPage { | ||
| 107 | // }, (item: string) => item) | 123 | // }, (item: string) => item) |
| 108 | 124 | ||
| 109 | } | 125 | } |
| 110 | - .cachedCount(0) | 126 | + .cachedCount(-1) |
| 111 | .indicator(false) | 127 | .indicator(false) |
| 112 | .vertical(true) | 128 | .vertical(true) |
| 113 | .loop(false) | 129 | .loop(false) |
| @@ -117,6 +133,10 @@ export struct DetailVideoListPage { | @@ -117,6 +133,10 @@ export struct DetailVideoListPage { | ||
| 117 | .onChange((index: number) => { | 133 | .onChange((index: number) => { |
| 118 | this.currentIndex = index | 134 | this.currentIndex = index |
| 119 | console.info('onChange==', index.toString()) | 135 | console.info('onChange==', index.toString()) |
| 136 | + | ||
| 137 | + if (this.currentIndex === this.data.length - 1) { | ||
| 138 | + this.queryVideoList() | ||
| 139 | + } | ||
| 120 | }) | 140 | }) |
| 121 | 141 | ||
| 122 | }.width('100%').height('100%') | 142 | }.width('100%').height('100%') |
| 1 | -import { InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index'; | 1 | +import { ContentDetailDTO, InteractDataDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index'; |
| 2 | +import { | ||
| 3 | + batchLikeAndCollectParams, | ||
| 4 | + batchLikeAndCollectResult, | ||
| 5 | + ContentDetailRequest, | ||
| 6 | + contentListParams, | ||
| 7 | + postExecuteCollectRecordParams, | ||
| 8 | + postExecuteLikeParams | ||
| 9 | +} from 'wdDetailPlayApi/src/main/ets/request/ContentDetailRequest'; | ||
| 2 | import { ToastUtils } from 'wdKit'; | 10 | import { ToastUtils } from 'wdKit'; |
| 11 | +import { HttpUrlUtils } from 'wdNetwork/Index'; | ||
| 12 | +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'; | ||
| 3 | 13 | ||
| 4 | export interface OperationItem { | 14 | export interface OperationItem { |
| 5 | icon: Resource; | 15 | icon: Resource; |
| 16 | + icon_check?: Resource; | ||
| 6 | 17 | ||
| 7 | // icon_selected: Resource; | 18 | // icon_selected: Resource; |
| 8 | text: string | Resource; | 19 | text: string | Resource; |
| @@ -16,17 +27,19 @@ const TAG = 'OperationListView'; | @@ -16,17 +27,19 @@ const TAG = 'OperationListView'; | ||
| 16 | @Preview | 27 | @Preview |
| 17 | @Component | 28 | @Component |
| 18 | export struct OperationListView { | 29 | export struct OperationListView { |
| 19 | - @Consume rmhInfo?: RmhInfoDTO | ||
| 20 | - @Consume userInfo?: UserInfoDTO | ||
| 21 | @Consume interactData: InteractDataDTO | 30 | @Consume interactData: InteractDataDTO |
| 31 | + @Consume contentDetailData: ContentDetailDTO | ||
| 32 | + @Consume newsStatusOfUser: batchLikeAndCollectResult | ||
| 22 | @State operationList: OperationItem[] = [ | 33 | @State operationList: OperationItem[] = [ |
| 23 | { | 34 | { |
| 24 | icon: $r('app.media.ic_like_uncheck'), | 35 | icon: $r('app.media.ic_like_uncheck'), |
| 36 | + icon_check: $r('app.media.ic_like_check'), | ||
| 25 | text: "赞", | 37 | text: "赞", |
| 26 | // num: 6622 | 38 | // num: 6622 |
| 27 | }, | 39 | }, |
| 28 | { | 40 | { |
| 29 | icon: $r('app.media.ic_collect_uncheck'), | 41 | icon: $r('app.media.ic_collect_uncheck'), |
| 42 | + icon_check: $r('app.media.ic_collect_check'), | ||
| 30 | text: "收藏", | 43 | text: "收藏", |
| 31 | // num: 662, | 44 | // num: 662, |
| 32 | }, | 45 | }, |
| @@ -44,26 +57,78 @@ export struct OperationListView { | @@ -44,26 +57,78 @@ export struct OperationListView { | ||
| 44 | aboutToAppear() { | 57 | aboutToAppear() { |
| 45 | } | 58 | } |
| 46 | 59 | ||
| 60 | + /** | ||
| 61 | + * 点赞、取消点赞 | ||
| 62 | + */ | ||
| 63 | + toggleLikeStatus() { | ||
| 64 | + // 未登录,跳转登录 | ||
| 65 | + if (!HttpUrlUtils.getUserId()) { | ||
| 66 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 67 | + return | ||
| 68 | + } | ||
| 69 | + const params: postExecuteLikeParams = { | ||
| 70 | + status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1', | ||
| 71 | + contentId: this.contentDetailData?.newsId + '', | ||
| 72 | + contentType: this.contentDetailData?.newsType + '', | ||
| 73 | + } | ||
| 74 | + ContentDetailRequest.postExecuteLike(params).then(res => { | ||
| 75 | + console.log('toggleLikeStatus==',) | ||
| 76 | + if (this.newsStatusOfUser) { | ||
| 77 | + this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1' | ||
| 78 | + this.queryContentInteractCount() | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + }) | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * 收藏、取消收藏 | ||
| 86 | + */ | ||
| 87 | + toggleCollectStatus() { | ||
| 88 | + // 未登录,跳转登录 | ||
| 89 | + if (!HttpUrlUtils.getUserId()) { | ||
| 90 | + WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 91 | + return | ||
| 92 | + } | ||
| 93 | + const params: postExecuteCollectRecordParams = { | ||
| 94 | + status: this.newsStatusOfUser?.collectStatus === 1 ? '0' : '1', | ||
| 95 | + contentList: [{ | ||
| 96 | + contentId: this.contentDetailData?.newsId + '', | ||
| 97 | + contentType: this.contentDetailData?.newsType + '', | ||
| 98 | + }], | ||
| 99 | + | ||
| 100 | + } | ||
| 101 | + ContentDetailRequest.postExecuteCollectRecord(params).then(res => { | ||
| 102 | + console.log('toggleLikeStatus==',) | ||
| 103 | + if (this.newsStatusOfUser) { | ||
| 104 | + this.newsStatusOfUser.collectStatus = this.newsStatusOfUser?.collectStatus === 1 ? 0 : 1 | ||
| 105 | + this.queryContentInteractCount() | ||
| 106 | + } | ||
| 107 | + }) | ||
| 108 | + | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * 查询点赞、收藏数量 | ||
| 113 | + */ | ||
| 114 | + queryContentInteractCount() { | ||
| 115 | + const params: contentListParams = { | ||
| 116 | + contentList: [{ | ||
| 117 | + contentId: this.contentDetailData?.newsId + '', | ||
| 118 | + contentType: this.contentDetailData?.newsType, | ||
| 119 | + }] | ||
| 120 | + } | ||
| 121 | + ContentDetailRequest.getContentInteract(params).then(res => { | ||
| 122 | + if (res.data && this.interactData) { | ||
| 123 | + this.interactData.likeNum = res.data[0]?.likeNum | ||
| 124 | + this.interactData.collectNum = res.data[0]?.collectNum | ||
| 125 | + this.interactData.commentNum = res.data[0]?.commentNum | ||
| 126 | + } | ||
| 127 | + console.log('获取互动点赞等数据===', JSON.stringify(res)) | ||
| 128 | + }) | ||
| 129 | + } | ||
| 130 | + | ||
| 47 | build() { | 131 | build() { |
| 48 | - // List({ space: 0, initialIndex: 0 }) { | ||
| 49 | - // ForEach(this.operationList, (item: OperationItem, index: number) => { | ||
| 50 | - // ListItem() { | ||
| 51 | - // this.buildOperationItem(item, index) | ||
| 52 | - // } | ||
| 53 | - // }, (item: OperationItem, index: number) => JSON.stringify(item)) | ||
| 54 | - // } | ||
| 55 | - // .width(48) | ||
| 56 | - // .height(250) | ||
| 57 | - // // .margin({ bottom: 100 }) | ||
| 58 | - // .backgroundColor(Color.Red) | ||
| 59 | - // // .listDirection(Axis.Vertical) // 默认值:Axis.Vertical | ||
| 60 | - // // .lanes(this.buildLanes()) // 行/列数,一列 // 默认值:1 | ||
| 61 | - // .cachedCount(2) | ||
| 62 | - // .scrollBar(BarState.Off) | ||
| 63 | - // .nestedScroll({ | ||
| 64 | - // scrollForward: NestedScrollMode.PARENT_FIRST, | ||
| 65 | - // scrollBackward: NestedScrollMode.SELF_FIRST | ||
| 66 | - // }) | ||
| 67 | 132 | ||
| 68 | Column() { | 133 | Column() { |
| 69 | this.buildUserComp() | 134 | this.buildUserComp() |
| @@ -74,32 +139,34 @@ export struct OperationListView { | @@ -74,32 +139,34 @@ export struct OperationListView { | ||
| 74 | .width(48) | 139 | .width(48) |
| 75 | } | 140 | } |
| 76 | 141 | ||
| 142 | + getImgUrl() { | ||
| 143 | + return this.contentDetailData?.rmhInfo?.rmhHeadUrl || this.contentDetailData?.userInfo?.userHeadUrl | ||
| 144 | + } | ||
| 145 | + | ||
| 77 | @Builder | 146 | @Builder |
| 78 | buildUserComp() { | 147 | buildUserComp() { |
| 79 | Column() { | 148 | Column() { |
| 80 | - Image(this.rmhInfo?.rmhHeadUrl || this.userInfo?.userHeadUrl) | ||
| 81 | - .width('100%') | ||
| 82 | - .borderRadius(24) | ||
| 83 | - .aspectRatio(1) | ||
| 84 | - .border({ width: 1, color: Color.White, style: BorderStyle.Solid }) | ||
| 85 | - .margin({ bottom: 30 }) | ||
| 86 | - }.width(48) | 149 | + if (this.getImgUrl()) { |
| 150 | + Image(this.getImgUrl()) | ||
| 151 | + .width('100%') | ||
| 152 | + .borderRadius(24) | ||
| 153 | + .aspectRatio(1) | ||
| 154 | + .border({ width: 1, color: Color.White, style: BorderStyle.Solid }) | ||
| 155 | + } | ||
| 156 | + }.margin({ bottom: 30 }) | ||
| 87 | } | 157 | } |
| 88 | 158 | ||
| 89 | - /** | ||
| 90 | - * 组件项 | ||
| 91 | - * | ||
| 92 | - * @param programmeBean item 组件项 | ||
| 93 | - */ | ||
| 94 | @Builder | 159 | @Builder |
| 95 | buildOperationItem(item: OperationItem, index: number) { | 160 | buildOperationItem(item: OperationItem, index: number) { |
| 96 | Column() { | 161 | Column() { |
| 97 | - Image(item.icon) | ||
| 98 | - .width(32) | ||
| 99 | - .aspectRatio(1) | ||
| 100 | - // .borderRadius(6) | ||
| 101 | if (item.text === '赞') { | 162 | if (item.text === '赞') { |
| 102 | - Text(this.interactData.likeNum ? (this.interactData.likeNum + '') : item.text) | 163 | + Image(this.newsStatusOfUser?.likeStatus == '0' ? item.icon : item.icon_check) |
| 164 | + .width(32) | ||
| 165 | + .aspectRatio(1) | ||
| 166 | + .onClick(() => { | ||
| 167 | + this.toggleLikeStatus() | ||
| 168 | + }) | ||
| 169 | + Text(this.interactData?.likeNum ? (this.interactData.likeNum + '') : item.text) | ||
| 103 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | 170 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) |
| 104 | .fontWeight(500) | 171 | .fontWeight(500) |
| 105 | .textAlign(TextAlign.Center) | 172 | .textAlign(TextAlign.Center) |
| @@ -108,7 +175,13 @@ export struct OperationListView { | @@ -108,7 +175,13 @@ export struct OperationListView { | ||
| 108 | .maxLines(1) | 175 | .maxLines(1) |
| 109 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 176 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 110 | } else if (item.text === '收藏') { | 177 | } else if (item.text === '收藏') { |
| 111 | - Text(this.interactData.collectNum ? (this.interactData.collectNum + '') : item.text) | 178 | + Image(this.newsStatusOfUser?.collectStatus == 0 ? item.icon : item.icon_check) |
| 179 | + .width(32) | ||
| 180 | + .aspectRatio(1) | ||
| 181 | + .onClick(() => { | ||
| 182 | + this.toggleCollectStatus() | ||
| 183 | + }) | ||
| 184 | + Text(this.interactData?.collectNum ? (this.interactData.collectNum + '') : item.text) | ||
| 112 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | 185 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) |
| 113 | .fontWeight(500) | 186 | .fontWeight(500) |
| 114 | .textAlign(TextAlign.Center) | 187 | .textAlign(TextAlign.Center) |
| @@ -117,7 +190,10 @@ export struct OperationListView { | @@ -117,7 +190,10 @@ export struct OperationListView { | ||
| 117 | .maxLines(1) | 190 | .maxLines(1) |
| 118 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 191 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 119 | } else if (item.text === '抢首评') { | 192 | } else if (item.text === '抢首评') { |
| 120 | - Text(this.interactData.commentNum ? (this.interactData.commentNum + '') : item.text) | 193 | + Image(item.icon) |
| 194 | + .width(32) | ||
| 195 | + .aspectRatio(1) | ||
| 196 | + Text(this.interactData?.commentNum ? (this.interactData.commentNum + '') : item.text) | ||
| 121 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | 197 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) |
| 122 | .fontWeight(500) | 198 | .fontWeight(500) |
| 123 | .textAlign(TextAlign.Center) | 199 | .textAlign(TextAlign.Center) |
| @@ -126,6 +202,9 @@ export struct OperationListView { | @@ -126,6 +202,9 @@ export struct OperationListView { | ||
| 126 | .maxLines(1) | 202 | .maxLines(1) |
| 127 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 203 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 128 | } else { | 204 | } else { |
| 205 | + Image(item.icon) | ||
| 206 | + .width(32) | ||
| 207 | + .aspectRatio(1) | ||
| 129 | Text(item.text) | 208 | Text(item.text) |
| 130 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) | 209 | .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown) |
| 131 | .fontWeight(500) | 210 | .fontWeight(500) |
| @@ -142,9 +221,10 @@ export struct OperationListView { | @@ -142,9 +221,10 @@ export struct OperationListView { | ||
| 142 | // .backgroundColor(Color.Black) | 221 | // .backgroundColor(Color.Black) |
| 143 | .alignItems(HorizontalAlign.Center) | 222 | .alignItems(HorizontalAlign.Center) |
| 144 | .hoverEffect(HoverEffect.Scale) | 223 | .hoverEffect(HoverEffect.Scale) |
| 145 | - .onClick((event: ClickEvent) => { | ||
| 146 | - console.info(TAG, `buildOperationItem onClick event index: ${index}`); | ||
| 147 | - // ToastUtils.showToast('体验版,本功能暂未开发', 1000); | ||
| 148 | - }) | 224 | + |
| 225 | + // .onClick((event: ClickEvent) => { | ||
| 226 | + // console.info(TAG, `buildOperationItem onClick event index: ${index}`); | ||
| 227 | + // // ToastUtils.showToast('体验版,本功能暂未开发', 1000); | ||
| 228 | + // }) | ||
| 149 | } | 229 | } |
| 150 | } | 230 | } |
| @@ -5,18 +5,15 @@ import { WindowModel } from 'wdKit'; | @@ -5,18 +5,15 @@ import { WindowModel } from 'wdKit'; | ||
| 5 | import { WDPlayerController } from 'wdPlayer'; | 5 | import { WDPlayerController } from 'wdPlayer'; |
| 6 | import { devicePLSensorManager } from 'wdDetailPlayApi'; | 6 | import { devicePLSensorManager } from 'wdDetailPlayApi'; |
| 7 | import { OperationListView } from './OperationListView'; | 7 | import { OperationListView } from './OperationListView'; |
| 8 | -import { RmhInfoDTO, UserInfoDTO } from 'wdBean/Index'; | 8 | +import { ContentDetailDTO, RmhInfoDTO, UserInfoDTO } from 'wdBean/Index'; |
| 9 | 9 | ||
| 10 | @Component | 10 | @Component |
| 11 | export struct PlayerTitleComment { | 11 | export struct PlayerTitleComment { |
| 12 | private playerController?: WDPlayerController; | 12 | private playerController?: WDPlayerController; |
| 13 | - @Consume newsSourceName?: string | ||
| 14 | - @Consume newsTitle?: string | ||
| 15 | - @Consume editorName?: string | ||
| 16 | - @Consume newsSummary?: string; | ||
| 17 | @State @Watch('watchSpeed') playSpeed: number = 1; | 13 | @State @Watch('watchSpeed') playSpeed: number = 1; |
| 18 | - @Consume isFullScreen: boolean; | ||
| 19 | @State comment: string = ''; | 14 | @State comment: string = ''; |
| 15 | + @Consume contentDetailData: ContentDetailDTO | undefined | ||
| 16 | + @Consume isFullScreen: boolean; | ||
| 20 | @Consume progressVal: number; | 17 | @Consume progressVal: number; |
| 21 | @Consume videoLandScape?: number | 18 | @Consume videoLandScape?: number |
| 22 | 19 | ||
| @@ -27,6 +24,14 @@ export struct PlayerTitleComment { | @@ -27,6 +24,14 @@ export struct PlayerTitleComment { | ||
| 27 | this.playerController?.setSpeed(this.playSpeed); | 24 | this.playerController?.setSpeed(this.playSpeed); |
| 28 | } | 25 | } |
| 29 | 26 | ||
| 27 | + getName() { | ||
| 28 | + return this.contentDetailData?.newsSourceName || this.contentDetailData?.editorName | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + getTitle() { | ||
| 32 | + return this.contentDetailData?.newsTitle || this.contentDetailData?.newsSummary | ||
| 33 | + } | ||
| 34 | + | ||
| 30 | build() { | 35 | build() { |
| 31 | Column() { | 36 | Column() { |
| 32 | // Column() { | 37 | // Column() { |
| @@ -59,15 +64,15 @@ export struct PlayerTitleComment { | @@ -59,15 +64,15 @@ export struct PlayerTitleComment { | ||
| 59 | 64 | ||
| 60 | Row() { | 65 | Row() { |
| 61 | Column() { | 66 | Column() { |
| 62 | - if (this.newsSourceName || this.editorName) { | ||
| 63 | - Text("@" + (this.newsSourceName || this.editorName)) | 67 | + if (this.getName()) { |
| 68 | + Text("@" + this.getName()) | ||
| 64 | .fontColor(Color.White) | 69 | .fontColor(Color.White) |
| 65 | .fontSize(15) | 70 | .fontSize(15) |
| 66 | .maxLines(1) | 71 | .maxLines(1) |
| 67 | .textOverflow({ overflow: TextOverflow.Ellipsis }) | 72 | .textOverflow({ overflow: TextOverflow.Ellipsis }) |
| 68 | } | 73 | } |
| 69 | - if (this.newsTitle || this.newsSummary) { | ||
| 70 | - Text(this.newsTitle || this.newsSummary) | 74 | + if (this.getTitle()) { |
| 75 | + Text(this.getTitle()) | ||
| 71 | .fontColor(Color.White) | 76 | .fontColor(Color.White) |
| 72 | .fontSize(15) | 77 | .fontSize(15) |
| 73 | .maxLines(3) | 78 | .maxLines(3) |
| @@ -134,7 +139,6 @@ export struct PlayerTitleComment { | @@ -134,7 +139,6 @@ export struct PlayerTitleComment { | ||
| 134 | }) | 139 | }) |
| 135 | 140 | ||
| 136 | TextInput({ placeholder: '说两句...', text: this.comment }) | 141 | TextInput({ placeholder: '说两句...', text: this.comment }) |
| 137 | - | ||
| 138 | .placeholderColor(Color.White) | 142 | .placeholderColor(Color.White) |
| 139 | .placeholderFont({ size: 14 }) | 143 | .placeholderFont({ size: 14 }) |
| 140 | .fontColor(Color.White) | 144 | .fontColor(Color.White) |
sight_harmony/features/wdDetailPlayShortVideo/src/main/resources/base/media/ic_collect_check.png
0 → 100644
3.02 KB
sight_harmony/features/wdDetailPlayShortVideo/src/main/resources/base/media/ic_like_check.png
0 → 100644
1.53 KB
| @@ -20,6 +20,7 @@ export class WDPlayerController { | @@ -20,6 +20,7 @@ export class WDPlayerController { | ||
| 20 | public onTimeUpdate?: (position: number, duration: number) => void; | 20 | public onTimeUpdate?: (position: number, duration: number) => void; |
| 21 | public onVolumeUpdate?: (volume: number) => void; | 21 | public onVolumeUpdate?: (volume: number) => void; |
| 22 | public continue?: () => void; | 22 | public continue?: () => void; |
| 23 | + public onCanplay?: () => void; | ||
| 23 | 24 | ||
| 24 | constructor() { | 25 | constructor() { |
| 25 | Logger.error("初始化") | 26 | Logger.error("初始化") |
| @@ -74,6 +75,9 @@ export class WDPlayerController { | @@ -74,6 +75,9 @@ export class WDPlayerController { | ||
| 74 | } | 75 | } |
| 75 | // this.avPlayer.play(); | 76 | // this.avPlayer.play(); |
| 76 | this.duration = this.avPlayer.duration; | 77 | this.duration = this.avPlayer.duration; |
| 78 | + if (this.onCanplay) { | ||
| 79 | + this.onCanplay() | ||
| 80 | + } | ||
| 77 | break; | 81 | break; |
| 78 | case AVPlayerStatus.PLAYING: | 82 | case AVPlayerStatus.PLAYING: |
| 79 | this.setBright(); | 83 | this.setBright(); |
| @@ -143,13 +147,15 @@ export class WDPlayerController { | @@ -143,13 +147,15 @@ export class WDPlayerController { | ||
| 143 | } | 147 | } |
| 144 | 148 | ||
| 145 | async release() { | 149 | async release() { |
| 146 | - if (this.avPlayer == null) { | ||
| 147 | - await this.initPromise; | ||
| 148 | - } | 150 | + // if (this.avPlayer == null) { |
| 151 | + // await this.initPromise; | ||
| 152 | + // } | ||
| 149 | if (this.avPlayer == null) { | 153 | if (this.avPlayer == null) { |
| 150 | return | 154 | return |
| 151 | } | 155 | } |
| 152 | - this.avPlayer.release(); | 156 | + this.avPlayer.release() |
| 157 | + this.avPlayer = undefined | ||
| 158 | + | ||
| 153 | } | 159 | } |
| 154 | 160 | ||
| 155 | async pause() { | 161 | async pause() { |
| @@ -171,7 +177,7 @@ export class WDPlayerController { | @@ -171,7 +177,7 @@ export class WDPlayerController { | ||
| 171 | } | 177 | } |
| 172 | this.avPlayer.play(); | 178 | this.avPlayer.play(); |
| 173 | } | 179 | } |
| 174 | - | 180 | + |
| 175 | async stop() { | 181 | async stop() { |
| 176 | if (this.avPlayer == null) { | 182 | if (this.avPlayer == null) { |
| 177 | await this.initPromise; | 183 | await this.initPromise; |
| @@ -250,6 +256,10 @@ export class WDPlayerController { | @@ -250,6 +256,10 @@ export class WDPlayerController { | ||
| 250 | return this.status; | 256 | return this.status; |
| 251 | } | 257 | } |
| 252 | 258 | ||
| 259 | + getPlayer() { | ||
| 260 | + return this.avPlayer; | ||
| 261 | + } | ||
| 262 | + | ||
| 253 | initProgress(time: number) { | 263 | initProgress(time: number) { |
| 254 | let nowSeconds = Math.floor(time / 1000); | 264 | let nowSeconds = Math.floor(time / 1000); |
| 255 | let totalSeconds = Math.floor(this.duration / 1000); | 265 | let totalSeconds = Math.floor(this.duration / 1000); |
| @@ -74,7 +74,7 @@ export struct WDPlayerRenderView { | @@ -74,7 +74,7 @@ export struct WDPlayerRenderView { | ||
| 74 | Row() { | 74 | Row() { |
| 75 | // 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。 | 75 | // 设置为“surface“类型时XComponent组件可以和其他组件一起进行布局和渲染。 |
| 76 | XComponent({ | 76 | XComponent({ |
| 77 | - id: 'xComponentId112233', | 77 | + id: 'xComponentId', |
| 78 | type: 'surface', | 78 | type: 'surface', |
| 79 | controller: this.xComponentController | 79 | controller: this.xComponentController |
| 80 | }) | 80 | }) |
-
Please register or login to post a comment