wangliang_wd

feat:增加互动消息

@@ -135,6 +135,14 @@ export class HttpUrlUtils { @@ -135,6 +135,14 @@ export class HttpUrlUtils {
135 */ 135 */
136 static readonly APPOINTMENT_ExecuteCollcet_PATH: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord"; 136 static readonly APPOINTMENT_ExecuteCollcet_PATH: string = "/api/rmrb-interact/interact/zh/c/collect/executeCollcetRecord";
137 /** 137 /**
  138 + * 个人中心 - 消息
  139 + */
  140 + static readonly APPOINTMENT_MessageList_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private";
  141 + /**
  142 + * 个人中心 - 消息 点赞数
  143 + */
  144 + static readonly APPOINTMENT_getMessageLikeCount_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/getLikeCount";
  145 + /**
138 * 个人中心 我的评论列表 146 * 个人中心 我的评论列表
139 */ 147 */
140 static readonly MINE_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/myCommentList"; 148 static readonly MINE_COMMENT_LIST_DATA_PATH: string = "/api/rmrb-comment/comment/zh/c/myCommentList";
@@ -463,6 +471,16 @@ export class HttpUrlUtils { @@ -463,6 +471,16 @@ export class HttpUrlUtils {
463 return url 471 return url
464 } 472 }
465 473
  474 + static getMessageListDataUrl() {
  475 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_MessageList_PATH
  476 + return url
  477 + }
  478 +
  479 + static getMessageLikeCount() {
  480 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_getMessageLikeCount_PATH
  481 + return url
  482 + }
  483 +
466 static getExecuteCollcetUrl() { 484 static getExecuteCollcetUrl() {
467 let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH 485 let url = HttpUrlUtils.getHost() + HttpUrlUtils.APPOINTMENT_ExecuteCollcet_PATH
468 return url 486 return url
  1 +import { ContentDTO } from 'wdBean/Index';
  2 +import { ProcessUtils } from 'wdRouter/Index';
  3 +import { InteractMessageModel } from '../../model/InteractMessageModel'
1 4
2 @Component 5 @Component
3 export struct InteractMComponent { 6 export struct InteractMComponent {
  7 + messageModel:InteractMessageModel = new InteractMessageModel;
  8 +///"remark": "{"beReply":"乐事薯片,大家的最爱!!",
  9 + // "headUrl":"https: //uatjdcdnphoto.aikan.pdnews.cn//zhbj/img/user/2023122211/2A59F725E69849A38CEE8823B0D9D141.jpg",
  10 + // "contentId":"30035774121","contentRelObjectid":"2012","contentTitle":"乐事推出华夏风光限定罐七款城市地标包装让出游“有滋有味”",
  11 + // "commentContent":"大家都爱吃!!","userName":"人民日报网友a8dKCV","userId":"504964178466309","contentRelId":"500002866426",
  12 + // "shareUrl":"https: //pd-people-uat.pdnews.cn/column/30035774121-500002866426","userType":"1",
  13 + // "contentRelType":"1","visitor":"0","contentType":"8"}",
  14 +
4 build() { 15 build() {
5 Row(){ 16 Row(){
6 - Image('')  
7 - .backgroundColor(Color.Red) 17 + Image(this.messageModel.InteractMsubM.headUrl)
8 .width(36) 18 .width(36)
9 .height(36) 19 .height(36)
10 .borderRadius(18) 20 .borderRadius(18)
11 21
12 Column(){ 22 Column(){
13 Row(){ 23 Row(){
14 - Text('用户名') 24 + Text(this.messageModel.InteractMsubM.userName)
15 .fontSize('14fp').fontColor('#222222') 25 .fontSize('14fp').fontColor('#222222')
16 26
17 - Text('回复了你的评论') 27 + Text(this.buildContentString())
18 .fontSize('14fp').fontColor('#999999') 28 .fontSize('14fp').fontColor('#999999')
19 .margin({left:5}) 29 .margin({left:5})
20 }.width('100%') 30 }.width('100%')
21 31
22 - Text('两天前') 32 + Text(this.messageModel.time)
23 .margin({top:2}) 33 .margin({top:2})
24 - .fontSize('12fp').fontColor('#B0B0B0')  
25 -  
26 - Text('评论内容')  
27 - .margin({top:8,bottom:10})  
28 - .fontSize('16fp').fontColor('#222222')  
29 - .width('100%')  
30 - .constraintSize({maxHeight:500}) 34 + .fontSize('12fp').fontColor('#B0B0B0').margin({top:10,bottom:10})
31 35
32 - Column(){  
33 - Text('[你的评论]乐事薯片,大家的最爱').fontSize('14fp').fontColor('#666666').constraintSize({maxHeight:500})  
34 - .margin({top:5,bottom:5}) 36 + if (this.messageModel.contentType === '208' || this.messageModel.contentType === '209'){
  37 + Text(this.messageModel.message)
  38 + .margin({bottom:10})
  39 + .fontSize('16fp').fontColor('#222222')
35 .width('100%') 40 .width('100%')
  41 + .constraintSize({maxHeight:500})
  42 + }
36 43
37 - Divider()  
38 - .color('#f5f5f5')  
39 - .backgroundColor('#f5f5f5')  
40 - .width('100%')  
41 - .height(1) 44 + Column(){
  45 + if (this.messageModel.contentType === '207' || this.messageModel.contentType === '209'){
  46 + Text('[你的评论]'+this.buildCommentContent()).fontSize('14fp').fontColor('#666666').constraintSize({maxHeight:500})
  47 + .margin({top:15,bottom:10})
  48 + .width('100%')
42 49
  50 + Divider()
  51 + .color('#EDEDED')
  52 + .backgroundColor('#EDEDED')
  53 + .width('100%')
  54 + .height(1)
  55 + }
43 Row(){ 56 Row(){
44 - Text('乐事薯片,大家的最爱!!!!').fontSize('12fp').fontColor('#666666').constraintSize({maxHeight:500}) 57 + Image($r('app.media.MessageOriginTextIcon'))
  58 + .width('12')
  59 + .height('12')
  60 + Text(this.messageModel.InteractMsubM.contentTitle)
  61 + .fontSize('12fp')
  62 + .fontColor('#666666')
  63 + .maxLines(1)
  64 + .width('90%')
  65 + .textOverflow({overflow:TextOverflow.Ellipsis})
45 66
46 Blank() 67 Blank()
47 68
48 Image($r('app.media.mine_user_edit')) 69 Image($r('app.media.mine_user_edit'))
49 .width('12') 70 .width('12')
50 .height('12') 71 .height('12')
51 - }.margin({top:5,bottom:5}).width('100%')  
52 - }.alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)  
53 - }.padding({left:5}).alignItems(HorizontalAlign.Start)  
54 - }.padding({top:5,left:16,right:16}).width('100%').height(160).alignItems(VerticalAlign.Top).backgroundColor(Color.Red) 72 + }.margin({top:10,bottom:15})
  73 + }.padding({left:10,right:10}).alignItems(HorizontalAlign.Start).backgroundColor('#f5f5f5').borderRadius(5)
  74 + .onClick(()=>{
  75 + let contentDTO :ContentDTO = new ContentDTO();
  76 + contentDTO.objectType = this.messageModel.InteractMsubM.contentType
  77 + contentDTO.objectId = this.messageModel.InteractMsubM.contentId
  78 + ProcessUtils.processPage(contentDTO)
  79 + })
  80 + }.padding({left:5,right:5}).alignItems(HorizontalAlign.Start).width('90%')
  81 + }.padding({top:10,left:16,right:16}).width('100%').alignItems(VerticalAlign.Top)
  82 + }
  83 +
  84 + buildContentString(): string {
  85 + let contentString: string = ''
  86 + if (this.messageModel.contentType === '206') {
  87 + contentString = '赞了你的作品'
  88 + }else if(this.messageModel.contentType === '207'){
  89 + contentString = '赞了你的评论'
  90 + }else if(this.messageModel.contentType === '208'){
  91 + contentString = '评论了你的作品'
  92 + }else if(this.messageModel.contentType === '209'){
  93 + contentString = '回复了你的评论'
  94 + }else if(this.messageModel.contentType === '210'){
  95 + contentString = '转发了您的作品'
  96 + }else if(this.messageModel.contentType === '211'){
  97 + contentString = '关注了你'
  98 + }
  99 + return contentString;
  100 + }
  101 + buildCommentContent(): string {
  102 + let contentString : string = this.messageModel.contentType === '207'?this.messageModel.message:this.messageModel.InteractMsubM.beReply;
  103 + return contentString;
55 } 104 }
56 } 105 }
1 import { StringUtils, ToastUtils } from 'wdKit/Index' 1 import { StringUtils, ToastUtils } from 'wdKit/Index'
  2 +import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
2 import MinePageDatasModel from '../../../model/MinePageDatasModel' 3 import MinePageDatasModel from '../../../model/MinePageDatasModel'
3 import { MessageItem } from '../../../viewmodel/MessageItem' 4 import { MessageItem } from '../../../viewmodel/MessageItem'
4 import { CustomTitleUI } from '../../reusable/CustomTitleUI' 5 import { CustomTitleUI } from '../../reusable/CustomTitleUI'
@@ -86,6 +87,7 @@ export struct MessageListUI { @@ -86,6 +87,7 @@ export struct MessageListUI {
86 ToastUtils.shortToast(index+"") 87 ToastUtils.shortToast(index+"")
87 switch (index) { 88 switch (index) {
88 case 0: //互动消息 89 case 0: //互动消息
  90 + WDRouterRule.jumpWithPage(WDRouterPage.interactMessagePage)
89 break; 91 break;
90 case 1: //预约消息 92 case 1: //预约消息
91 break; 93 break;
1 1
2 -import MyCollectionViewModel from '../../viewmodel/MyCollectionViewModel'; 2 +import InteractMessageViewModel from '../../viewmodel/InteractMessageViewModel';
3 import PageModel from '../../viewmodel/PageModel'; 3 import PageModel from '../../viewmodel/PageModel';
4 import { CommonConstants, ViewType } from 'wdConstant' 4 import { CommonConstants, ViewType } from 'wdConstant'
5 import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent' 5 import { EmptyComponent,WDViewDefaultType } from '../view/EmptyComponent'
6 import { ContentDTO } from 'wdBean' 6 import { ContentDTO } from 'wdBean'
7 import NoMoreLayout from './NoMoreLayout' 7 import NoMoreLayout from './NoMoreLayout'
8 -import CustomRefreshLoadLayout from './CustomRefreshLoadLayout';  
9 -import { CustomSelectUI } from '../view/CustomSelectUI';  
10 -import { CustomBottomFuctionUI } from '../view/CustomBottomFuctionUI';  
11 -import { BigPicCardComponent } from '../view/BigPicCardComponent';  
12 -  
13 import { CustomTitleUI } from '../reusable/CustomTitleUI'; 8 import { CustomTitleUI } from '../reusable/CustomTitleUI';
14 -import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';  
15 import { InteractMComponent } from '../InteractMessage/InteractMComponent'; 9 import { InteractMComponent } from '../InteractMessage/InteractMComponent';
  10 +import { InteractMessageModel, WDMessageCenterMessageType } from '../../model/InteractMessageModel';
  11 +import { CustomPullToRefresh } from '../reusable/CustomPullToRefresh';
16 12
17 @Entry 13 @Entry
18 @Component 14 @Component
@@ -20,39 +16,40 @@ struct InteractMessagePage { @@ -20,39 +16,40 @@ struct InteractMessagePage {
20 @State private browSingModel: PageModel = new PageModel() 16 @State private browSingModel: PageModel = new PageModel()
21 isloading : boolean = false 17 isloading : boolean = false
22 @Provide isEditState:boolean = false 18 @Provide isEditState:boolean = false
23 - @State allDatas :ContentDTO[] = []; 19 + @State allDatas :InteractMessageModel[] = [];
24 private scroller: Scroller = new Scroller(); 20 private scroller: Scroller = new Scroller();
25 - @State likeNum: number = 20 21 + @State likeNum: number = 0
  22 + @State currentPage: number = 1;
26 23
27 aboutToAppear(){ 24 aboutToAppear(){
28 this.getData() 25 this.getData()
  26 + this.getMessageLikeCount()
29 } 27 }
30 28
31 build() { 29 build() {
32 Column(){ 30 Column(){
33 CustomTitleUI({titleName:'互动消息'}) 31 CustomTitleUI({titleName:'互动消息'})
34 - this.ListLayout()  
35 - // if(this.browSingModel.viewType == ViewType.ERROR){  
36 - // EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NetworkFailed})  
37 - // }else if(this.browSingModel.viewType == ViewType.EMPTY){  
38 - // EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoHistory})  
39 - // }else {  
40 - // CustomPullToRefresh({  
41 - // alldata:this.allDatas,  
42 - // scroller:this.scroller,  
43 - // customList:()=>{  
44 - // this.ListLayout()  
45 - // },  
46 - // onRefresh:(resolve)=>{  
47 - // this.browSingModel.currentPage = 0  
48 - // this.getData(resolve)  
49 - // },  
50 - // onLoadMore:(resolve)=> {  
51 - // this.browSingModel.currentPage++  
52 - // this.getData()  
53 - // }  
54 - // })  
55 - // } 32 + if(this.browSingModel.viewType == ViewType.ERROR){
  33 + EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NetworkFailed})
  34 + }else if(this.browSingModel.viewType == ViewType.EMPTY){
  35 + EmptyComponent({emptyType:WDViewDefaultType.WDViewDefaultType_NoHistory})
  36 + }else {
  37 + CustomPullToRefresh({
  38 + alldata:this.allDatas,
  39 + scroller:this.scroller,
  40 + customList:()=>{
  41 + this.ListLayout()
  42 + },
  43 + onRefresh:(resolve)=>{
  44 + this.browSingModel.currentPage = 0
  45 + this.getData(resolve)
  46 + },
  47 + onLoadMore:(resolve)=> {
  48 + this.browSingModel.currentPage++
  49 + this.getData()
  50 + }
  51 + })
  52 + }
56 53
57 } 54 }
58 .width(CommonConstants.FULL_WIDTH) 55 .width(CommonConstants.FULL_WIDTH)
@@ -66,9 +63,9 @@ struct InteractMessagePage { @@ -66,9 +63,9 @@ struct InteractMessagePage {
66 } 63 }
67 64
68 // 下拉刷新 65 // 下拉刷新
69 - ForEach(this.allDatas, (compDTO: ContentDTO, compIndex: number) => { 66 + ForEach(this.allDatas, (InteractM: InteractMessageModel, compIndex: number) => {
70 ListItem() { 67 ListItem() {
71 - InteractMComponent() 68 + InteractMComponent({messageModel:InteractM})
72 } 69 }
73 }) 70 })
74 // 加载更多 71 // 加载更多
@@ -112,12 +109,22 @@ struct InteractMessagePage { @@ -112,12 +109,22 @@ struct InteractMessagePage {
112 } 109 }
113 110
114 async getData(resolve?: (value: string | PromiseLike<string>) => void){ 111 async getData(resolve?: (value: string | PromiseLike<string>) => void){
115 - MyCollectionViewModel.fetchMyCollectList(2,'1',this.browSingModel.currentPage,getContext(this)).then(collectionItem => { 112 + InteractMessageViewModel.fetchMessageList(WDMessageCenterMessageType.WDMessageCenterMessageType_Interact,this.currentPage).then(InteractMessageMItem => {
116 if(resolve) resolve('刷新成功') 113 if(resolve) resolve('刷新成功')
117 - if (collectionItem && collectionItem.list && collectionItem.list.length > 0) { 114 + if (InteractMessageMItem && InteractMessageMItem.list && InteractMessageMItem.list.length > 0) {
118 this.browSingModel.viewType = ViewType.LOADED; 115 this.browSingModel.viewType = ViewType.LOADED;
119 - this.allDatas.push(...collectionItem.list)  
120 - if (collectionItem.list.length === this.browSingModel.pageSize) { 116 +
  117 + if (this.currentPage === 1) {
  118 + this.allDatas = []
  119 + }
  120 +
  121 + for (let index = 0; index < InteractMessageMItem.list.length; index++) {
  122 + const element = InteractMessageMItem.list[index];
  123 + element.InteractMsubM = JSON.parse(element.remark)
  124 + }
  125 +
  126 + this.allDatas.push(...InteractMessageMItem.list)
  127 + if (InteractMessageMItem.list.length === this.browSingModel.pageSize) {
121 this.browSingModel.currentPage++; 128 this.browSingModel.currentPage++;
122 this.browSingModel.hasMore = true; 129 this.browSingModel.hasMore = true;
123 } else { 130 } else {
@@ -129,4 +136,11 @@ struct InteractMessagePage { @@ -129,4 +136,11 @@ struct InteractMessagePage {
129 }) 136 })
130 } 137 }
131 138
  139 + async getMessageLikeCount(){
  140 + InteractMessageViewModel.getMessageLikeCount().then(num => {
  141 + this.likeNum = num
  142 + })
  143 + }
  144 +
  145 +
132 } 146 }
  1 +
  2 +/**
  3 + * WDMessageCenterMessageType 拉取消息类型
  4 + */
  5 +export const enum WDMessageCenterMessageType {
  6 + WDMessageCenterMessageType_Interact = 1, //互动通知
  7 + WDMessageCenterMessageType_Subscribe, //预约消息
  8 + WDMessageCenterMessageType_System, //系统消息
  9 +}
  10 +
  11 +
  12 +export interface InteractMessageListModel{
  13 + data: InteractMessageMItem
  14 + code: number
  15 + message: string
  16 + success: string
  17 + timestamp: number
  18 +}
  19 +
  20 +
  21 +export class InteractMessageMItem{
  22 + pageNum:number = 0
  23 + pageSize:number = 0
  24 + totalCount:number = 0
  25 + hasNext:number = 0
  26 + list:InteractMessageModel[] = []
  27 +
  28 + constructor(list?:InteractMessageModel[],pageNum?: number,pageSize?: number,totalCount?: number,hasNext?:number) {
  29 + }
  30 +}
  31 +
  32 +export class InteractMessageModel {
  33 + classify: string = '';
  34 + contentId: string = '';
  35 + contentType: string = '';
  36 + id: number = 0;
  37 + message: string = '';
  38 + platform: string = '';
  39 + privateMailId: number = 0;
  40 + privateMailIdList: number[] = [];
  41 + privateMailIds: string = '';
  42 + privateMailNum: number = 0;
  43 + read: boolean = true;
  44 + source: string = '';
  45 + time: string = '';
  46 + title: string = '';
  47 + userId: string = '';
  48 + remark: string = '';
  49 + InteractMsubM:InteractMsubModel = new InteractMsubModel;
  50 +}
  51 +
  52 +export class InteractMsubModel {
  53 + beReply: string = '';
  54 + headUrl: string = '';
  55 + contentId: string = '';
  56 + contentRelObjectid: string = '';
  57 + contentTitle: string = '';
  58 + commentContent: string = '';
  59 + userName: string = '';
  60 + userId: string = '';
  61 + contentRelId: string = '';
  62 + shareUrl: string = '';
  63 + userType: string = '';
  64 + contentRelType: string = '';
  65 + visitor: string = '';
  66 + contentType: string = '';
  67 +}
  68 +
  69 +export interface InteractMParams {
  70 + contentType?: string;
  71 + pageNum?: string;
  72 + pageSize?: string;
  73 + userId?: string;
  74 + createTime?: string;
  75 +}
  76 +
  77 +export interface InteractMDTO{
  78 + success: boolean;
  79 + code: number;
  80 + message: string;
  81 + data: number;
  82 + timestamp?: number;
  83 +}
@@ -43,7 +43,6 @@ export interface MyCollectionListModel{ @@ -43,7 +43,6 @@ export interface MyCollectionListModel{
43 } 43 }
44 44
45 45
46 -  
47 export interface contentListItemParams{ 46 export interface contentListItemParams{
48 contentId?:string; 47 contentId?:string;
49 contentType?:string; 48 contentType?:string;
  1 +// import { collcetRecordParams, MyCollectionItem, MyCollectionListModel } from '../model/MyCollectionModel';
  2 +import { HttpUrlUtils, HttpUtils, ResponseDTO, WDHttp } from 'wdNetwork';
  3 +import { Logger } from 'wdKit';
  4 +import promptAction from '@ohos.promptAction';
  5 +import {
  6 + InteractMDTO,
  7 + InteractMessageListModel, InteractMessageMItem, InteractMParams } from '../model/InteractMessageModel';
  8 +
  9 +const TAG = "MyCollectionViewModel"
  10 +
  11 +class InteractMessageViewModel {
  12 + private static instance:InteractMessageViewModel
  13 + /**
  14 + * 单例模式
  15 + * @returns
  16 + */
  17 + public static getInstance(): InteractMessageViewModel {
  18 + if (!InteractMessageViewModel.instance) {
  19 + InteractMessageViewModel.instance = new InteractMessageViewModel();
  20 + }
  21 + return InteractMessageViewModel.instance;
  22 + }
  23 +
  24 + // ///互动通知
  25 + // WDMessageCenterMessageType_Interact = 1,
  26 + //
  27 + // ///预约消息
  28 + // WDMessageCenterMessageType_Subscribe = 2,
  29 + //
  30 + // ///系统消息
  31 + // WDMessageCenterMessageType_System = 3
  32 +
  33 + BaseGetRequest(contentType:number,pageNum:number){
  34 + let userID = HttpUtils.getUserId();
  35 + let url = HttpUrlUtils.getMessageListDataUrl()+`?contentType=${contentType}&userId=${userID}&pageSize=${20}&pageNum=${pageNum}`
  36 + return WDHttp.get<InteractMessageListModel>(url)
  37 + }
  38 +
  39 +
  40 + fetchMessageList(contentType:number,pageNum:number):Promise<InteractMessageMItem>{
  41 + return new Promise((success,error) => {
  42 + this.BaseGetRequest(contentType,pageNum).then((navResDTO: InteractMessageListModel) => {
  43 + if (!navResDTO || navResDTO.code != 0) {
  44 + return
  45 + }
  46 + Logger.info(TAG, "fetchMessageList then,navResDTO.timeStamp:" + navResDTO.timestamp);
  47 + success(navResDTO.data)
  48 + }).catch((err: Error) => {
  49 + Logger.error(TAG, `fetchMessageList catch, error.name : ${err.name}, error.message:${err.message}`);
  50 + error("page data invalid");
  51 + })
  52 + })
  53 + }
  54 +
  55 + getMessageLikeCount():Promise<number>{
  56 + return new Promise((success,error) => {
  57 + WDHttp.get<InteractMDTO>(HttpUrlUtils.getMessageLikeCount()).then((navResDTO: InteractMDTO) => {
  58 + if (navResDTO.code == 0) {
  59 + success(navResDTO.data)
  60 + }
  61 + })
  62 + .catch((error: Error) => {
  63 + Logger.info(TAG,'executeCollcet','ResponseDTO')
  64 + })
  65 + })
  66 + }
  67 +}
  68 +
  69 +const interactMViewModel = InteractMessageViewModel.getInstance();
  70 +
  71 +export default interactMViewModel as InteractMessageViewModel