王士厅

多图详情页增加comp,调详情接口

@@ -44,6 +44,17 @@ export class HttpUrlUtils { @@ -44,6 +44,17 @@ export class HttpUrlUtils {
44 */ 44 */
45 static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData"; 45 static readonly INTERACT_DATA_PATH: string = "/api/rmrb-contact/contact/zh/c/content/interactData";
46 46
  47 + // 多图(图集)详情页
  48 + /**
  49 + * 批量查询内容当前用户点赞、收藏状态
  50 + */
  51 + static readonly INTERACT_DATA_STATUS: string = "/api/rmrb-interact/interact/zh/c/batchLikeAndCollect/status";
  52 +
  53 + /**
  54 + * 浏览历史新增、删除接口
  55 + */
  56 + static readonly INTERACT_BROWS_OPERATE: string = "/api/rmrb-interact/interact/zh/c/brows/operate";
  57 +
47 /** 58 /**
48 * 电子报信息 59 * 电子报信息
49 */ 60 */
@@ -23,6 +23,8 @@ export { Pic } from './src/main/ets/bean/content/Pic' @@ -23,6 +23,8 @@ export { Pic } from './src/main/ets/bean/content/Pic'
23 23
24 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO'; 24 export { InteractDataDTO } from './src/main/ets/bean/content/InteractDataDTO';
25 25
  26 +export { InteractDataStatusDTO } from './src/main/ets/bean/detail/MultiPictureDetailPageDTO';
  27 +
26 export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam'; 28 export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
27 29
28 export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean'; 30 export { LabelBean } from './src/main/ets/bean/component/extra/LabelBean';
@@ -85,4 +87,3 @@ export { OperDataList } from './src/main/ets/bean/morningevening/OperDataList'; @@ -85,4 +87,3 @@ export { OperDataList } from './src/main/ets/bean/morningevening/OperDataList';
85 87
86 export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo'; 88 export { ShareInfo } from './src/main/ets/bean/morningevening/ShareInfo';
87 89
88 -  
  1 +/*
  2 + * 多图(图集)详情
  3 + * */
  4 +// 批量查询内容当前用户点赞、收藏状态
  5 +export interface InteractDataStatusDTO {
  6 + contentId: string;
  7 + contentType: number;
  8 + contentRelId: string;
  9 + relType: number;
  10 + likeStatus: number;
  11 + collectStatus: number;
  12 +}
@@ -51,3 +51,5 @@ export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardCo @@ -51,3 +51,5 @@ export { BigPicCardComponent } from "./src/main/ets/components/view/BigPicCardCo
51 export { HeadPictureCardComponent } from "./src/main/ets/components/view/HeadPictureCardComponent" 51 export { HeadPictureCardComponent } from "./src/main/ets/components/view/HeadPictureCardComponent"
52 52
53 export { ZhGridLayoutComponent } from "./src/main/ets/components/view/ZhGridLayoutComponent" 53 export { ZhGridLayoutComponent } from "./src/main/ets/components/view/ZhGridLayoutComponent"
  54 +
  55 +export { MultiPictureDetailPageComponent } from "./src/main/ets/components/MultiPictureDetailPageComponent"
  1 +import { Logger } from 'wdKit';
  2 +import { ContentDetailDTO } from 'wdBean';
  3 +import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
  4 +import display from '@ohos.display';
  5 +import font from '@ohos.font';
  6 +
  7 +const TAG = 'MultiPictureDetailPageComponent';
  8 +
  9 +@Component
  10 +export struct MultiPictureDetailPageComponent {
  11 + private displayTool = display.getDefaultDisplaySync()
  12 + private screenWidth: number = 0
  13 + private picWidth: number = 0
  14 + @State picHeight: number = 0
  15 + @State relId: string = '500005189942'
  16 + @State contentId: string = '30043715146'
  17 + @State relType: string = '1'
  18 + @State contentDetailData: ContentDetailDTO[] = [{}] as ContentDetailDTO[]
  19 + @Provide @Watch('onCurrentPageNumUpdated') currentPageNum: string = '01'
  20 + private swiperController: SwiperController = new SwiperController()
  21 + @State swiperIndex: number = 0;
  22 +
  23 + //watch监听页码回调
  24 + onCurrentPageNumUpdated(): void {
  25 + Logger.info(TAG, `currentPageNum:${this.currentPageNum}`, )
  26 + let _swiperIndex = Number.parseInt(this.currentPageNum)
  27 + Logger.info(TAG, `_swiperIndex:${_swiperIndex}`)
  28 + this.swiperIndex = _swiperIndex > 0 ? _swiperIndex - 1 : _swiperIndex
  29 + }
  30 +
  31 +
  32 + async aboutToAppear() {
  33 + //获取宽高尺寸
  34 + this.screenWidth = this.displayTool.width
  35 + this.picWidth = this.screenWidth - vp2px(52)
  36 + this.picHeight = this.picWidth * 566 / 378
  37 + //注册字体
  38 + font.registerFont({
  39 + familyName: 'BebasNeue_Regular',
  40 + familySrc: $rawfile('font/BebasNeue_Regular.otf')
  41 + })
  42 + this.getContentDetailData()
  43 + }
  44 +
  45 + aboutToDisappear() {
  46 +
  47 + }
  48 +
  49 + build() {
  50 + RelativeContainer() {
  51 + if (this.contentDetailData && this.contentDetailData.length > 0) {
  52 + Swiper(this.swiperController) {
  53 + ForEach(this.contentDetailData, (item: ContentDetailDTO, index: number) => {
  54 + // ENewspaperItemComponent({ newspaperListItemBean: item })
  55 + })
  56 + }
  57 + .index(this.swiperIndex)
  58 + .width('100%')
  59 + .height(px2vp(this.picHeight) + 32)
  60 + .vertical(true)
  61 + .autoPlay(false)
  62 + .cachedCount(3)
  63 + .indicator(false)
  64 + .displayCount(1)
  65 + .margin({ top: 35, left: 10, right: 10 })
  66 + .id('e_newspaper_content')
  67 + .alignRules({
  68 + top: { anchor: "e_newspaper_top", align: VerticalAlign.Bottom },
  69 + middle: { anchor: "__container__", align: HorizontalAlign.Center }
  70 + })
  71 + .onChange((index: number) => {
  72 + this.swiperIndex = index
  73 + })
  74 + }}
  75 + }
  76 +
  77 + private async getContentDetailData() {
  78 + try {
  79 + let data = await MultiPictureDetailViewModel.getDetailData(this.relId, this.contentId, this.relType)
  80 + this.contentDetailData = data;
  81 + Logger.info(TAG, `contentDetailData:${JSON.stringify(this.contentDetailData)}`)
  82 + } catch (exception) {
  83 +
  84 + }
  85 + }
  86 +}
  1 +import { ToastUtils, Logger } from 'wdKit';
  2 +
  3 +export interface OperationItem {
  4 + icon: Resource;
  5 +
  6 + // icon_selected: Resource;
  7 + text: string | Resource;
  8 + num?: number; // 个数
  9 +}
  10 +
  11 +const FULL_PARENT: string = '100%';
  12 +
  13 +const TAG = 'OperRowListView';
  14 +
  15 +@Entry
  16 +@Component
  17 +export struct OperRowListView {
  18 + @State operationList: OperationItem[] = [
  19 + {
  20 + icon: $r('app.media.ic_like_uncheck'),
  21 + text: "点赞",
  22 + num: 6622
  23 + },
  24 + {
  25 + icon: $r('app.media.ic_collect_uncheck'),
  26 + text: "收藏",
  27 + num: 662,
  28 + },
  29 + {
  30 + icon: $r('app.media.ic_comment'),
  31 + text: "评论",
  32 + num: 500,
  33 + },
  34 + {
  35 + icon: $r('app.media.ic_share'),
  36 + text: "分享"
  37 + }
  38 + ]
  39 +
  40 + aboutToAppear() {
  41 + }
  42 +
  43 + build() {
  44 + // List({ space: 0, initialIndex: 0 }) {
  45 + // ForEach(this.operationList, (item: OperationItem, index: number) => {
  46 + // ListItem() {
  47 + // this.buildOperationItem(item, index)
  48 + // }
  49 + // }, (item: OperationItem, index: number) => JSON.stringify(item))
  50 + // }
  51 + // .width(48)
  52 + // .height(250)
  53 + // // .margin({ bottom: 100 })
  54 + // .backgroundColor(Color.Red)
  55 + // // .listDirection(Axis.Vertical) // 默认值:Axis.Vertical
  56 + // // .lanes(this.buildLanes()) // 行/列数,一列 // 默认值:1
  57 + // .cachedCount(2)
  58 + // .scrollBar(BarState.Off)
  59 + // .nestedScroll({
  60 + // scrollForward: NestedScrollMode.PARENT_FIRST,
  61 + // scrollBackward: NestedScrollMode.SELF_FIRST
  62 + // })
  63 +
  64 + Column() {
  65 + ForEach(this.operationList, (item: OperationItem, index: number) => {
  66 + this.buildOperationItem(item, index)
  67 + }, (item: OperationItem, index: number) => JSON.stringify(item))
  68 + }
  69 + .width(48)
  70 + }
  71 +
  72 + /**
  73 + * 组件项
  74 + *
  75 + * @param programmeBean item 组件项
  76 + */
  77 + @Builder
  78 + buildOperationItem(item: OperationItem, index: number) {
  79 + Column() {
  80 + Image(item.icon)
  81 + .width('100%')
  82 + .aspectRatio(1)
  83 + // .borderRadius(6)
  84 +
  85 + Text(item.text)
  86 + .width('100%')// .margin({ top: 4, left: 6, right: 6 })// .backgroundColor(Color.Brown)
  87 + .fontWeight(FontWeight.Normal)
  88 + .textAlign(TextAlign.Center)
  89 + .fontSize(13)
  90 + .fontColor('#FFFFFF')
  91 + .maxLines(1)
  92 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  93 + }
  94 + .margin(5)
  95 + // .backgroundColor(Color.Black)
  96 + .alignItems(HorizontalAlign.Center)
  97 + .hoverEffect(HoverEffect.Scale)
  98 + .onClick((event: ClickEvent) => {
  99 + Logger.info(TAG, `buildOperationItem onClick event index: ${index}`);
  100 + ToastUtils.showToast('体验版,本功能暂未开发', 1000);
  101 + })
  102 + }
  103 +}
@@ -5,6 +5,7 @@ import { @@ -5,6 +5,7 @@ import {
5 CompInfoBean, 5 CompInfoBean,
6 ContentDetailDTO, 6 ContentDetailDTO,
7 InteractDataDTO, 7 InteractDataDTO,
  8 + InteractDataStatusDTO,
8 MorningEveningPaperDTO, 9 MorningEveningPaperDTO,
9 NavigationBodyDTO, 10 NavigationBodyDTO,
10 NewspaperListBean, 11 NewspaperListBean,
@@ -69,6 +70,20 @@ export class PageRepository { @@ -69,6 +70,20 @@ export class PageRepository {
69 return url; 70 return url;
70 } 71 }
71 72
  73 + // 批量查询内容当前用户点赞、收藏状态
  74 + static getInteractDataStatusUrl() {
  75 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_DATA_STATUS;
  76 + Logger.info(TAG, "getInteractDataStatusUrl url = " + url)
  77 + return url;
  78 + }
  79 +
  80 + // 浏览历史新增、删除接口
  81 + static getInteractBrowsOperateUrl() {
  82 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.INTERACT_BROWS_OPERATE;
  83 + Logger.info(TAG, "getInteractBrowsOperateUrl url = " + url)
  84 + return url;
  85 + }
  86 +
72 static getNewspaperInfoUrl(date: string) { 87 static getNewspaperInfoUrl(date: string) {
73 let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_INFO_PATH + "?date=" + date; 88 let url = HttpUrlUtils.getHost() + HttpUrlUtils.E_NEWSPAPER_INFO_PATH + "?date=" + date;
74 Logger.info(TAG, "getNewspaperInfoUrl url = " + url) 89 Logger.info(TAG, "getNewspaperInfoUrl url = " + url)
@@ -153,6 +168,20 @@ export class PageRepository { @@ -153,6 +168,20 @@ export class PageRepository {
153 return WDHttp.post<ResponseDTO<InteractDataDTO[]>>(url, param, headers) 168 return WDHttp.post<ResponseDTO<InteractDataDTO[]>>(url, param, headers)
154 }; 169 };
155 170
  171 + // 批量查询内容当前用户点赞、收藏状态
  172 + static fetchInteractDataStatus(param: object) {
  173 + let url = PageRepository.getInteractDataStatusUrl()
  174 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  175 + return WDHttp.post<ResponseDTO<InteractDataStatusDTO[]>>(url, param, headers)
  176 + };
  177 +
  178 + // 浏览历史新增、删除接口
  179 + static fetchInteractBrowsOperate(param: object) {
  180 + let url = PageRepository.getInteractBrowsOperateUrl()
  181 + let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  182 + return WDHttp.post<ResponseDTO<null>>(url, param, headers)
  183 + };
  184 +
156 static fetchNewspaperInfo(date: string) { 185 static fetchNewspaperInfo(date: string) {
157 let url = PageRepository.getNewspaperInfoUrl(date) 186 let url = PageRepository.getNewspaperInfoUrl(date)
158 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders(); 187 let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
  1 +import { Logger } from 'wdKit';
  2 +import { ResponseDTO } from 'wdNetwork';
  3 +import { ContentDetailDTO } from 'wdBean';
  4 +import { PageRepository } from '../repository/PageRepository';
  5 +
  6 +const TAG = 'MultiPictureDetailViewModel';
  7 +
  8 +export class MultiPictureDetailViewModel {
  9 +
  10 + /*fetchDetailData
  11 + fetchInteractData
  12 + fetchInteractDataStatus
  13 + fetchInteractBrowsOperate*/
  14 +
  15 + static async getDetailData(relId: string, contentId: string, relType: string): Promise<ContentDetailDTO[]> {
  16 + return new Promise<ContentDetailDTO[]>((success, error) => {
  17 + Logger.info(TAG, `fetchDetailData start`);
  18 + PageRepository.fetchDetailData(relId, contentId, relType).then((resDTO: ResponseDTO<ContentDetailDTO[]>) => {
  19 + if (!resDTO || !resDTO.data) {
  20 + Logger.error(TAG, 'fetchDetailData is empty');
  21 + error('resDTO is empty');
  22 + return
  23 + }
  24 + if (resDTO.code != 0) {
  25 + Logger.error(TAG, `fetchDetailData then code:${resDTO.code}, message:${resDTO.message}`);
  26 + error('resDTO Response Code is failure');
  27 + return
  28 + }
  29 + Logger.info(TAG, "fetchDetailData then,navResDTO.timestamp:" + resDTO.timestamp);
  30 + success(resDTO.data);
  31 + }).catch((err: Error) => {
  32 + Logger.error(TAG, `fetchDetailData catch, error.name : ${err.name}, error.message:${err.message}`);
  33 + error(err);
  34 + })
  35 + })
  36 + }
  37 +}
  1 +import { Logger } from 'wdKit';
  2 +import { MultiPictureDetailPageComponent } from 'wdComponent';
  3 +
  4 +const TAG = 'MultiPictureDetailPage';
  5 +
  6 +/**
  7 + * 多图(图集详情页)
  8 + */
1 @Entry 9 @Entry
2 @Component 10 @Component
3 struct MultiPictureDetailPage { 11 struct MultiPictureDetailPage {
4 - @State message: string = 'Hello World';  
5 12
6 build() { 13 build() {
7 Row() { 14 Row() {
8 Column() { 15 Column() {
9 - Text(this.message)  
10 - .fontSize(50)  
11 - .fontWeight(FontWeight.Bold) 16 + MultiPictureDetailPageComponent()
12 } 17 }
13 - .width('100%')  
14 } 18 }
15 - .height('100%') 19 + }
  20 +
  21 + pageTransition(){
  22 + // 定义页面进入时的效果,从右边侧滑入
  23 + PageTransitionEnter({ type: RouteType.None, duration: 300 })
  24 + .slide(SlideEffect.Right)
  25 + // 定义页面退出时的效果,向右边侧滑出
  26 + PageTransitionExit({ type: RouteType.None, duration: 300 })
  27 + .slide(SlideEffect.Right)
  28 + }
  29 +
  30 + aboutToAppear() {
  31 + Logger.info(TAG, 'aboutToAppear');
  32 + }
  33 +
  34 + aboutToDisappear() {
  35 + Logger.info(TAG, 'aboutToDisappear');
  36 + }
  37 +
  38 + onBackPress() {
  39 + Logger.info(TAG, 'onBackPress');
16 } 40 }
17 } 41 }