Merge branch 'main' of http://192.168.1.42/developOne/harmonyPool
# Conflicts: # sight_harmony/features/wdComponent/src/main/ets/components/page/PageComponent.ets
Showing
27 changed files
with
783 additions
and
68 deletions
| @@ -4,3 +4,5 @@ export { HttpRequest as WDHttp } from "./src/main/ets/http/HttpRequest" | @@ -4,3 +4,5 @@ export { HttpRequest as WDHttp } from "./src/main/ets/http/HttpRequest" | ||
| 4 | 4 | ||
| 5 | export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils" | 5 | export { HttpUrlUtils } from "./src/main/ets/http/HttpUrlUtils" |
| 6 | 6 | ||
| 7 | +export { HttpBizUtil } from "./src/main/ets/http/HttpBizUtil" | ||
| 8 | + |
| 1 | +import { SpConstants } from 'wdConstant/Index'; | ||
| 2 | +import { EmitterEventId, EmitterUtils, Logger, SPHelper, ToastUtils } from 'wdKit/Index'; | ||
| 3 | +import HashMap from '@ohos.util.HashMap'; | ||
| 4 | +import { ResponseDTO } from '../bean/ResponseDTO'; | ||
| 5 | +import { HttpUrlUtils, WDHttp } from '../../../../Index'; | ||
| 6 | +import { RefreshTokenRes } from '../bean/RefreshTokenRes'; | ||
| 7 | + | ||
| 8 | +const TAG: string = 'HttpBizUtil' | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 网络请求工具,业务封装http,暂添加TokenInterceptor功能 | ||
| 12 | + * TODO 待优化,将HttpBizUtil接入 AxiosInstance.interceptors.response.use | ||
| 13 | + */ | ||
| 14 | +export class HttpBizUtil { | ||
| 15 | + /** | ||
| 16 | + * get请求,封装了刷新token逻辑,接口选用,不涉及业务接口可以用原来的接口(如page接口)。 | ||
| 17 | + * | ||
| 18 | + * @param url 请求地址 | ||
| 19 | + * @param headers 请求header参数 | ||
| 20 | + * @returns 返回值 | ||
| 21 | + */ | ||
| 22 | + static get<T = string>(url: string, headers?: HashMap<string, string>): Promise<ResponseDTO<T>> { | ||
| 23 | + return new Promise<ResponseDTO<T>>((success, debug) => { | ||
| 24 | + WDHttp.get<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 25 | + Logger.debug(TAG, 'get: ' + resDTO.code) | ||
| 26 | + Logger.debug(TAG, 'get: ' + resDTO.message) | ||
| 27 | + // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 | ||
| 28 | + if (resDTO.code == 403 || resDTO.code == 406) { | ||
| 29 | + HttpBizUtil.refreshToken().then((token: string) => { | ||
| 30 | + if (headers) { | ||
| 31 | + headers.replace('RMRB-X-TOKEN', token) | ||
| 32 | + headers.replace('cookie', 'RMRB-X-TOKEN=' + token) | ||
| 33 | + } | ||
| 34 | + Logger.debug(TAG, 'get again send: ' + token) | ||
| 35 | + // refreshToken为空场景不处理,直接请求接口。 | ||
| 36 | + WDHttp.get<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 37 | + Logger.debug(TAG, 'get again: ' + resDTO.message) | ||
| 38 | + success(resDTO) | ||
| 39 | + }).catch((res: object) => { | ||
| 40 | + debug(res) | ||
| 41 | + }) | ||
| 42 | + }); | ||
| 43 | + } else { | ||
| 44 | + success(resDTO) | ||
| 45 | + } | ||
| 46 | + }).catch((res: object) => { | ||
| 47 | + debug(res) | ||
| 48 | + }) | ||
| 49 | + }) | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * post请求,封装了刷新token逻辑,接口选用,不涉及业务接口可以用原来的接口(如page接口)。 | ||
| 54 | + * | ||
| 55 | + * @param url 请求地址 | ||
| 56 | + * @param headers 请求header参数 | ||
| 57 | + * @returns 返回值 | ||
| 58 | + */ | ||
| 59 | + static post<T = string>(url: string, data?: object, headers?: HashMap<string, string>): Promise<ResponseDTO<T>> { | ||
| 60 | + return new Promise<ResponseDTO<T>>((success, debug) => { | ||
| 61 | + WDHttp.post<ResponseDTO<T>>(url, data, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 62 | + Logger.debug(TAG, 'post: ' + resDTO.code) | ||
| 63 | + Logger.debug(TAG, 'post: ' + resDTO.message) | ||
| 64 | + // 403:临时token;406:强制下线、封禁、清空登录信息还要跳转登录页面 | ||
| 65 | + if (resDTO.code == 0 || resDTO.code == 406) { | ||
| 66 | + HttpBizUtil.refreshToken().then((token: string) => { | ||
| 67 | + if (headers) { | ||
| 68 | + headers.replace('RMRB-X-TOKEN', token) | ||
| 69 | + headers.replace('cookie', 'RMRB-X-TOKEN=' + token) | ||
| 70 | + } | ||
| 71 | + // refreshToken为空场景不处理,直接请求接口。 | ||
| 72 | + WDHttp.post<ResponseDTO<T>>(url, headers).then((resDTO: ResponseDTO<T>) => { | ||
| 73 | + success(resDTO) | ||
| 74 | + }).catch((res: object) => { | ||
| 75 | + debug(res) | ||
| 76 | + }) | ||
| 77 | + }); | ||
| 78 | + } else { | ||
| 79 | + success(resDTO) | ||
| 80 | + } | ||
| 81 | + }).catch((res: object) => { | ||
| 82 | + debug(res) | ||
| 83 | + }) | ||
| 84 | + }) | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + /* | ||
| 88 | + * 获取刷新后的token,可能为空 | ||
| 89 | + */ | ||
| 90 | + static refreshToken(): Promise<string> { | ||
| 91 | + let url = HttpUrlUtils.getRefreshTokenUrl(); | ||
| 92 | + let params: HashMap<string, string> = new HashMap<string, string>() | ||
| 93 | + params.set('refreshToken', HttpUrlUtils.getRefreshToken()) | ||
| 94 | + params.set('deviceId', HttpUrlUtils.getDeviceId()) | ||
| 95 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 96 | + Logger.debug(TAG, 'refreshToken getRefreshToken: ' + HttpUrlUtils.getRefreshToken()) | ||
| 97 | + // // 请求刷新token接口 | ||
| 98 | + return new Promise<string>((success, debug) => { | ||
| 99 | + WDHttp.post<ResponseDTO<RefreshTokenRes>>(url, params, headers).then((resDTO: ResponseDTO<RefreshTokenRes>) => { | ||
| 100 | + let newToken = '' | ||
| 101 | + if (resDTO) { | ||
| 102 | + Logger.debug(TAG, 'refreshToken getRefreshToken: ' + resDTO.message) | ||
| 103 | + Logger.debug(TAG, 'refreshToken getRefreshToken: ' + resDTO.code) | ||
| 104 | + if (resDTO.code == 377) { | ||
| 105 | + // 377强制用户下线、重新登录、封禁等场景;refreshToken 失效 | ||
| 106 | + ToastUtils.showToast("已登出,请重新登入", 1000); | ||
| 107 | + EmitterUtils.sendEmptyEvent(EmitterEventId.FORCE_USER_LOGIN_OUT) | ||
| 108 | + // WDRouterRule.jumpWithPage(WDRouterPage.loginPage) | ||
| 109 | + } else if (resDTO.code == 0 && resDTO.data) { | ||
| 110 | + newToken = resDTO.data.jwtToken | ||
| 111 | + let refreshToken = resDTO.data.refreshToken | ||
| 112 | + SPHelper.default.save(SpConstants.USER_JWT_TOKEN, newToken) | ||
| 113 | + SPHelper.default.save(SpConstants.USER_REFRESH_TOKEN, refreshToken) | ||
| 114 | + Logger.debug(TAG, 'refreshToken jwtToken: ' + resDTO.data.jwtToken) | ||
| 115 | + Logger.debug(TAG, 'refreshToken refreshToken: ' + resDTO.data.refreshToken) | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + success(newToken) | ||
| 119 | + }); | ||
| 120 | + }) | ||
| 121 | + } | ||
| 122 | +} |
| @@ -112,6 +112,10 @@ export class HttpUrlUtils { | @@ -112,6 +112,10 @@ export class HttpUrlUtils { | ||
| 112 | */ | 112 | */ |
| 113 | static readonly APPOINTMENT_userArea_PATH: string = "/api/rmrb-content-center/c/service/sys-area/treeselect"; | 113 | static readonly APPOINTMENT_userArea_PATH: string = "/api/rmrb-content-center/c/service/sys-area/treeselect"; |
| 114 | /** | 114 | /** |
| 115 | + * 用户token刷新接口(token过期,需要刷新) | ||
| 116 | + */ | ||
| 117 | + static readonly REFRESH_TOKEN_PATH: string = "/api/rmrb-user-center/auth/zh/c/refreshToken"; | ||
| 118 | + /** | ||
| 115 | /** | 119 | /** |
| 116 | * 个人中心 关注列表详情 | 120 | * 个人中心 关注列表详情 |
| 117 | */ | 121 | */ |
| @@ -188,7 +192,6 @@ export class HttpUrlUtils { | @@ -188,7 +192,6 @@ export class HttpUrlUtils { | ||
| 188 | * 搜索主页 热词 | 192 | * 搜索主页 热词 |
| 189 | */ | 193 | */ |
| 190 | static readonly SEARCH_HOTS_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hots"; | 194 | static readonly SEARCH_HOTS_DATA_PATH: string = "/api/rmrb-search-api/zh/c/hots"; |
| 191 | - | ||
| 192 | /** | 195 | /** |
| 193 | * 搜索联想词 | 196 | * 搜索联想词 |
| 194 | */ | 197 | */ |
| @@ -198,7 +201,6 @@ export class HttpUrlUtils { | @@ -198,7 +201,6 @@ export class HttpUrlUtils { | ||
| 198 | * 直播详情 | 201 | * 直播详情 |
| 199 | */ | 202 | */ |
| 200 | static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; | 203 | static readonly LIVE_DETAILS_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/content/detail"; |
| 201 | - | ||
| 202 | /** | 204 | /** |
| 203 | * 直播详情-直播间列表 | 205 | * 直播详情-直播间列表 |
| 204 | */ | 206 | */ |
| @@ -358,7 +360,7 @@ export class HttpUrlUtils { | @@ -358,7 +360,7 @@ export class HttpUrlUtils { | ||
| 358 | return ''; | 360 | return ''; |
| 359 | } | 361 | } |
| 360 | 362 | ||
| 361 | - private static getDeviceId() { | 363 | + public static getDeviceId() { |
| 362 | // TODO | 364 | // TODO |
| 363 | return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; | 365 | return '8a81226a-cabd-3e1b-b630-b51db4a720ed'; |
| 364 | } | 366 | } |
| @@ -452,6 +454,10 @@ export class HttpUrlUtils { | @@ -452,6 +454,10 @@ export class HttpUrlUtils { | ||
| 452 | return url; | 454 | return url; |
| 453 | } | 455 | } |
| 454 | 456 | ||
| 457 | + static getRefreshTokenUrl() { | ||
| 458 | + let url = HttpUrlUtils._hostUrl + HttpUrlUtils.REFRESH_TOKEN_PATH; | ||
| 459 | + return url; | ||
| 460 | + } | ||
| 455 | 461 | ||
| 456 | static getResetPassworddUrl() { | 462 | static getResetPassworddUrl() { |
| 457 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword"; | 463 | let url = HttpUrlUtils._hostUrl + "/api/rmrb-user-center/user/zh/c/resetPassword"; |
| @@ -66,3 +66,6 @@ export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasN | @@ -66,3 +66,6 @@ export { ListHasNoMoreDataUI } from "./src/main/ets/components/reusable/ListHasN | ||
| 66 | export { LottieView } from './src/main/ets/lottie/LottieView' | 66 | export { LottieView } from './src/main/ets/lottie/LottieView' |
| 67 | 67 | ||
| 68 | export { SpacialTopicPageComponent } from './src/main/ets/components/SpacialTopicPageComponent' | 68 | export { SpacialTopicPageComponent } from './src/main/ets/components/SpacialTopicPageComponent' |
| 69 | + | ||
| 70 | +export { LogoutViewModel } from "./src/main/ets/viewmodel/LogoutViewModel" | ||
| 71 | + |
| 1 | +import { Logger } from 'wdKit'; | ||
| 2 | +import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel'; | ||
| 3 | +import { ContentDetailDTO } from 'wdBean'; | ||
| 4 | +import media from '@ohos.multimedia.media'; | ||
| 5 | +import { OperRowListView } from './view/OperRowListView'; | ||
| 6 | +import { WDPlayerController } from 'wdPlayer/Index'; | ||
| 7 | + | ||
| 8 | +const TAG = 'DynamicDetailComponent' | ||
| 9 | +@Preview | ||
| 10 | +@Component | ||
| 11 | +export struct DynamicDetailComponent { | ||
| 12 | + //入参 | ||
| 13 | + private relId: string = '' | ||
| 14 | + private contentId: string = '' | ||
| 15 | + private relType: string = '' | ||
| 16 | + //出参 | ||
| 17 | + @State contentDetailData: ContentDetailDTO[] = [] as ContentDetailDTO[] | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + async aboutToAppear() { | ||
| 21 | + await this.getContentDetailData() | ||
| 22 | + } | ||
| 23 | + onPageHide() { | ||
| 24 | + | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + build() { | ||
| 28 | + Row() { | ||
| 29 | + Column(){ | ||
| 30 | + Text("this is a test!") | ||
| 31 | + } | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + private async getContentDetailData() { | ||
| 36 | + try { | ||
| 37 | + let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType) | ||
| 38 | + this.contentDetailData = data; | ||
| 39 | + console.log('动态详情',JSON.stringify(this.contentDetailData)) | ||
| 40 | + } catch (exception) { | ||
| 41 | + console.log('请求失败',JSON.stringify(exception)) | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | +} |
| 1 | +import { ContentDTO } from 'wdBean'; | ||
| 2 | +import { RmhTitle } from '../cardCommon/RmhTitle' | ||
| 3 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 4 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 5 | + | ||
| 6 | +const TAG = 'Card12Component'; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 人民号-动态---12:人民号无图卡; | ||
| 10 | + */ | ||
| 11 | +@Component | ||
| 12 | +export struct Card12Component { | ||
| 13 | + @State contentDTO: ContentDTO = { | ||
| 14 | + appStyle: '20', | ||
| 15 | + coverType: 1, | ||
| 16 | + coverUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 17 | + fullColumnImgUrls: [ | ||
| 18 | + { | ||
| 19 | + landscape: 1, | ||
| 20 | + size: 1, | ||
| 21 | + url: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 22 | + weight: 1600 | ||
| 23 | + } | ||
| 24 | + ], | ||
| 25 | + newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 26 | + rmhInfo: { | ||
| 27 | + authIcon: | ||
| 28 | + 'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png', | ||
| 29 | + authTitle: '10后音乐人王烁然个人人民号', | ||
| 30 | + authTitle2: '10后音乐人王烁然个人人民号', | ||
| 31 | + banControl: 0, | ||
| 32 | + cnIsAttention: 1, | ||
| 33 | + rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 34 | + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn/image/creator/rmh/20221031/3d3419e86a.jpeg?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg', | ||
| 35 | + rmhName: '王烁然', | ||
| 36 | + userId: '522435359667845', | ||
| 37 | + userType: '2' | ||
| 38 | + }, | ||
| 39 | + objectType: '1', | ||
| 40 | + videoInfo: { | ||
| 41 | + firstFrameImageUri: '', | ||
| 42 | + videoDuration: 37, | ||
| 43 | + videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4' | ||
| 44 | + } | ||
| 45 | + } as ContentDTO; | ||
| 46 | + | ||
| 47 | + aboutToAppear(): void { | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + build() { | ||
| 51 | + Column() { | ||
| 52 | + // rmh信息 | ||
| 53 | + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) | ||
| 54 | + // 标题 | ||
| 55 | + if (this.contentDTO.newsTitle) { | ||
| 56 | + Text(this.contentDTO.newsTitle) | ||
| 57 | + .fontSize($r('app.float.font_size_17')) | ||
| 58 | + .fontColor($r('app.color.color_222222')) | ||
| 59 | + .width(CommonConstants.FULL_WIDTH) | ||
| 60 | + .textOverflowStyle(3) | ||
| 61 | + .margin({ bottom: 8 }) | ||
| 62 | + .height(75) | ||
| 63 | + .lineHeight(25) | ||
| 64 | + .fontFamily('PingFang SC-Regular') | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + // if (this.contentDTO.fullColumnImgUrls?.[0]) { | ||
| 68 | + // createImg({ contentDTO: this.contentDTO }) | ||
| 69 | + // } | ||
| 70 | + //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 | ||
| 71 | + } | ||
| 72 | + .padding({ | ||
| 73 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 74 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 75 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 76 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 77 | + }) | ||
| 78 | + } | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +interface radiusType { | ||
| 82 | + topLeft: number | Resource; | ||
| 83 | + topRight: number | Resource; | ||
| 84 | + bottomLeft: number | Resource; | ||
| 85 | + bottomRight: number | Resource; | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +@Component | ||
| 89 | +struct createImg { | ||
| 90 | + @Prop contentDTO: ContentDTO | ||
| 91 | + | ||
| 92 | + build() { | ||
| 93 | + GridRow() { | ||
| 94 | + if (this.contentDTO.fullColumnImgUrls[0].landscape === 1) { | ||
| 95 | + // 横屏 | ||
| 96 | + GridCol({ | ||
| 97 | + span: { xs: 12 } | ||
| 98 | + }) { | ||
| 99 | + Stack() { | ||
| 100 | + Image(this.contentDTO.coverUrl) | ||
| 101 | + .width(CommonConstants.FULL_WIDTH) | ||
| 102 | + .aspectRatio(16 / 9) | ||
| 103 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 104 | + CardMediaInfo({ contentDTO: this.contentDTO }) | ||
| 105 | + } | ||
| 106 | + .align(Alignment.BottomEnd) | ||
| 107 | + } | ||
| 108 | + } else { | ||
| 109 | + // 竖图显示,宽度占50%,高度自适应 | ||
| 110 | + GridCol({ | ||
| 111 | + span: { xs: 6 } | ||
| 112 | + }) { | ||
| 113 | + Stack() { | ||
| 114 | + Image(this.contentDTO.coverUrl) | ||
| 115 | + .width(CommonConstants.FULL_WIDTH) | ||
| 116 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 117 | + CardMediaInfo({ contentDTO: this.contentDTO }) | ||
| 118 | + } | ||
| 119 | + .align(Alignment.BottomEnd) | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | +} | ||
| 125 | + | ||
| 126 | + | ||
| 127 | +@Extend(Text) | ||
| 128 | +function textOverflowStyle(maxLine: number) { | ||
| 129 | + .maxLines(maxLine) | ||
| 130 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 131 | +} |
| 1 | +import { ContentDTO } from 'wdBean'; | ||
| 2 | +import { RmhTitle } from '../cardCommon/RmhTitle' | ||
| 3 | +import { CardMediaInfo } from '../cardCommon/CardMediaInfo' | ||
| 4 | +import { CommonConstants } from 'wdConstant/Index'; | ||
| 5 | + | ||
| 6 | +const TAG = 'Card12Component'; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 人民号-动态---12:人民号无图卡; | ||
| 10 | + */ | ||
| 11 | +@Entry | ||
| 12 | +@Component | ||
| 13 | +export struct Card12Component { | ||
| 14 | + @State contentDTO: ContentDTO = { | ||
| 15 | + appStyle: '20', | ||
| 16 | + coverType: 1, | ||
| 17 | + coverUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 18 | + fullColumnImgUrls: [ | ||
| 19 | + { | ||
| 20 | + landscape: 1, | ||
| 21 | + size: 1, | ||
| 22 | + url: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/default_image/202105/rmrb_default_image_4GdWrgSw1622451312.jpg?x-oss-process=image/resize,m_fill,h_480,w_360/quality,q_90', | ||
| 23 | + weight: 1600 | ||
| 24 | + } | ||
| 25 | + ], | ||
| 26 | + newsTitle: '好玩!》10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 27 | + rmhInfo: { | ||
| 28 | + authIcon: | ||
| 29 | + 'https://cdnjdphoto.aikan.pdnews.cn/creator-category/icon/auth/yellow.png', | ||
| 30 | + authTitle: '10后音乐人王烁然个人人民号', | ||
| 31 | + authTitle2: '10后音乐人王烁然个人人民号', | ||
| 32 | + banControl: 0, | ||
| 33 | + cnIsAttention: 1, | ||
| 34 | + rmhDesc: '10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人10后少年音乐人', | ||
| 35 | + rmhHeadUrl: 'https://cdnjdphoto.aikan.pdnews.cn/image/creator/rmh/20221031/3d3419e86a.jpeg?x-oss-process=image/resize,l_100/auto-orient,1/quality,q_90/format,jpg', | ||
| 36 | + rmhName: '王烁然', | ||
| 37 | + userId: '522435359667845', | ||
| 38 | + userType: '2' | ||
| 39 | + }, | ||
| 40 | + objectType: '1', | ||
| 41 | + videoInfo: { | ||
| 42 | + firstFrameImageUri: '', | ||
| 43 | + videoDuration: 37, | ||
| 44 | + videoUrl: 'https://rmrbcmsonline.peopleapp.com/upload/user_app/gov_dynamic/video/mp4/202105/rmrb_GSNARt6P1622451310.mp4' | ||
| 45 | + } | ||
| 46 | + } as ContentDTO; | ||
| 47 | + | ||
| 48 | + aboutToAppear(): void { | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + build() { | ||
| 52 | + Column() { | ||
| 53 | + // rmh信息 | ||
| 54 | + RmhTitle({ rmhInfo: this.contentDTO.rmhInfo }) | ||
| 55 | + // 左标题,右图 | ||
| 56 | + Flex({ direction: FlexDirection.Row }) { | ||
| 57 | + | ||
| 58 | + Text(this.contentDTO.newsTitle) | ||
| 59 | + .fontSize($r('app.float.font_size_17')) | ||
| 60 | + .fontColor($r('app.color.color_222222')) | ||
| 61 | + .textOverflowStyle(3) | ||
| 62 | + .lineHeight(25) | ||
| 63 | + .fontFamily('PingFang SC-Regular') | ||
| 64 | + .textAlign(TextAlign.Start) | ||
| 65 | + .flexBasis('auto') | ||
| 66 | + .margin({right: 12}) | ||
| 67 | + | ||
| 68 | + Image(this.contentDTO.coverUrl) | ||
| 69 | + .flexBasis(174) | ||
| 70 | + .height(75) | ||
| 71 | + .borderRadius($r('app.float.image_border_radius')) | ||
| 72 | + // .flexBasis(160) | ||
| 73 | + .backgroundImageSize(ImageSize.Auto) | ||
| 74 | + | ||
| 75 | + } | ||
| 76 | + .width(CommonConstants.FULL_WIDTH) | ||
| 77 | + .margin({ bottom: 8 }) | ||
| 78 | + .height(75) | ||
| 79 | + | ||
| 80 | + | ||
| 81 | + //TODO 底部的:分享、评论、点赞 功能;需要引用一个公共组件 | ||
| 82 | + } | ||
| 83 | + .padding({ | ||
| 84 | + left: $r('app.float.card_comp_pagePadding_lf'), | ||
| 85 | + right: $r('app.float.card_comp_pagePadding_lf'), | ||
| 86 | + top: $r('app.float.card_comp_pagePadding_tb'), | ||
| 87 | + bottom: $r('app.float.card_comp_pagePadding_tb') | ||
| 88 | + }) | ||
| 89 | + } | ||
| 90 | +} | ||
| 91 | + | ||
| 92 | +interface radiusType { | ||
| 93 | + topLeft: number | Resource; | ||
| 94 | + topRight: number | Resource; | ||
| 95 | + bottomLeft: number | Resource; | ||
| 96 | + bottomRight: number | Resource; | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +@Extend(Text) | ||
| 100 | +function textOverflowStyle(maxLine: number) { | ||
| 101 | + .maxLines(maxLine) | ||
| 102 | + .textOverflow({ overflow: TextOverflow.Ellipsis }) | ||
| 103 | +} |
| @@ -33,8 +33,8 @@ export default struct MinePageUserSimpleInfoUI { | @@ -33,8 +33,8 @@ export default struct MinePageUserSimpleInfoUI { | ||
| 33 | Stack(){ | 33 | Stack(){ |
| 34 | Image(this.headPhotoUrl) | 34 | Image(this.headPhotoUrl) |
| 35 | .alt($r('app.media.default_head')) | 35 | .alt($r('app.media.default_head')) |
| 36 | - .width('108lpx') | ||
| 37 | - .height('108lpx') | 36 | + .width('100lpx') |
| 37 | + .height('100lpx') | ||
| 38 | .objectFit(ImageFit.Cover) | 38 | .objectFit(ImageFit.Cover) |
| 39 | .borderRadius(50) | 39 | .borderRadius(50) |
| 40 | Image(this.levelHead) | 40 | Image(this.levelHead) |
| @@ -18,7 +18,7 @@ export struct FollowFirstTabsComponent{ | @@ -18,7 +18,7 @@ export struct FollowFirstTabsComponent{ | ||
| 18 | value.forEach((element)=>{ | 18 | value.forEach((element)=>{ |
| 19 | this.data.push(element) | 19 | this.data.push(element) |
| 20 | }) | 20 | }) |
| 21 | - console.log("ycg",this.data.length.toString()); | 21 | + |
| 22 | if(this.controller != null && this.data.length>1 && this.changeIndex === 1){ | 22 | if(this.controller != null && this.data.length>1 && this.changeIndex === 1){ |
| 23 | //个人主页 跳转 关注页 tab 2 | 23 | //个人主页 跳转 关注页 tab 2 |
| 24 | let intervalID = setInterval(() => { | 24 | let intervalID = setInterval(() => { |
| @@ -171,6 +171,7 @@ struct ChildComponent { | @@ -171,6 +171,7 @@ struct ChildComponent { | ||
| 171 | .fontSize('31lpx') | 171 | .fontSize('31lpx') |
| 172 | .lineHeight('38lpx') | 172 | .lineHeight('38lpx') |
| 173 | .fontColor($r('app.color.color_222222')) | 173 | .fontColor($r('app.color.color_222222')) |
| 174 | + .maxLines(1) | ||
| 174 | Text(`粉丝${this.data.cnFansNum}`) | 175 | Text(`粉丝${this.data.cnFansNum}`) |
| 175 | .fontColor($r('app.color.color_B0B0B0')) | 176 | .fontColor($r('app.color.color_B0B0B0')) |
| 176 | .fontSize('23lpx') | 177 | .fontSize('23lpx') |
sight_harmony/features/wdComponent/src/main/ets/components/mine/follow/FollowSecondTabsComponent.ets
| @@ -35,25 +35,45 @@ export struct FollowSecondTabsComponent{ | @@ -35,25 +35,45 @@ export struct FollowSecondTabsComponent{ | ||
| 35 | 35 | ||
| 36 | @Builder FollowSecondUI(){ | 36 | @Builder FollowSecondUI(){ |
| 37 | Row() { | 37 | Row() { |
| 38 | + Row(){ | ||
| 39 | + // 页签 | ||
| 40 | + Column({ space: 7 }) { | ||
| 41 | + Scroll() { | ||
| 42 | + Column() { | ||
| 43 | + ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => { | ||
| 44 | + this.TabBuilder(index,item) | ||
| 45 | + }) | ||
| 46 | + } | ||
| 47 | + .justifyContent(FlexAlign.Start) | ||
| 48 | + } | ||
| 49 | + .align(Alignment.Top) | ||
| 50 | + .scrollable(ScrollDirection.Vertical) | ||
| 51 | + .scrollBar(BarState.Off) | ||
| 52 | + .height('100%') | ||
| 53 | + }.height('100%') | ||
| 54 | + .alignItems(HorizontalAlign.Center) | ||
| 55 | + } | ||
| 56 | + .alignItems(VerticalAlign.Top) | ||
| 57 | + .height('100%') | ||
| 58 | + | ||
| 38 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 59 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 39 | ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => { | 60 | ForEach(this.data[this.firstIndex].children, (item: FollowSecondListItem, index: number ) => { |
| 40 | TabContent(){ | 61 | TabContent(){ |
| 41 | FollowThirdTabsComponent({data:$data,firstIndex:$firstIndex,secondIndex:index}) | 62 | FollowThirdTabsComponent({data:$data,firstIndex:$firstIndex,secondIndex:index}) |
| 42 | - }.tabBar(this.TabBuilder(index,item)) | 63 | + } |
| 43 | .backgroundColor($r('app.color.white')) | 64 | .backgroundColor($r('app.color.white')) |
| 44 | }, (item: FollowListItem, index: number) => index.toString()) | 65 | }, (item: FollowListItem, index: number) => index.toString()) |
| 45 | } | 66 | } |
| 46 | .vertical(true) | 67 | .vertical(true) |
| 47 | .barMode(BarMode.Scrollable) | 68 | .barMode(BarMode.Scrollable) |
| 48 | - .barWidth('140lpx') | ||
| 49 | .animationDuration(0) | 69 | .animationDuration(0) |
| 50 | .onChange((index: number) => { | 70 | .onChange((index: number) => { |
| 51 | this.currentIndex = index | 71 | this.currentIndex = index |
| 52 | }) | 72 | }) |
| 53 | - .width('100%') | 73 | + .barWidth(0) |
| 74 | + .height('100%') | ||
| 75 | + .layoutWeight(1) | ||
| 54 | }.width('100%') | 76 | }.width('100%') |
| 55 | - .alignItems(VerticalAlign.Top) | ||
| 56 | - .backgroundColor('#0FF') | ||
| 57 | } | 77 | } |
| 58 | 78 | ||
| 59 | @Builder TabBuilder(index: number, item: FollowSecondListItem) { | 79 | @Builder TabBuilder(index: number, item: FollowSecondListItem) { |
| @@ -73,6 +93,7 @@ export struct FollowSecondTabsComponent{ | @@ -73,6 +93,7 @@ export struct FollowSecondTabsComponent{ | ||
| 73 | }) | 93 | }) |
| 74 | .justifyContent(FlexAlign.Center) | 94 | .justifyContent(FlexAlign.Center) |
| 75 | .height('84lpx') | 95 | .height('84lpx') |
| 96 | + .width('140lpx') | ||
| 76 | .backgroundColor(this.currentIndex === index?$r('app.color.white'):$r('app.color.color_F9F9F9')) | 97 | .backgroundColor(this.currentIndex === index?$r('app.color.white'):$r('app.color.color_F9F9F9')) |
| 77 | } | 98 | } |
| 78 | 99 |
| @@ -34,19 +34,45 @@ export struct FollowThirdTabsComponent{ | @@ -34,19 +34,45 @@ export struct FollowThirdTabsComponent{ | ||
| 34 | .lineHeight('38lpx') | 34 | .lineHeight('38lpx') |
| 35 | .backgroundColor($r('app.color.color_F9F9F9')) | 35 | .backgroundColor($r('app.color.color_F9F9F9')) |
| 36 | .padding('13lpx') | 36 | .padding('13lpx') |
| 37 | + .maxLines(1) | ||
| 37 | } | 38 | } |
| 38 | .onClick(()=>{ | 39 | .onClick(()=>{ |
| 39 | this.currentIndex = index | 40 | this.currentIndex = index |
| 40 | this.controller.changeIndex(this.currentIndex) | 41 | this.controller.changeIndex(this.currentIndex) |
| 41 | }) | 42 | }) |
| 42 | - .height('100%') | 43 | + .height('84lpx') |
| 43 | .margin({right:'9lpx'}) | 44 | .margin({right:'9lpx'}) |
| 44 | .padding({left:'20lpx',right:index === this.data[this.firstIndex].children[this.secondIndex].children.length-1?"20lpx":"0lpx"}) | 45 | .padding({left:'20lpx',right:index === this.data[this.firstIndex].children[this.secondIndex].children.length-1?"20lpx":"0lpx"}) |
| 45 | .justifyContent(FlexAlign.Center) | 46 | .justifyContent(FlexAlign.Center) |
| 46 | } | 47 | } |
| 47 | 48 | ||
| 48 | @Builder FollowThirdUI(){ | 49 | @Builder FollowThirdUI(){ |
| 50 | + | ||
| 51 | + Column(){ | ||
| 52 | + Column() { | ||
| 53 | + // 页签 | ||
| 54 | + Row({ space: 7 }) { | ||
| 55 | + Scroll() { | ||
| 49 | Row() { | 56 | Row() { |
| 57 | + ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => { | ||
| 58 | + this.TabBuilder(index,item) | ||
| 59 | + }) | ||
| 60 | + } | ||
| 61 | + .justifyContent(FlexAlign.Start) | ||
| 62 | + } | ||
| 63 | + .align(Alignment.Start) | ||
| 64 | + .scrollable(ScrollDirection.Horizontal) | ||
| 65 | + .scrollBar(BarState.Off) | ||
| 66 | + .width('90%') | ||
| 67 | + .padding({left:'11lpx'}) | ||
| 68 | + } | ||
| 69 | + .alignItems(VerticalAlign.Bottom) | ||
| 70 | + .width('100%') | ||
| 71 | + } | ||
| 72 | + .backgroundColor($r('app.color.white')) | ||
| 73 | + .alignItems(HorizontalAlign.Start) | ||
| 74 | + .width('100%') | ||
| 75 | + | ||
| 50 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 76 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 51 | ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => { | 77 | ForEach(this.data[this.firstIndex].children[this.secondIndex].children, (item: FollowThirdListItem, index: number ) => { |
| 52 | TabContent(){ | 78 | TabContent(){ |
| @@ -58,20 +84,19 @@ export struct FollowThirdTabsComponent{ | @@ -58,20 +84,19 @@ export struct FollowThirdTabsComponent{ | ||
| 58 | .margin({left:'20lpx'}) | 84 | .margin({left:'20lpx'}) |
| 59 | FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].children[this.secondIndex].children[index].id}) | 85 | FollowListDetailUI({creatorDirectoryId:this.data[this.firstIndex].children[this.secondIndex].children[index].id}) |
| 60 | } | 86 | } |
| 61 | - }.tabBar(this.TabBuilder(index,item)) | 87 | + } |
| 62 | .backgroundColor($r('app.color.white')) | 88 | .backgroundColor($r('app.color.white')) |
| 63 | }, (item: FollowListItem, index: number) => index.toString()) | 89 | }, (item: FollowListItem, index: number) => index.toString()) |
| 64 | } | 90 | } |
| 91 | + .barHeight(0) | ||
| 65 | .vertical(false) | 92 | .vertical(false) |
| 66 | .barMode(BarMode.Scrollable) | 93 | .barMode(BarMode.Scrollable) |
| 67 | - .barWidth('100%') | ||
| 68 | - .barHeight('84lpx') | ||
| 69 | .animationDuration(0) | 94 | .animationDuration(0) |
| 70 | .onChange((index: number) => { | 95 | .onChange((index: number) => { |
| 71 | this.currentIndex = index | 96 | this.currentIndex = index |
| 72 | }) | 97 | }) |
| 73 | .width('100%') | 98 | .width('100%') |
| 74 | - }.width('100%') | 99 | + } |
| 75 | } | 100 | } |
| 76 | 101 | ||
| 77 | } | 102 | } |
| 1 | -import { Logger, DateTimeUtils, CollectionUtils } from 'wdKit'; | 1 | +import { CollectionUtils, DateTimeUtils, Logger } from 'wdKit'; |
| 2 | import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; | 2 | import { CommonConstants, CompStyle, ViewType } from 'wdConstant'; |
| 3 | import PageViewModel from '../../viewmodel/PageViewModel'; | 3 | import PageViewModel from '../../viewmodel/PageViewModel'; |
| 4 | import { EmptyComponent } from '../view/EmptyComponent'; | 4 | import { EmptyComponent } from '../view/EmptyComponent'; |
| @@ -13,7 +13,7 @@ import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | @@ -13,7 +13,7 @@ import CustomRefreshLoadLayout from './CustomRefreshLoadLayout'; | ||
| 13 | import { CompParser } from '../CompParser'; | 13 | import { CompParser } from '../CompParser'; |
| 14 | import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; | 14 | import { GroupInfoDTO } from 'wdBean/src/main/ets/bean/navigation/PageInfoDTO'; |
| 15 | import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; | 15 | import { VideoChannelDetail } from 'wdDetailPlayShortVideo/Index'; |
| 16 | -import { CompDTO, LiveReviewDTO, PageDTO, PageInfoDTO } from 'wdBean'; | 16 | +import { CompDTO, LiveReviewDTO, PageDTO, PageInfoBean } from 'wdBean'; |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | const TAG = 'PageComponent'; | 19 | const TAG = 'PageComponent'; |
| @@ -71,7 +71,6 @@ export struct PageComponent { | @@ -71,7 +71,6 @@ export struct PageComponent { | ||
| 71 | @Builder | 71 | @Builder |
| 72 | ListLayout() { | 72 | ListLayout() { |
| 73 | List() { | 73 | List() { |
| 74 | - if (this.name !== '视频') { | ||
| 75 | // 下拉刷新 | 74 | // 下拉刷新 |
| 76 | ListItem() { | 75 | ListItem() { |
| 77 | RefreshLayout({ | 76 | RefreshLayout({ |
| @@ -79,25 +78,22 @@ export struct PageComponent { | @@ -79,25 +78,22 @@ export struct PageComponent { | ||
| 79 | this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight) | 78 | this.pageModel.pullDownRefreshText, this.pageModel.pullDownRefreshHeight) |
| 80 | }) | 79 | }) |
| 81 | } | 80 | } |
| 82 | - } | ||
| 83 | 81 | ||
| 84 | - if (this.name == '视频') { | ||
| 85 | - VideoChannelDetail() | ||
| 86 | - } else { | ||
| 87 | LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => { | 82 | LazyForEach(this.pageModel.compList, (compDTO: CompDTO, compIndex: number) => { |
| 88 | ListItem() { | 83 | ListItem() { |
| 89 | Column() { | 84 | Column() { |
| 85 | + if (this.name == '视频') { | ||
| 86 | + VideoChannelDetail() | ||
| 87 | + } else { | ||
| 90 | CompParser({ compDTO: compDTO, compIndex: compIndex }); | 88 | CompParser({ compDTO: compDTO, compIndex: compIndex }); |
| 89 | + } | ||
| 91 | 90 | ||
| 92 | } | 91 | } |
| 93 | } | 92 | } |
| 94 | }, | 93 | }, |
| 95 | (compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp | 94 | (compDTO: CompDTO, compIndex: number) => compDTO.id + compIndex.toString() + this.pageModel.timestamp |
| 96 | ) | 95 | ) |
| 97 | - } | ||
| 98 | 96 | ||
| 99 | - | ||
| 100 | - if (this.name !== '视频') { | ||
| 101 | // 加载更多 | 97 | // 加载更多 |
| 102 | ListItem() { | 98 | ListItem() { |
| 103 | if (this.pageModel.hasMore) { | 99 | if (this.pageModel.hasMore) { |
| @@ -110,7 +106,6 @@ export struct PageComponent { | @@ -110,7 +106,6 @@ export struct PageComponent { | ||
| 110 | } | 106 | } |
| 111 | } | 107 | } |
| 112 | } | 108 | } |
| 113 | - } | ||
| 114 | .scrollBar(BarState.Off) | 109 | .scrollBar(BarState.Off) |
| 115 | .cachedCount(8) | 110 | .cachedCount(8) |
| 116 | .height(CommonConstants.FULL_PARENT) | 111 | .height(CommonConstants.FULL_PARENT) |
| @@ -162,6 +157,16 @@ export struct PageComponent { | @@ -162,6 +157,16 @@ export struct PageComponent { | ||
| 162 | this.pageModel.viewType = ViewType.EMPTY; | 157 | this.pageModel.viewType = ViewType.EMPTY; |
| 163 | return; | 158 | return; |
| 164 | } | 159 | } |
| 160 | + if (this.navIndex === 0) { | ||
| 161 | + await this.getVideoListData(pageInfo); | ||
| 162 | + } else { | ||
| 163 | + await this.getLiveListData(pageInfo); | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + private async getVideoListData(pageInfo: PageInfoBean) { | ||
| 165 | let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); | 170 | let groupInfo: GroupInfoDTO = CollectionUtils.getElement(pageInfo.groups, 0); |
| 166 | if (groupInfo != null) { | 171 | if (groupInfo != null) { |
| 167 | this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; | 172 | this.pageModel.isRecGroup = groupInfo.groupStrategy === 1; |
| @@ -169,7 +174,89 @@ export struct PageComponent { | @@ -169,7 +174,89 @@ export struct PageComponent { | ||
| 169 | } | 174 | } |
| 170 | // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | 175 | // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 |
| 171 | // for (const group of pageInfo.groups) { | 176 | // for (const group of pageInfo.groups) { |
| 172 | - this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)) | 177 | + this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); |
| 178 | + this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 179 | + if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 180 | + this.pageDto.compList.forEach((comp) => { | ||
| 181 | + if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 182 | + comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 183 | + } | ||
| 184 | + }); | ||
| 185 | + | ||
| 186 | + this.pageModel.viewType = ViewType.LOADED; | ||
| 187 | + this.pageModel.compList.push(...this.pageDto.compList); | ||
| 188 | + if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 189 | + this.pageModel.currentPage++; | ||
| 190 | + this.pageModel.hasMore = true; | ||
| 191 | + } else { | ||
| 192 | + this.pageModel.hasMore = false; | ||
| 193 | + } | ||
| 194 | + // // 二次请求,批查互动数据 | ||
| 195 | + // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 196 | + // // 刷新,替换所有数据 | ||
| 197 | + // this.pageModel.compList.replaceAll(...data) | ||
| 198 | + // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 199 | + // }) | ||
| 200 | + this.isFirstIn = false; | ||
| 201 | + Logger.debug(TAG, 'cj111'); | ||
| 202 | + // } else { | ||
| 203 | + // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 204 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 205 | + // } | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + // private async getLiveListData(pageInfo: PageInfoBean) { | ||
| 210 | + // // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 211 | + // for (const group of pageInfo.groups) { | ||
| 212 | + // this.pageDto = await PageViewModel.getPageData(this.pageModel, getContext(this)); | ||
| 213 | + // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString(); | ||
| 214 | + // if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | ||
| 215 | + // this.pageDto.compList.forEach((comp) => { | ||
| 216 | + // if (comp.compStyle === CompStyle.Zh_Grid_Layout_02 && this.liveReviewDTO && this.liveReviewDTO.list && this.liveReviewDTO.list.length > 0) { | ||
| 217 | + // comp.operDataList.push(...this.liveReviewDTO.list); | ||
| 218 | + // } | ||
| 219 | + // }); | ||
| 220 | + // | ||
| 221 | + // this.pageModel.viewType = ViewType.LOADED; | ||
| 222 | + // this.pageModel.compList.push(...this.pageDto.compList); | ||
| 223 | + // if (this.pageDto.compList.length === this.pageModel.pageSize) { | ||
| 224 | + // this.pageModel.currentPage++; | ||
| 225 | + // this.pageModel.hasMore = true; | ||
| 226 | + // } else { | ||
| 227 | + // this.pageModel.hasMore = false; | ||
| 228 | + // } | ||
| 229 | + // // // 二次请求,批查互动数据 | ||
| 230 | + // // PageViewModel.getInteractData(pageDto.compList).then((data: CompDTO[]) => { | ||
| 231 | + // // // 刷新,替换所有数据 | ||
| 232 | + // // this.pageModel.compList.replaceAll(...data) | ||
| 233 | + // // this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | ||
| 234 | + // // }) | ||
| 235 | + // this.isFirstIn = false; | ||
| 236 | + // Logger.debug(TAG, 'cj111'); | ||
| 237 | + // // } else { | ||
| 238 | + // // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 239 | + // // this.pageModel.viewType = ViewType.EMPTY; | ||
| 240 | + // } | ||
| 241 | + // } | ||
| 242 | + // } | ||
| 243 | + | ||
| 244 | + async getLiveListData(pageInfo: PageInfoBean) { | ||
| 245 | + // Logger.info(TAG, `getData id: ${this.pageId} , ${this.channelId} , navIndex: ${this.currentTopNavSelectedIndex}`); | ||
| 246 | + // this.pageModel.pageId = this.pageId; | ||
| 247 | + // this.pageModel.groupId = this.pageId; | ||
| 248 | + // this.pageModel.channelId = this.channelId; | ||
| 249 | + // this.pageModel.currentPage = 1; | ||
| 250 | + // let pageInfo = await PageViewModel.getPageUrlData(this.pageModel.pageId); | ||
| 251 | + // if (pageInfo == null) { | ||
| 252 | + // this.pageModel.viewType = ViewType.EMPTY; | ||
| 253 | + // return; | ||
| 254 | + // } | ||
| 255 | + Logger.debug(TAG, 'getPageUrlData ' + pageInfo.id); | ||
| 256 | + // pageInfo.groups.forEach(async (group) => { 不能按顺序加载用for...of替代 | ||
| 257 | + for (const group of pageInfo.groups) { | ||
| 258 | + this.pageDto = await PageViewModel.getLivePageData(this.pageModel.pageId, `${group.id}`, this.pageModel.channelId, group.groupStrategy | ||
| 259 | + , this.pageModel.currentPage, this.pageModel.pageSize, getContext(this)) | ||
| 173 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 260 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 174 | if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { | 261 | if (this.pageDto && this.pageDto.compList && this.pageDto.compList.length > 0) { |
| 175 | this.pageDto.compList.forEach((comp) => { | 262 | this.pageDto.compList.forEach((comp) => { |
| @@ -193,12 +280,11 @@ export struct PageComponent { | @@ -193,12 +280,11 @@ export struct PageComponent { | ||
| 193 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() | 280 | this.pageModel.timestamp = DateTimeUtils.getTimeStamp().toString() |
| 194 | }) | 281 | }) |
| 195 | this.isFirstIn = false | 282 | this.isFirstIn = false |
| 196 | - // } else { | ||
| 197 | - // Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 198 | - // this.pageModel.viewType = ViewType.EMPTY; | ||
| 199 | - // } | 283 | + } else { |
| 284 | + Logger.debug(TAG, 'aboutToAppear, data response page ' + this.pageId + ', comp list is empty.'); | ||
| 285 | + this.pageModel.viewType = ViewType.EMPTY; | ||
| 286 | + } | ||
| 200 | } | 287 | } |
| 201 | - | ||
| 202 | } | 288 | } |
| 203 | 289 | ||
| 204 | async getPreviewData() { | 290 | async getPreviewData() { |
| 1 | +import { SearchResultContentComponent } from './SearchResultContentComponent' | ||
| 1 | 2 | ||
| 2 | const TAG = "SearchResultComponent" | 3 | const TAG = "SearchResultComponent" |
| 3 | /** | 4 | /** |
| @@ -19,7 +20,7 @@ export struct SearchResultComponent{ | @@ -19,7 +20,7 @@ export struct SearchResultComponent{ | ||
| 19 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { | 20 | Tabs({ barPosition: BarPosition.Start, controller: this.controller }) { |
| 20 | ForEach(this.count, (item: string, index: number ) => { | 21 | ForEach(this.count, (item: string, index: number ) => { |
| 21 | TabContent(){ | 22 | TabContent(){ |
| 22 | - Text(item) | 23 | + SearchResultContentComponent() |
| 23 | }.tabBar(this.TabBuilder(index,item)) | 24 | }.tabBar(this.TabBuilder(index,item)) |
| 24 | }, (item: string, index: number) => index.toString()) | 25 | }, (item: string, index: number) => index.toString()) |
| 25 | } | 26 | } |
| @@ -63,4 +64,5 @@ export struct SearchResultComponent{ | @@ -63,4 +64,5 @@ export struct SearchResultComponent{ | ||
| 63 | .margin({right:'9lpx'}) | 64 | .margin({right:'9lpx'}) |
| 64 | .padding({left:'31lpx',right:index === this.count.length-1?"31lpx":"0lpx"}) | 65 | .padding({left:'31lpx',right:index === this.count.length-1?"31lpx":"0lpx"}) |
| 65 | } | 66 | } |
| 67 | + | ||
| 66 | } | 68 | } |
| @@ -3,7 +3,7 @@ import MinePagePersonalFunctionsItem from '../viewmodel/MinePagePersonalFunction | @@ -3,7 +3,7 @@ import MinePagePersonalFunctionsItem from '../viewmodel/MinePagePersonalFunction | ||
| 3 | import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsItem' | 3 | import MinePageCreatorFunctionsItem from '../viewmodel/MinePageCreatorFunctionsItem' |
| 4 | import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel'; | 4 | import MinePageMoreFunctionModel from '../viewmodel/MinePageMoreFunctionModel'; |
| 5 | import HashMap from '@ohos.util.HashMap'; | 5 | import HashMap from '@ohos.util.HashMap'; |
| 6 | -import { HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; | 6 | +import { HttpBizUtil, HttpUrlUtils, ResponseDTO, WDHttp } from 'wdNetwork'; |
| 7 | import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem'; | 7 | import { MineAppointmentListItem } from '../viewmodel/MineAppointmentListItem'; |
| 8 | import { Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 8 | import { Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 9 | import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem'; | 9 | import { MineFollowListDetailItem } from '../viewmodel/MineFollowListDetailItem'; |
| @@ -371,7 +371,8 @@ class MinePageDatasModel{ | @@ -371,7 +371,8 @@ class MinePageDatasModel{ | ||
| 371 | fetchMineUserLevelData() { | 371 | fetchMineUserLevelData() { |
| 372 | let url = HttpUrlUtils.getMineUserLevelDataUrl() | 372 | let url = HttpUrlUtils.getMineUserLevelDataUrl() |
| 373 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 373 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 374 | - return WDHttp.get<ResponseDTO<MineUserLevelItem>>(url, headers) | 374 | + // return WDHttp.get<ResponseDTO<MineUserLevelItem>>(url, headers) |
| 375 | + return HttpBizUtil.get<MineUserLevelItem>(url, headers) | ||
| 375 | }; | 376 | }; |
| 376 | 377 | ||
| 377 | async getMineUserLevelDataLocal(context: Context): Promise<MineUserLevelItem> { | 378 | async getMineUserLevelDataLocal(context: Context): Promise<MineUserLevelItem> { |
| @@ -409,7 +410,8 @@ class MinePageDatasModel{ | @@ -409,7 +410,8 @@ class MinePageDatasModel{ | ||
| 409 | fetchMineUserDetailData() { | 410 | fetchMineUserDetailData() { |
| 410 | let url = HttpUrlUtils.getMineUserDetailDataUrl() | 411 | let url = HttpUrlUtils.getMineUserDetailDataUrl() |
| 411 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 412 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 412 | - return WDHttp.get<ResponseDTO<MineUserDetailItem>>(url, headers) | 413 | + // return WDHttp.get<ResponseDTO<MineUserDetailItem>>(url, headers) |
| 414 | + return HttpBizUtil.get<MineUserDetailItem>(url, headers) | ||
| 413 | }; | 415 | }; |
| 414 | 416 | ||
| 415 | async getMineUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> { | 417 | async getMineUserDetailDataLocal(context: Context): Promise<MineUserDetailItem> { |
| @@ -2,6 +2,7 @@ import router from '@ohos.router' | @@ -2,6 +2,7 @@ import router from '@ohos.router' | ||
| 2 | import { Params } from 'wdBean'; | 2 | import { Params } from 'wdBean'; |
| 3 | import { StringUtils } from 'wdKit'; | 3 | import { StringUtils } from 'wdKit'; |
| 4 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; | 4 | import { WDRouterPage, WDRouterRule } from 'wdRouter'; |
| 5 | +import { CardParser } from '../components/CardParser'; | ||
| 5 | import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent'; | 6 | import { HomePageBottomComponent } from '../components/mine/home/HomePageBottomComponent'; |
| 6 | import MinePageDatasModel from '../model/MinePageDatasModel'; | 7 | import MinePageDatasModel from '../model/MinePageDatasModel'; |
| 7 | 8 | ||
| @@ -182,14 +183,37 @@ struct MineHomePage { | @@ -182,14 +183,37 @@ struct MineHomePage { | ||
| 182 | 183 | ||
| 183 | Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') | 184 | Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') |
| 184 | 185 | ||
| 186 | + Column(){ | ||
| 187 | + Column() { | ||
| 188 | + // 页签 | ||
| 189 | + Row({ space: 7 }) { | ||
| 190 | + Scroll() { | ||
| 191 | + Row() { | ||
| 192 | + this.TabBuilder(0,"评论") | ||
| 193 | + this.TabBuilder(1,"关注") | ||
| 194 | + } | ||
| 195 | + .justifyContent(FlexAlign.Start) | ||
| 196 | + } | ||
| 197 | + .align(Alignment.Start) | ||
| 198 | + .scrollable(ScrollDirection.Horizontal) | ||
| 199 | + .scrollBar(BarState.Off) | ||
| 200 | + .width('90%') | ||
| 201 | + .padding({left:'31lpx'}) | ||
| 202 | + } | ||
| 203 | + .alignItems(VerticalAlign.Bottom) | ||
| 204 | + .width('100%') | ||
| 205 | + } | ||
| 206 | + .alignItems(HorizontalAlign.Start) | ||
| 207 | + .width('100%') | ||
| 208 | + | ||
| 185 | //tab 页面 | 209 | //tab 页面 |
| 186 | Tabs({controller: this.controller}) { | 210 | Tabs({controller: this.controller}) { |
| 187 | TabContent() { | 211 | TabContent() { |
| 188 | HomePageBottomComponent({style:0}) | 212 | HomePageBottomComponent({style:0}) |
| 189 | - }.tabBar(this.TabBuilder(0,"评论")) | 213 | + } |
| 190 | TabContent() { | 214 | TabContent() { |
| 191 | HomePageBottomComponent({style:1}) | 215 | HomePageBottomComponent({style:1}) |
| 192 | - }.tabBar(this.TabBuilder(1,"关注")) | 216 | + } |
| 193 | } | 217 | } |
| 194 | .backgroundColor($r('app.color.white')) | 218 | .backgroundColor($r('app.color.white')) |
| 195 | .animationDuration(0) | 219 | .animationDuration(0) |
| @@ -197,6 +221,8 @@ struct MineHomePage { | @@ -197,6 +221,8 @@ struct MineHomePage { | ||
| 197 | this.currentIndex = index | 221 | this.currentIndex = index |
| 198 | }) | 222 | }) |
| 199 | .vertical(false) | 223 | .vertical(false) |
| 224 | + .barHeight(0) | ||
| 225 | + } | ||
| 200 | }.width("100%") | 226 | }.width("100%") |
| 201 | } | 227 | } |
| 202 | .edgeEffect(EdgeEffect.None) | 228 | .edgeEffect(EdgeEffect.None) |
| @@ -206,8 +232,8 @@ struct MineHomePage { | @@ -206,8 +232,8 @@ struct MineHomePage { | ||
| 206 | } | 232 | } |
| 207 | }.width('100%') | 233 | }.width('100%') |
| 208 | .layoutWeight(1) | 234 | .layoutWeight(1) |
| 209 | - | ||
| 210 | } | 235 | } |
| 236 | + | ||
| 211 | @Builder MineHomeTitleTransparent() { | 237 | @Builder MineHomeTitleTransparent() { |
| 212 | RelativeContainer() { | 238 | RelativeContainer() { |
| 213 | //标题栏目 | 239 | //标题栏目 |
| @@ -342,9 +368,9 @@ struct MineHomePage { | @@ -342,9 +368,9 @@ struct MineHomePage { | ||
| 342 | this.currentIndex = index | 368 | this.currentIndex = index |
| 343 | this.controller.changeIndex(this.currentIndex) | 369 | this.controller.changeIndex(this.currentIndex) |
| 344 | }) | 370 | }) |
| 345 | - .height('100%') | ||
| 346 | - .width('100%') | ||
| 347 | - .margin({right:'9lpx'}) | 371 | + .height('77lpx') |
| 372 | + .width('70lpx') | ||
| 373 | + .margin({right:'29lpx'}) | ||
| 348 | } | 374 | } |
| 349 | 375 | ||
| 350 | /** | 376 | /** |
| @@ -172,17 +172,42 @@ struct OtherNormalUserHomePage { | @@ -172,17 +172,42 @@ struct OtherNormalUserHomePage { | ||
| 172 | .width('100%') | 172 | .width('100%') |
| 173 | .backgroundColor($r('app.color.white')) | 173 | .backgroundColor($r('app.color.white')) |
| 174 | } | 174 | } |
| 175 | + | ||
| 175 | //间隔符 | 176 | //间隔符 |
| 176 | Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') | 177 | Divider().width('100%').height('12lpx').color($r('app.color.color_F5F5F5')).strokeWidth('12lpx') |
| 177 | 178 | ||
| 179 | + Column(){ | ||
| 180 | + Column() { | ||
| 181 | + // 页签 | ||
| 182 | + Row({ space: 7 }) { | ||
| 183 | + Scroll() { | ||
| 184 | + Row() { | ||
| 185 | + this.TabBuilder(0,"评论") | ||
| 186 | + this.TabBuilder(1,"关注") | ||
| 187 | + } | ||
| 188 | + .justifyContent(FlexAlign.Start) | ||
| 189 | + } | ||
| 190 | + .align(Alignment.Start) | ||
| 191 | + .scrollable(ScrollDirection.Horizontal) | ||
| 192 | + .scrollBar(BarState.Off) | ||
| 193 | + .width('90%') | ||
| 194 | + .padding({left:'31lpx'}) | ||
| 195 | + } | ||
| 196 | + .alignItems(VerticalAlign.Bottom) | ||
| 197 | + .width('100%') | ||
| 198 | + } | ||
| 199 | + .backgroundColor($r('app.color.white')) | ||
| 200 | + .alignItems(HorizontalAlign.Start) | ||
| 201 | + .width('100%') | ||
| 202 | + | ||
| 178 | //tab 页面 | 203 | //tab 页面 |
| 179 | Tabs({controller: this.controller}) { | 204 | Tabs({controller: this.controller}) { |
| 180 | TabContent() { | 205 | TabContent() { |
| 181 | OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum}) | 206 | OtherHomePageBottomCommentComponent({curUserId:this.curUserId,levelHead:this.levelHead,commentNum:$commentNum}) |
| 182 | - }.tabBar(this.TabBuilder(0,"评论")) | 207 | + } |
| 183 | TabContent() { | 208 | TabContent() { |
| 184 | OtherHomePageBottomFollowComponent({curUserId:this.curUserId}) | 209 | OtherHomePageBottomFollowComponent({curUserId:this.curUserId}) |
| 185 | - }.tabBar(this.TabBuilder(1,"关注")) | 210 | + } |
| 186 | } | 211 | } |
| 187 | .backgroundColor($r('app.color.white')) | 212 | .backgroundColor($r('app.color.white')) |
| 188 | .animationDuration(0) | 213 | .animationDuration(0) |
| @@ -190,6 +215,8 @@ struct OtherNormalUserHomePage { | @@ -190,6 +215,8 @@ struct OtherNormalUserHomePage { | ||
| 190 | this.currentIndex = index | 215 | this.currentIndex = index |
| 191 | }) | 216 | }) |
| 192 | .vertical(false) | 217 | .vertical(false) |
| 218 | + .barHeight(0) | ||
| 219 | + } | ||
| 193 | }.width("100%") | 220 | }.width("100%") |
| 194 | } | 221 | } |
| 195 | .edgeEffect(EdgeEffect.None) | 222 | .edgeEffect(EdgeEffect.None) |
| @@ -300,9 +327,9 @@ struct OtherNormalUserHomePage { | @@ -300,9 +327,9 @@ struct OtherNormalUserHomePage { | ||
| 300 | this.currentIndex = index | 327 | this.currentIndex = index |
| 301 | this.controller.changeIndex(this.currentIndex) | 328 | this.controller.changeIndex(this.currentIndex) |
| 302 | }) | 329 | }) |
| 303 | - .height('100%') | ||
| 304 | - .width('100%') | ||
| 305 | - .margin({right:'9lpx'}) | 330 | + .height('77lpx') |
| 331 | + .width('70lpx') | ||
| 332 | + .margin({right:'29lpx'}) | ||
| 306 | } | 333 | } |
| 307 | 334 | ||
| 308 | 335 |
| @@ -6,6 +6,7 @@ import { | @@ -6,6 +6,7 @@ import { | ||
| 6 | CompInfoBean, | 6 | CompInfoBean, |
| 7 | ContentDetailDTO, | 7 | ContentDetailDTO, |
| 8 | ContentDTO, | 8 | ContentDTO, |
| 9 | + contentListParams, | ||
| 9 | InteractDataDTO, | 10 | InteractDataDTO, |
| 10 | LiveReviewDTO, | 11 | LiveReviewDTO, |
| 11 | MorningEveningPaperDTO, | 12 | MorningEveningPaperDTO, |
| @@ -14,11 +15,10 @@ import { | @@ -14,11 +15,10 @@ import { | ||
| 14 | NewspaperTimeInfoBean, | 15 | NewspaperTimeInfoBean, |
| 15 | PageDTO, | 16 | PageDTO, |
| 16 | PageInfoBean, | 17 | PageInfoBean, |
| 18 | + PageInfoDTO, | ||
| 17 | postBatchAttentionStatusParams, | 19 | postBatchAttentionStatusParams, |
| 18 | postBatchAttentionStatusResult, | 20 | postBatchAttentionStatusResult, |
| 19 | postExecuteCollectRecordParams, | 21 | postExecuteCollectRecordParams, |
| 20 | - contentListParams, | ||
| 21 | - PageInfoDTO, | ||
| 22 | postExecuteLikeParams, | 22 | postExecuteLikeParams, |
| 23 | postInteractAccentionOperateParams, | 23 | postInteractAccentionOperateParams, |
| 24 | postRecommendListParams | 24 | postRecommendListParams |
| @@ -48,10 +48,10 @@ export class PageRepository { | @@ -48,10 +48,10 @@ export class PageRepository { | ||
| 48 | 48 | ||
| 49 | static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | 49 | static getCompInfoUrl(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { |
| 50 | let url = HttpUrlUtils.getHost(); | 50 | let url = HttpUrlUtils.getHost(); |
| 51 | - if(1 == groupStrategy){ | 51 | + if (1 == groupStrategy) { |
| 52 | //推荐 | 52 | //推荐 |
| 53 | url = url + HttpUrlUtils.COMP_REC_PATH; | 53 | url = url + HttpUrlUtils.COMP_REC_PATH; |
| 54 | - }else{ | 54 | + } else { |
| 55 | //非推荐 | 55 | //非推荐 |
| 56 | url = url + HttpUrlUtils.COMP_PATH; | 56 | url = url + HttpUrlUtils.COMP_PATH; |
| 57 | } | 57 | } |
| @@ -194,8 +194,14 @@ export class PageRepository { | @@ -194,8 +194,14 @@ export class PageRepository { | ||
| 194 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) | 194 | return WDHttp.get<ResponseDTO<PageInfoDTO>>(url, headers) |
| 195 | }; | 195 | }; |
| 196 | 196 | ||
| 197 | - static fetchCompData(pageId: string, groupId: string, channelId: string,groupStrategy:number, currentPage: number, pageSize: number) { | ||
| 198 | - let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId,groupStrategy, currentPage, pageSize) | 197 | + static fetchLivePageData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { |
| 198 | + let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 199 | + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | ||
| 200 | + return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | ||
| 201 | + }; | ||
| 202 | + | ||
| 203 | + static fetchCompData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number, pageSize: number) { | ||
| 204 | + let url = PageRepository.getCompInfoUrl(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 199 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); | 205 | let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); |
| 200 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) | 206 | return WDHttp.get<ResponseDTO<PageDTO>>(url, headers) |
| 201 | }; | 207 | }; |
| @@ -11,6 +11,15 @@ export class LogoutViewModel{ | @@ -11,6 +11,15 @@ export class LogoutViewModel{ | ||
| 11 | requestLogout(){ | 11 | requestLogout(){ |
| 12 | return new Promise<string>((success, fail) => { | 12 | return new Promise<string>((success, fail) => { |
| 13 | this.logout.requestLogout().then((data) => { | 13 | this.logout.requestLogout().then((data) => { |
| 14 | + LogoutViewModel.clearLoginInfo() | ||
| 15 | + success(data) | ||
| 16 | + }).catch((message: string) => { | ||
| 17 | + fail(message) | ||
| 18 | + }) | ||
| 19 | + }) | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + static clearLoginInfo() { | ||
| 14 | SPHelper.default.save(SpConstants.USER_FIRST_MARK, '') | 23 | SPHelper.default.save(SpConstants.USER_FIRST_MARK, '') |
| 15 | SPHelper.default.save(SpConstants.USER_ID, '') | 24 | SPHelper.default.save(SpConstants.USER_ID, '') |
| 16 | SPHelper.default.save(SpConstants.USER_JWT_TOKEN, '') | 25 | SPHelper.default.save(SpConstants.USER_JWT_TOKEN, '') |
| @@ -23,10 +32,5 @@ export class LogoutViewModel{ | @@ -23,10 +32,5 @@ export class LogoutViewModel{ | ||
| 23 | HttpUrlUtils.setUserId("") | 32 | HttpUrlUtils.setUserId("") |
| 24 | HttpUrlUtils.setUserType("") | 33 | HttpUrlUtils.setUserType("") |
| 25 | HttpUrlUtils.setUserToken('') | 34 | HttpUrlUtils.setUserToken('') |
| 26 | - success(data) | ||
| 27 | - }).catch((message: string) => { | ||
| 28 | - fail(message) | ||
| 29 | - }) | ||
| 30 | - }) | ||
| 31 | } | 35 | } |
| 32 | } | 36 | } |
| @@ -7,11 +7,9 @@ import { | @@ -7,11 +7,9 @@ import { | ||
| 7 | MorningEveningPaperDTO, | 7 | MorningEveningPaperDTO, |
| 8 | NavigationBodyDTO, | 8 | NavigationBodyDTO, |
| 9 | PageDTO, | 9 | PageDTO, |
| 10 | - PageInfoBean, | ||
| 11 | - PageInfoDTO | 10 | + PageInfoBean |
| 12 | } from 'wdBean'; | 11 | } from 'wdBean'; |
| 13 | 12 | ||
| 14 | - | ||
| 15 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 13 | import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; |
| 16 | import { ResponseDTO, } from 'wdNetwork'; | 14 | import { ResponseDTO, } from 'wdNetwork'; |
| 17 | import { PageRepository } from '../repository/PageRepository'; | 15 | import { PageRepository } from '../repository/PageRepository'; |
| @@ -145,7 +143,36 @@ export class PageViewModel extends BaseViewModel { | @@ -145,7 +143,36 @@ export class PageViewModel extends BaseViewModel { | ||
| 145 | 143 | ||
| 146 | async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { | 144 | async getPageData(pageModel: PageModel, context?: Context): Promise<PageDTO> { |
| 147 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); | 145 | Logger.debug(TAG, 'getPageData pageId: ' + pageModel.pageId); |
| 148 | - return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.isRecGroup==true?1:0,pageModel.currentPage, pageModel.pageSize)) | 146 | + return this.parseComp(PageRepository.fetchCompData(pageModel.pageId, pageModel.groupId, pageModel.channelId, pageModel.isRecGroup == true ? 1 : 0, pageModel.currentPage, pageModel.pageSize)) |
| 147 | + } | ||
| 148 | + | ||
| 149 | + async getLivePageData(pageId: string, groupId: string, channelId: string, groupStrategy: number, currentPage: number | ||
| 150 | + , pageSize: number, context: Context): Promise<PageDTO> { | ||
| 151 | + Logger.debug(TAG, 'getPageData pageId: ' + pageId); | ||
| 152 | + if (mock_switch) { | ||
| 153 | + return this.getPageData1(currentPage, context); | ||
| 154 | + } | ||
| 155 | + return new Promise<PageDTO>((success, error) => { | ||
| 156 | + PageRepository.fetchLivePageData(pageId, groupId, channelId, groupStrategy, currentPage, pageSize) | ||
| 157 | + .then((resDTO: ResponseDTO<PageDTO>) => { | ||
| 158 | + if (!resDTO || !resDTO.data) { | ||
| 159 | + Logger.error(TAG, 'getNavData then resDTO is empty'); | ||
| 160 | + error('resDTO is empty'); | ||
| 161 | + return | ||
| 162 | + } | ||
| 163 | + if (resDTO.code != 0) { | ||
| 164 | + Logger.error(TAG, `getNavData then code:${resDTO.code}, message:${resDTO.message}`); | ||
| 165 | + error('resDTO Response Code is failure'); | ||
| 166 | + return | ||
| 167 | + } | ||
| 168 | + Logger.info(TAG, "getNavData then,resDTO.timestamp:" + resDTO.timestamp); | ||
| 169 | + success(resDTO.data); | ||
| 170 | + }) | ||
| 171 | + .catch((err: Error) => { | ||
| 172 | + Logger.error(TAG, `getPageData catch, error.name : ${err.name}, error.message:${err.message}`); | ||
| 173 | + error(err); | ||
| 174 | + }) | ||
| 175 | + }) | ||
| 149 | } | 176 | } |
| 150 | 177 | ||
| 151 | private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { | 178 | private parseComp(getData: Promise<ResponseDTO<PageDTO>>): Promise<PageDTO> { |
| @@ -7,10 +7,8 @@ import cryptoFramework from '@ohos.security.cryptoFramework' | @@ -7,10 +7,8 @@ import cryptoFramework from '@ohos.security.cryptoFramework' | ||
| 7 | import buffer from '@ohos.buffer' | 7 | import buffer from '@ohos.buffer' |
| 8 | import { encryptMessage } from '../../utils/cryptoUtil' | 8 | import { encryptMessage } from '../../utils/cryptoUtil' |
| 9 | 9 | ||
| 10 | -import { | ||
| 11 | - SpConstants | ||
| 12 | -} from '../../../../../../../commons/wdNetwork/oh_modules/wdConstant/src/main/ets/constants/SpConstants' | ||
| 13 | import { HttpUrlUtils } from 'wdNetwork/src/main/ets/http/HttpUrlUtils' | 10 | import { HttpUrlUtils } from 'wdNetwork/src/main/ets/http/HttpUrlUtils' |
| 11 | +import { SpConstants } from 'wdConstant/Index' | ||
| 14 | 12 | ||
| 15 | const TAG = "LoginViewModel" | 13 | const TAG = "LoginViewModel" |
| 16 | 14 |
| 1 | -import { BottomNavigationComponent} from 'wdComponent'; | 1 | +import { BottomNavigationComponent, LogoutViewModel} from 'wdComponent'; |
| 2 | import { BreakpointConstants } from 'wdConstant'; | 2 | import { BreakpointConstants } from 'wdConstant'; |
| 3 | 3 | ||
| 4 | -import { BreakpointSystem, Logger } from 'wdKit'; | 4 | +import { BreakpointSystem, EmitterEventId, EmitterUtils, Logger } from 'wdKit'; |
| 5 | import router from '@ohos.router'; | 5 | import router from '@ohos.router'; |
| 6 | +import { promptAction } from '@kit.ArkUI'; | ||
| 6 | 7 | ||
| 7 | 8 | ||
| 8 | const TAG = 'MainPage'; | 9 | const TAG = 'MainPage'; |
| @@ -22,6 +23,9 @@ struct MainPage { | @@ -22,6 +23,9 @@ struct MainPage { | ||
| 22 | aboutToAppear() { | 23 | aboutToAppear() { |
| 23 | this.breakpointSystem.register() | 24 | this.breakpointSystem.register() |
| 24 | Logger.info(TAG, `aboutToAppear `); | 25 | Logger.info(TAG, `aboutToAppear `); |
| 26 | + EmitterUtils.receiveEvent(EmitterEventId.FORCE_USER_LOGIN_OUT, () => { | ||
| 27 | + LogoutViewModel.clearLoginInfo() | ||
| 28 | + }) | ||
| 25 | } | 29 | } |
| 26 | 30 | ||
| 27 | aboutToDisappear() { | 31 | aboutToDisappear() { |
| 1 | +import { Logger } from 'wdKit'; | ||
| 2 | +import { AudioDetailComponent } from 'wdComponent'; | ||
| 3 | +import router from '@ohos.router'; | ||
| 4 | +import { Params, Action } from 'wdBean'; | ||
| 5 | +const TAG = 'DynamicDetailPage'; | ||
| 6 | +@Entry | ||
| 7 | +@Component | ||
| 8 | +struct DynamicDetailPage { | ||
| 9 | + | ||
| 10 | + @State relId: string = '' | ||
| 11 | + @State contentId: string = '' | ||
| 12 | + @State relType: string = '' | ||
| 13 | + | ||
| 14 | + build() { | ||
| 15 | + Column() { | ||
| 16 | + AudioDetailComponent({ | ||
| 17 | + relId: this.relId, | ||
| 18 | + contentId: this.contentId, | ||
| 19 | + relType: this.relType | ||
| 20 | + }) | ||
| 21 | + } | ||
| 22 | + .height('100%') | ||
| 23 | + .width('100%') | ||
| 24 | + .backgroundColor('#20272E') | ||
| 25 | + } | ||
| 26 | + aboutToAppear() { | ||
| 27 | + let par:Action = router.getParams() as Action; | ||
| 28 | + let params = par?.params; | ||
| 29 | + this.relId = params?.extra?.relId || ''; | ||
| 30 | + this.relType = params?.extra?.relType || ''; | ||
| 31 | + this.contentId = params?.contentID || ''; | ||
| 32 | + } | ||
| 33 | +} |
-
Please register or login to post a comment