Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
yuzhilin
2024-04-12 09:48:45 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8f447bfdc72eadc72f6df0c755cdbb1069cc3141
8f447bfd
1 parent
3044a772
推荐列表
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
362 additions
and
83 deletions
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebComponent.ets
sight_harmony/features/wdBean/Index.ets
sight_harmony/features/wdBean/src/main/ets/bean/detail/MultiPictureDetailPageDTO.ts
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/page/ChannelSubscriptionLayout.ets
sight_harmony/features/wdComponent/src/main/ets/components/view/RecommendList.ets
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
sight_harmony/features/wdComponent/src/main/ets/viewmodel/DetailViewModel.ets
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_candle.png
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_candle_active.png
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_like.png
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_prayer.png
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_prayer_active.png
sight_harmony/commons/wdNetwork/src/main/ets/http/HttpUrlUtils.ets
View file @
8f447bf
...
...
@@ -210,6 +210,10 @@ export class HttpUrlUtils {
* */
static readonly DAILY_PAPER_TOPIC: string = "/api/rmrb-bff-display-zh/display/zh/c/dailyPaperTopic";
private static _hostUrl: string = HttpUrlUtils.HOST_PRODUCT;
/**
* 推荐列表
*/
static readonly RECOMMEND_LIST: string = "/api/rmrb-bff-display-zh/recommend/zh/c/list";
public static set hostUrl(value: string) {
HttpUrlUtils._hostUrl = value;
...
...
sight_harmony/commons/wdWebComponent/src/main/ets/pages/WdWebComponent.ets
View file @
8f447bf
...
...
@@ -12,7 +12,7 @@ const TAG = 'WdWebComponent';
export struct WdWebComponent {
private webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
//TODO 默认网页
webUrl: string = ConfigConstants.DETAIL_URL
webUrl: string
| Resource
= ConfigConstants.DETAIL_URL
/**
* 对外暴露webview的回调,能力
*/
...
...
sight_harmony/features/wdBean/Index.ets
View file @
8f447bf
...
...
@@ -34,7 +34,8 @@ export {
postExecuteLikeParams,
postExecuteCollectRecordParams,
contentListParams,
postInteractAccentionOperateParams
postInteractAccentionOperateParams,
postRecommendListParams
} from './src/main/ets/bean/detail/MultiPictureDetailPageDTO';
export { InteractParam, ContentBean } from './src/main/ets/bean/content/InteractParam';
...
...
sight_harmony/features/wdBean/src/main/ets/bean/detail/MultiPictureDetailPageDTO.ts
View file @
8f447bf
...
...
@@ -178,3 +178,13 @@ export interface postInteractAccentionOperateParams {
// userId: string;
status
:
number
;
}
export
interface
postRecommendListParams
{
imei
:
string
;
userId
?:
string
;
contentId
?:
string
;
relId
?:
string
;
contentType
?:
number
;
recType
:
number
;
channelId
?
:
string
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextPageComponent.ets
View file @
8f447bf
import { Action, ContentDetailDTO } from 'wdBean';
import { Logger, NumberFormatterUtils } from 'wdKit';
import {
Action,
ContentDetailDTO,
ContentDTO,
postRecommendListParams,
postExecuteLikeParams,
batchLikeAndCollectResult,
batchLikeAndCollectParams,
InteractDataDTO,
contentListParams,
} from 'wdBean';
import DetailViewModel from '../viewmodel/DetailViewModel';
import { ImageAndTextWebComponent } from './ImageAndTextWebComponent';
import router from '@ohos.router';
import { RecommendList } from '../components/view/RecommendList'
import { CommonConstants } from 'wdConstant'
import { HttpUrlUtils } from 'wdNetwork/Index';
import { WDRouterPage, WDRouterRule } from 'wdRouter/Index';
import { MultiPictureDetailViewModel } from '../viewmodel/MultiPictureDetailViewModel';
import { PageRepository } from '../repository/PageRepository';
const TAG = 'ImageAndTextPageComponent'
export interface OperationItem {
icon: Resource;
icon_check?: Resource;
text: string | Resource;
num?: number; // 个数
}
@Component
export struct ImageAndTextPageComponent {
scroller: Scroller = new Scroller();
action: Action = {} as Action
@State detailData: ContentDetailDTO = {} as ContentDetailDTO
@State contentDetailData: ContentDetailDTO = {} as ContentDetailDTO
@State recommendList: ContentDTO[] = []
@State newsStatusOfUser: batchLikeAndCollectResult | undefined = undefined // 点赞、收藏状态
@State interactData: InteractDataDTO = {} as InteractDataDTO
@State operationList: OperationItem[] = [
{
icon: $r('app.media.ic_comment'),
text: "评论",
},
{
icon: $r('app.media.ic_like_uncheck'),
icon_check: $r('app.media.ic_like_check'),
text: "点赞",
},
{
icon: $r('app.media.ic_collect_uncheck'),
icon_check: $r('app.media.ic_collect_check'),
text: "收藏",
},
{
icon: $r('app.media.ic_share'),
text: "分享"
}
]
build() {
RelativeContainer() {
RelativeContainer() {
Text(this.detailData?.publishTime)
.fontColor($r('app.color.color_B0B0B0'))
.fontSize($r('app.float.font_size_13'))
.id('date')
.alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End },
center:{anchor: "__container__", align:VerticalAlign.Center}})
Image($r('app.media.icon_ren_min_ri_bao'))
.width(70)
.height(28)
.alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center } })
}
.height(32)
.width('100%')
.id('image_text_detail_top')
.alignRules({ top: { anchor: "__container__", align: VerticalAlign.Top } })
.visibility(Visibility.None)
Image($r('app.media.line'))
.width('100%')
.height(6)
.objectFit(ImageFit.Contain)
.id('image_text_detail_top_line')
.alignRules({ top: { anchor: "image_text_detail_top", align: VerticalAlign.Bottom } })
.margin({ top: 10 })
.visibility(Visibility.Hidden)
RelativeContainer() {
Column() {
Column() {
// 发布时间
// Row() {
// Image($r('app.media.icon_ren_min_ri_bao'))
// .width(70)
// .height(28)
// Text(this.contentDetailData.publishTime)
// .fontColor($r('app.color.color_B0B0B0'))
// .fontSize($r('app.float.font_size_13'))
// .height('100%')
// .align(Alignment.End)
// }
// .width(CommonConstants.FULL_WIDTH)
// .height(32)
// .padding({ left: 15, right: 15, })
// .justifyContent(FlexAlign.SpaceBetween)
// .backgroundColor(Color.White)
// Row() {
// Image($r('app.media.line'))
// .width('100%')
// .height(6)
// .objectFit(ImageFit.Cover)
// .margin({ top: 10 })
// }
// .padding({ left: 15, right: 15, })
// .backgroundColor(Color.White)
Stack({ alignContent: Alignment.Bottom }) {
List() {
//详情展示区
ListItem() {
Column() {
ImageAndTextWebComponent({ contentDetailData: this.contentDetailData, action: this.action })
}.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
}
.backgroundColor(Color.White)
// if (this.contentDetailData.openLikes === 1) {
// ListItem() {
// // 点赞
// Row() {
// Row() {
// if (this.newsStatusOfUser?.likeStatus === '1') {
// Image(this.contentDetailData.likesStyle === 1 ? $r('app.media.ic_like_check') : (this.contentDetailData.likesStyle === 2 ? $r('app.media.icon_prayer_active') : $r('app.media.icon_candle_active')))
// .width(24)
// .height(24)
// .margin({ right: 5 })
// } else {
// Image(this.contentDetailData.likesStyle === 1 ? $r('app.media.icon_like') : (this.contentDetailData.likesStyle === 2 ? $r('app.media.icon_prayer') : $r('app.media.icon_candle')))
// .width(24)
// .height(24)
// .margin({ right: 5 })
// }
// Text(`${this.interactData?.likeNum || 0}`)
// .fontSize(16)
// .fontColor(this.newsStatusOfUser?.likeStatus === '1' ? '#ED2800' : '#999999')
// .fontWeight(500)
// }.alignItems(VerticalAlign.Center)
// .onClick(() => {
// this.toggleLikeStatus()
// })
//
// }.width(CommonConstants.FULL_WIDTH).height(80)
// .justifyContent(FlexAlign.Center)
// }
// .backgroundColor(Color.White)
// .margin({ bottom: 5 })
// }
//相关推荐区
// ListItem() {
// RecommendList({ recommendList: this.recommendList })
// }
// .backgroundColor(Color.White)
}
.width(CommonConstants.FULL_WIDTH)
.height(CommonConstants.FULL_HEIGHT)
.padding({ bottom: 56 })
.scrollBar(BarState.Off)
.edgeEffect(EdgeEffect.None)
//底部交互区
Row() {
Image($r('app.media.icon_arrow_left'))
.width(24)
.height(24)
.id('back')
.alignRules({ left: { anchor: "__container__", align: HorizontalAlign.Start },
center: { anchor: "__container__", align: VerticalAlign.Center } })
.onClick((event: ClickEvent) => {
router.back()
})
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
.id('forward')
.alignRules({ right: { anchor: "__container__", align: HorizontalAlign.End },
center: { anchor: "back", align: VerticalAlign.Center } })
Image($r('app.media.icon_listen'))
Row() {
Image($r('app.media.icon_comment'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('listen')
.alignRules({ right: { anchor: "forward", align: HorizontalAlign.Start },
center: { anchor: "back", align: VerticalAlign.Center } })
.id('comment')
Image($r('app.media.icon_star'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('star')
.alignRules({ right: { anchor: "listen", align: HorizontalAlign.Start },
center: { anchor: "back", align: VerticalAlign.Center } })
Image($r('app.media.icon_comment
'))
Image($r('app.media.icon_listen
'))
.width(24)
.height(24)
.margin({ right: 24 })
.id('comment')
.alignRules({ right: { anchor: "star", align: HorizontalAlign.Start },
center: { anchor: "back", align: VerticalAlign.Center } })
}
.width('100%')
.height(56)
.id('image_text_detail_bottom')
.alignRules({ bottom: { anchor: "__container__", align: VerticalAlign.Bottom } })
Image($r('app.media.icon_forward'))
.width(24)
.height(24)
Column() {
ImageAndTextWebComponent({ detailData: this.detailData, action: this.action })
}
.width('100%')
.alignRules({ top: { anchor: "image_text_detail_top_line", align: VerticalAlign.Bottom },
bottom: { anchor: "image_text_detail_bottom", align: VerticalAlign.Top } })
.id('image_text_detail_content')
}
.width('100%')
.height('100%')
.padding({ left: 16, right: 16 })
.width(CommonConstants.FULL_WIDTH)
.height(56)
.backgroundColor(Color.White)
.padding({ left: 15, right: 15, })
.justifyContent(FlexAlign.SpaceBetween)
}
}.backgroundColor("#f5f5f5")
}.width(CommonConstants.FULL_WIDTH).height(CommonConstants.FULL_HEIGHT)
}
async aboutToAppear
() {
private async getDetail
() {
let contentId: string = ''
let relId: string = ''
let relType: string = ''
...
...
@@ -122,14 +204,106 @@ export struct ImageAndTextPageComponent {
}
let detailBeans = await DetailViewModel.getDetailPageData(relId, contentId, relType)
if (detailBeans && detailBeans.length > 0) {
this.detailData = detailBeans[0];
this.contentDetailData = detailBeans[0];
//TODO
// if (this.contentDetailData.recommendShow === 1) {
// this.getRecommend()
// }
// if (this.contentDetailData.openLikes === 1) {
// this.getInteractDataStatus()
// this.queryContentInteractCount()
// }
}
}
}
private async getRecommend() {
let params: postRecommendListParams = {
imei: "8272c108-4fa2-34ce-80b9-bc425a7c2a7e",
userId: HttpUrlUtils.getUserId(),
contentId: String(this.contentDetailData.newsId),
recType: 1,
contentType: this.contentDetailData.newsType,
relId: this.contentDetailData?.reLInfo?.relId,
channelId: String(this.contentDetailData?.reLInfo?.channelId)
}
let recommendList = await DetailViewModel.postRecommendList(params)
if (recommendList && recommendList.length > 0) {
this.recommendList = recommendList;
}
}
// 已登录->查询用户对作品点赞、收藏状态
private async getInteractDataStatus() {
try {
const params: batchLikeAndCollectParams = {
contentList: [
{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
]
}
console.error(TAG, JSON.stringify(this.contentDetailData))
let data = await MultiPictureDetailViewModel.getInteractDataStatus(params)
console.error(TAG, '查询用户对作品点赞、收藏状态', JSON.stringify(data))
this.newsStatusOfUser = data[0];
Logger.info(TAG, `newsStatusOfUser:${JSON.stringify(this.newsStatusOfUser)}`)
} catch (exception) {
console.error(TAG, JSON.stringify(exception))
}
}
aboutToDisappear() {
/**
* 点赞、取消点赞
*/
toggleLikeStatus() {
// 未登录,跳转登录
if (!HttpUrlUtils.getUserId()) {
WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
return
}
const params: postExecuteLikeParams = {
status: this.newsStatusOfUser?.likeStatus === '1' ? '0' : '1',
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType + '',
}
PageRepository.postExecuteLike(params).then(res => {
console.log(TAG, '点赞、取消点赞', 'toggleLikeStatus==',)
if (this.newsStatusOfUser) {
this.newsStatusOfUser.likeStatus = this.newsStatusOfUser?.likeStatus == '1' ? '0' : '1'
this.queryContentInteractCount()
}
})
}
/**
* 查询点赞、收藏数量
*/
queryContentInteractCount() {
console.error(TAG, 'contentDetailData2222', JSON.stringify(this.contentDetailData))
const params: contentListParams = {
contentList: [{
contentId: this.contentDetailData?.newsId + '',
contentType: this.contentDetailData?.newsType,
}]
}
PageRepository.getContentInteract(params).then(res => {
if (res.data) {
this.interactData.likeNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.likeNum)
this.interactData.collectNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.collectNum)
this.interactData.commentNum = NumberFormatterUtils.formatNumberWithWan(res.data[0]?.commentNum)
}
console.log(TAG, '获取互动点赞等数据===', JSON.stringify(res))
console.log(TAG, 'this.interactData', JSON.stringify(this.interactData))
})
}
aboutToAppear() {
this.getDetail()
}
aboutToDisappear() {
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/components/ImageAndTextWebComponent.ets
View file @
8f447bf
...
...
@@ -8,14 +8,12 @@ import {
} from 'wdBean';
import { Logger } from 'wdKit';
import { WdWebComponent, WdWebLocalComponent } from 'wdWebComponent';
import { BridgeWebViewControl } from '../../../../../../commons/wdWebComponent/oh_modules/wdJsBridge/Index';
@Component
export struct ImageAndTextWebComponent {
webviewControl: BridgeWebViewControl = new BridgeWebViewControl()
action: Action = {} as Action
@State reload: number = 0;
@Prop @Watch('onDetailDataUpdated')
d
etailData: ContentDetailDTO = {} as ContentDetailDTO
@Prop @Watch('onDetailDataUpdated')
contentD
etailData: ContentDetailDTO = {} as ContentDetailDTO
onDetailDataUpdated() {
// if (this.action) {
...
...
@@ -77,10 +75,10 @@ export struct ImageAndTextWebComponent {
build() {
Column() {
if (this.
detailData && this.detailData.shareInfo && this.d
etailData.shareInfo.shareUrl){
if (this.
contentDetailData && this.contentDetailData.shareInfo && this.contentD
etailData.shareInfo.shareUrl){
WdWebComponent({
webviewControl: this.webviewControl,
webUrl: this.detailData?.shareInfo?.shareUrl,
webUrl: this.contentDetailData?.shareInfo?.shareUrl,
// webUrl: $rawfile('apph5/index.html'),
backVisibility: false,
})
}
...
...
sight_harmony/features/wdComponent/src/main/ets/components/page/ChannelSubscriptionLayout.ets
View file @
8f447bf
...
...
@@ -287,7 +287,9 @@ struct ChannelDialog {
.height('100%')
.justifyContent(FlexAlign.Center)
.backgroundColor(item.homeChannel === '1' || item.movePermitted === 0 ? '#F5F5F5' : '#ffffff')
.onClick(() => {
.onTouch((event?: TouchEvent) => {
if(event&&event.type === TouchType.Down){
console.log('onTouch')
if (this.isEditIng) {
if (item.delPermitted === 1) {
this.delChannelItem(index)
...
...
@@ -296,6 +298,7 @@ struct ChannelDialog {
this.confirm(index)
this.controller?.close()
}
}
})
}
.width('23%')
...
...
sight_harmony/features/wdComponent/src/main/ets/components/view/RecommendList.ets
0 → 100644
View file @
8f447bf
import { ContentDTO } from 'wdBean';
import { CommonConstants } from 'wdConstant';
import { Card3Component } from '../cardview/Card3Component'
import { Card6Component } from '../cardview/Card6Component'
const RECOMMEND_LIST_TITLE = '相关推荐'
@Component
export struct RecommendList {
@Prop recommendList: ContentDTO[] = [] as ContentDTO []
build() {
Column() {
if (this.recommendList.length > 0) {
Row() {
Image($r("app.media.redLine"))
.width(3)
.height(16)
.margin({ right: 4 })
Text(RECOMMEND_LIST_TITLE)
.width(CommonConstants.FULL_PARENT)
.fontSize($r('app.float.normal_text_size'))
.fontWeight(FontWeight.Bold)
.maxLines(1)
.textOverflow({ overflow: TextOverflow.Ellipsis }) // 超出的部分显示省略号。
}
.padding({ top: 15, left: 15, right: 15 })
.width(CommonConstants.FULL_PARENT)
.justifyContent(FlexAlign.Start)
}
ForEach(this.recommendList, (item: ContentDTO, index: number) => {
if (item.coverUrl) {
Card6Component({ contentDTO: item })
} else {
Card3Component({ contentDTO: item })
}
}, (item: ContentDTO) => JSON.stringify(item))
}.width('100%')
}
}
\ No newline at end of file
...
...
sight_harmony/features/wdComponent/src/main/ets/repository/PageRepository.ets
View file @
8f447bf
...
...
@@ -17,7 +17,9 @@ import {
postBatchAttentionStatusResult,
postExecuteCollectRecordParams,
postExecuteLikeParams,
postInteractAccentionOperateParams
postInteractAccentionOperateParams,
postRecommendListParams,
ContentDTO
} from 'wdBean';
const TAG = 'HttpRequest';
...
...
@@ -325,4 +327,17 @@ export class PageRepository {
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
return WDHttp.get<ResponseDTO<PageInfoBean>>(url, headers)
};
/**
* 获取推荐列表
* https://pdapis.pdnews.cn/api/rmrb-bff-display-zh/recommend/zh/c/list
* @param params
* @returns
* */
static postRecommendList(params:postRecommendListParams){
let url = HttpUrlUtils.getHost() + HttpUrlUtils.RECOMMEND_LIST
let headers: HashMap<string, string> = HttpUrlUtils.getCommonHeaders();
Logger.info(TAG, "postRecommendList url = " + url + JSON.stringify(params))
return WDHttp.post<ResponseDTO<ContentDTO[]>>(url, params, headers)
};
}
...
...
sight_harmony/features/wdComponent/src/main/ets/viewmodel/DetailViewModel.ets
View file @
8f447bf
import { ContentDetailDTO } from 'wdBean';
import { ContentDetailDTO
, ContentDTO, postRecommendListParams
} from 'wdBean';
import { Logger, StringUtils } from 'wdKit';
import { ResponseDTO, } from 'wdNetwork';
import { PageRepository } from '../repository/PageRepository';
...
...
@@ -42,6 +42,40 @@ export class DetailViewModel extends BaseViewModel {
})
}
/**
* 获取推荐列表
* @return {string} resDTO.data
* @param imei
* @param relType
* @param contentId
* @param userId
* @param relId
* @param contentType
* @returns
*/
postRecommendList(params: postRecommendListParams): Promise<ContentDTO[]> {
Logger.debug(TAG, 'postRecommendList contentId: ' + params.contentId);
return new Promise((success, error) => {
PageRepository.postRecommendList(params).then((resDTO: ResponseDTO<ContentDTO[]>) => {
if (!resDTO || !resDTO.data) {
Logger.error(TAG, 'postRecommendList then resDTO is empty');
error('resDTO is empty');
return
}
if (resDTO.code != 0) {
Logger.error(TAG, `postRecommendList then code:${resDTO.code}, message:${resDTO.message}`);
error('resDTO Response Code is failure');
return
}
Logger.info(TAG, "postRecommendList then,resDTO.timeStamp:" + resDTO.timestamp);
success(resDTO.data);
}).catch((err: Error) => {
Logger.error(TAG, `postRecommendList catch, error.name : ${err.name}, error.message:${err.message}`);
error(err);
})
})
}
private dataTranslate(json: string): ContentDetailDTO | null {
if (StringUtils.isEmpty(json)) {
return null;
...
...
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_candle.png
0 → 100644
View file @
8f447bf
861 Bytes
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_candle_active.png
0 → 100644
View file @
8f447bf
984 Bytes
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_like.png
0 → 100644
View file @
8f447bf
1.17 KB
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_prayer.png
0 → 100644
View file @
8f447bf
1.3 KB
sight_harmony/features/wdComponent/src/main/resources/base/media/icon_prayer_active.png
0 → 100644
View file @
8f447bf
2.04 KB
Please
register
or
login
to post a comment