yangchenggong1_wd

desc:消息中心 和 预约消息

@@ -329,6 +329,16 @@ export class HttpUrlUtils { @@ -329,6 +329,16 @@ export class HttpUrlUtils {
329 */ 329 */
330 static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime="; 330 static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime=";
331 331
  332 + /**
  333 + * 点击消息
  334 + */
  335 + static readonly SEND_MESSAGE_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/touch?createTime=";
  336 +
  337 + /**
  338 + * 推送消息
  339 + */
  340 + static readonly HISTORY_PUSH_MESSAGE_PATH: string = "/api/rmrb-bff-display-zh/content/zh/c/push";
  341 +
332 static getHost(): string { 342 static getHost(): string {
333 return HostManager.getHost(); 343 return HostManager.getHost();
334 } 344 }
@@ -746,4 +756,16 @@ export class HttpUrlUtils { @@ -746,4 +756,16 @@ export class HttpUrlUtils {
746 let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push"; 756 let url = HttpUrlUtils.getHost() + "/api/rmrb-user-center/common/user/c/device/push";
747 return url; 757 return url;
748 } 758 }
  759 +
  760 + //点击消息
  761 + static getSendClickMessageUrl() {
  762 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.SEND_MESSAGE_PATH
  763 + return url
  764 + }
  765 +
  766 + //消息 历史推送消息
  767 + static getHistoryPushUrl() {
  768 + let url = HttpUrlUtils.getHost() + HttpUrlUtils.HISTORY_PUSH_MESSAGE_PATH
  769 + return url
  770 + }
749 } 771 }
@@ -119,6 +119,8 @@ export class WDRouterPage { @@ -119,6 +119,8 @@ export class WDRouterPage {
119 static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage"); 119 static searchPage = new WDRouterPage("wdComponent", "ets/pages/SearchPage");
120 //消息主页 120 //消息主页
121 static mineMessagePage = new WDRouterPage("wdComponent", "ets/pages/MineMessagePage"); 121 static mineMessagePage = new WDRouterPage("wdComponent", "ets/pages/MineMessagePage");
  122 + //预约消息主页
  123 + static subscribeMessagePage = new WDRouterPage("wdComponent", "ets/pages/SubscribeMessagePage");
122 //搜索人民号主页 124 //搜索人民号主页
123 static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage"); 125 static searchCreatorPage = new WDRouterPage("wdComponent", "ets/pages/SearchCreatorPage");
124 //人民号主页 126 //人民号主页
1 import { WDRouterRule, WDRouterPage } from 'wdRouter' 1 import { WDRouterRule, WDRouterPage } from 'wdRouter'
  2 +import MinePageDatasModel from '../../model/MinePageDatasModel'
2 import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem' 3 import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
3 import { PagePersonFunction } from './PagePersonFunction' 4 import { PagePersonFunction } from './PagePersonFunction'
4 5
  6 +
  7 +const TAG = "MinePagePersonFunctionUI"
5 @Component 8 @Component
6 export default struct MinePagePersonFunctionUI { 9 export default struct MinePagePersonFunctionUI {
7 @Link personalData:MinePagePersonalFunctionsItem[] 10 @Link personalData:MinePagePersonalFunctionsItem[]
@@ -62,6 +65,7 @@ export default struct MinePagePersonFunctionUI { @@ -62,6 +65,7 @@ export default struct MinePagePersonFunctionUI {
62 WDRouterRule.jumpWithPage(WDRouterPage.loginPage) 65 WDRouterRule.jumpWithPage(WDRouterPage.loginPage)
63 return 66 return
64 } 67 }
  68 + this.messageClick()
65 WDRouterRule.jumpWithPage(WDRouterPage.mineMessagePage) 69 WDRouterRule.jumpWithPage(WDRouterPage.mineMessagePage)
66 break; 70 break;
67 } 71 }
@@ -75,5 +79,13 @@ export default struct MinePagePersonFunctionUI { @@ -75,5 +79,13 @@ export default struct MinePagePersonFunctionUI {
75 .height('234lpx') 79 .height('234lpx')
76 .margin({top:'31lpx',left:'23lpx',right:'23lpx' }) 80 .margin({top:'31lpx',left:'23lpx',right:'23lpx' })
77 } 81 }
  82 +
  83 + messageClick(){
  84 + MinePageDatasModel.sendClickMessageData().then((value) => {
  85 + console.log(TAG, "进入消息页面")
  86 + }).catch((err: Error) => {
  87 + console.log(TAG, JSON.stringify(err))
  88 + })
  89 + }
78 } 90 }
79 91
  1 +import { StringUtils } from 'wdKit/Index'
  2 +import { MessageItem } from '../../../viewmodel/MessageItem'
  3 +
  4 +const TAG = "MessageListUI"
  5 +
  6 +@Component
  7 +export struct MessageListItemUI {
  8 + @ObjectLink item: MessageItem
  9 + @State index:number = -1
  10 +
  11 + build() {
  12 + Column(){
  13 + Column() {
  14 + Row() {
  15 + Row() {
  16 + Image(this.item.imgSrc)
  17 + .objectFit(ImageFit.Auto)
  18 + .width('92lpx')
  19 + .height('92lpx')
  20 + .margin({ right: '15lpx' })
  21 +
  22 + Column() {
  23 + Text(this.item.title)
  24 + .fontWeight(500)
  25 + .fontSize('31lpx')
  26 + .lineHeight('42lpx')
  27 + .fontColor($r('app.color.color_222222'))
  28 + .maxLines(1)
  29 + .margin({ bottom: StringUtils.isNotEmpty(this.item.desc)?'8lpx':0 })
  30 +
  31 + if(StringUtils.isNotEmpty(this.item.desc)){
  32 + Text(`${this.item.desc}`)
  33 + .fontColor($r('app.color.color_999999'))
  34 + .fontSize('27lpx')
  35 + .lineHeight('38lpx')
  36 + .fontWeight(400)
  37 + .maxLines(1)
  38 + .textOverflow({ overflow: TextOverflow.Ellipsis })
  39 + }
  40 + }
  41 + .height('92lpx')
  42 + .layoutWeight(1)
  43 + .alignItems(HorizontalAlign.Start)
  44 + .justifyContent(StringUtils.isNotEmpty(this.item.desc)?FlexAlign.Start:FlexAlign.Center)
  45 + }.layoutWeight(1)
  46 +
  47 + Column() {
  48 + Text(`${this.item.time}`)
  49 + .fontColor($r('app.color.color_999999'))
  50 + .fontSize('23lpx')
  51 + .fontWeight(500)
  52 + .lineHeight('35lpx')
  53 + .margin({ bottom: this.item.unReadCount > 0 ?'8lpx':0 })
  54 +
  55 + if(this.item.unReadCount > 0){
  56 + Button(){
  57 + Text(`${this.item.unReadCount}`)
  58 + .fontWeight(400)
  59 + .fontSize("18lpx")
  60 + .fontColor($r('app.color.white'))
  61 + }
  62 + .type((this.item.unReadCount>0 && this.item.unReadCount < 10 ? ButtonType.Circle:ButtonType.Capsule))
  63 + .backgroundColor($r("app.color.color_ED2800"))
  64 + .stateEffect(false)
  65 + .height("27lpx")
  66 + .constraintSize({minWidth:"27lpx"})
  67 + }
  68 + }
  69 + .justifyContent(FlexAlign.Start)
  70 + .alignItems(HorizontalAlign.End)
  71 + .height('92lpx')
  72 + }
  73 + .width('100%')
  74 + .height('92lpx')
  75 + .justifyContent(FlexAlign.SpaceBetween)
  76 +
  77 + }.height('154lpx')
  78 + .width("100%")
  79 + .justifyContent(FlexAlign.Center)
  80 +
  81 + Text().backgroundColor($r('app.color.color_EDEDED'))
  82 + .width('100%')
  83 + .height('1lpx')
  84 + .visibility(this.index != 3 ?Visibility.Visible:Visibility.None)
  85 + }
  86 + }
  87 +
  88 +
  89 +}
1 -import { StringUtils, ToastUtils } from 'wdKit/Index' 1 +import { DateTimeUtils, StringUtils, ToastUtils } from 'wdKit/Index'
2 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index' 2 import { WDRouterPage, WDRouterRule } from 'wdRouter/Index'
3 import MinePageDatasModel from '../../../model/MinePageDatasModel' 3 import MinePageDatasModel from '../../../model/MinePageDatasModel'
4 import { MessageItem } from '../../../viewmodel/MessageItem' 4 import { MessageItem } from '../../../viewmodel/MessageItem'
5 import { CustomTitleUI } from '../../reusable/CustomTitleUI' 5 import { CustomTitleUI } from '../../reusable/CustomTitleUI'
  6 +import { MessageListItemUI } from './MessageListItemUI'
6 7
7 const TAG = "MessageListUI" 8 const TAG = "MessageListUI"
8 9
@@ -12,84 +13,143 @@ export struct MessageListUI { @@ -12,84 +13,143 @@ export struct MessageListUI {
12 13
13 aboutToAppear() { 14 aboutToAppear() {
14 this.msgData = MinePageDatasModel.getMessageData() 15 this.msgData = MinePageDatasModel.getMessageData()
  16 + this.getHistoryPush()
  17 + this.getMessagePush()
15 } 18 }
16 19
17 - build() {  
18 - Column() {  
19 - //标题栏目  
20 - CustomTitleUI({ titleName: "消息" }) 20 + //历史推送
  21 + getHistoryPush() {
  22 + MinePageDatasModel.getHistoryPushData("1", "1").then((value) => {
  23 + if (value != null && value.list != null && value.list.length > 0) {
  24 + this.msgData.forEach((item) => {
  25 + if (item.title == "历史推送") {
  26 + if (value.list != null && value.list[0] != null) {
  27 + if (value.list[0].newsTitle) {
  28 + item.desc = value.list[0].newsTitle
  29 + }
  30 + if (value.list[0].publishTime) {
  31 + item.time = this.getPublishTime("",value.list[0].publishTime)
  32 + }
  33 + }
  34 + }
  35 + })
  36 + }
  37 + }).catch((err: Error) => {
  38 + console.log(TAG, JSON.stringify(err))
  39 + })
  40 + }
21 41
22 - List() {  
23 - ForEach(this.msgData, (item: MessageItem, index: number) => {  
24 - ListItem() {  
25 - Column(){  
26 - Column() {  
27 - Row() {  
28 - Row() {  
29 - Image(item.imgSrc)  
30 - .objectFit(ImageFit.Auto)  
31 - .width('92lpx')  
32 - .height('92lpx')  
33 - .margin({ right: '15lpx' }) 42 + //互动消息 预约消息 系统消息
  43 + getMessagePush() {
  44 + MinePageDatasModel.getMessageUnReadData().then((value) => {
  45 + this.msgData.forEach((item) => {
  46 + if (item.title == "预约消息") {
  47 + if (value.subscribeInfo != null) {
  48 + if (value.subscribeInfo.title) {
  49 + item.desc = value.subscribeInfo.title
  50 + }
  51 + if (value.subscribeInfo.time) {
  52 + item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.subscribeInfo.time)+"")
  53 + }
  54 + }
  55 + if(value.subscribeCount > 0){
  56 + item.unReadCount = value.subscribeCount
  57 + }
  58 + } else if (item.title == "系统消息") {
  59 + if (value.systemInfo != null) {
  60 + if (value.systemInfo.title) {
  61 + item.desc = value.systemInfo.title
  62 + }
  63 + if (value.systemInfo.time) {
  64 + item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.systemInfo.time) + "")
  65 + }
  66 + }
  67 + if(value.systemCount > 0){
  68 + item.unReadCount = value.systemCount
  69 + }
  70 + }else if(item.title == "互动消息"){
  71 + if(value.activeCount > 0){
  72 + item.unReadCount = value.activeCount
  73 + }
  74 + if (value.activeInfo != null) {
  75 + if (value.activeInfo.title) {
  76 + item.desc = value.activeInfo.title
  77 + }
  78 + if (value.activeInfo.time) {
  79 + item.time = this.getPublishTime(value.subscribeInfo.time,DateTimeUtils.getDateTimestamp(value.activeInfo.time) + "")
  80 + }
  81 + }
  82 + }
  83 + })
  84 + }).catch((err: Error) => {
  85 + console.log(TAG, JSON.stringify(err))
  86 + })
  87 + }
34 88
35 - Column() {  
36 - Text(item.title)  
37 - .fontWeight(500)  
38 - .fontSize('31lpx')  
39 - .lineHeight('42lpx')  
40 - .fontColor($r('app.color.color_222222'))  
41 - .maxLines(1)  
42 - .margin({ bottom: StringUtils.isNotEmpty(item.desc)?'8lpx':0 }) 89 + getPublishTime(data:string,publishTime: string): string {
  90 + const publishTimestamp = parseInt(publishTime)
  91 + const currentTime = Date.now(); // 当前时间戳
43 92
44 - if(StringUtils.isNotEmpty(item.desc)){  
45 - Text(`${item.desc}`)  
46 - .fontColor($r('app.color.color_B0B0B0'))  
47 - .fontSize('23lpx')  
48 - .lineHeight('38lpx')  
49 - .fontWeight(400)  
50 - .maxLines(1)  
51 - .textOverflow({ overflow: TextOverflow.Ellipsis })  
52 - }  
53 - }  
54 - .height('92lpx')  
55 - .layoutWeight(1)  
56 - .alignItems(HorizontalAlign.Start)  
57 - .justifyContent(StringUtils.isNotEmpty(item.desc)?FlexAlign.Start:FlexAlign.Center)  
58 - }.layoutWeight(1) 93 + // 计算差异
  94 + const timeDifference = currentTime - publishTimestamp;
59 95
60 - Row() {  
61 - Text(`${item.time}`)  
62 - .fontColor($r('app.color.color_999999'))  
63 - .fontSize('23lpx')  
64 - .fontWeight(500)  
65 - .lineHeight('35lpx') 96 + // 转换为分钟、小时和天
  97 + const minutes = Math.floor(timeDifference / (1000 * 60));
  98 + const hours = Math.floor(timeDifference / (1000 * 60 * 60));
  99 + const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
  100 +
  101 + // 根据时间差返回对应的字符串
  102 + let result: string;
  103 +
  104 + if (minutes < 60) {
  105 + result = `${minutes}分钟前`;
  106 + if(minutes === 0){
  107 + result = `刚刚`;
  108 + }
  109 + } else if (hours < 24) {
  110 + result = `${hours}小时前`;
  111 + } else {
  112 + result = `${days}天前`;
  113 + if(days > 1){
  114 + let arr = data.split(" ")
  115 + if(arr.length === 2){
  116 + let arr2 = arr[0].split("-")
  117 + if(arr2.length === 3){
  118 + result = `${arr2[1]}-${arr2[2]}`
  119 + }
  120 + }else{
  121 + //原始数据是时间戳 需要转成dateString
  122 + let time = DateTimeUtils.formatDate(Number(publishTime))
  123 + let arr = time.split("-")
  124 + if(arr.length === 3){
  125 + result = `${arr[1]}-${arr[2]}`
  126 + }
  127 + }
66 } 128 }
67 - .justifyContent(FlexAlign.Start)  
68 - .alignItems(VerticalAlign.Top)  
69 - .height('92lpx')  
70 } 129 }
71 - .width('100%')  
72 - .height('92lpx')  
73 - .justifyContent(FlexAlign.SpaceBetween)  
74 -  
75 - }.height('154lpx')  
76 - .width("100%")  
77 - .justifyContent(FlexAlign.Center)  
78 130
79 - Text().backgroundColor($r('app.color.color_EDEDED'))  
80 - .width('100%')  
81 - .height('1lpx')  
82 - .visibility(index != 3 ?Visibility.Visible:Visibility.None) 131 + console.log(result);
  132 + return result
83 } 133 }
  134 +
  135 + build() {
  136 + Column() {
  137 + //标题栏目
  138 + CustomTitleUI({ titleName: "消息" })
  139 +
  140 + List() {
  141 + ForEach(this.msgData, (item: MessageItem, index: number) => {
  142 + ListItem() {
  143 + MessageListItemUI({ item: item, index: index })
84 } 144 }
85 - .padding({left:"31lpx",right:"31lpx"}) 145 + .padding({ left: "31lpx", right: "31lpx" })
86 .onClick(() => { 146 .onClick(() => {
87 - ToastUtils.shortToast(index+"")  
88 switch (index) { 147 switch (index) {
89 case 0: //互动消息 148 case 0: //互动消息
90 WDRouterRule.jumpWithPage(WDRouterPage.interactMessagePage) 149 WDRouterRule.jumpWithPage(WDRouterPage.interactMessagePage)
91 break; 150 break;
92 case 1: //预约消息 151 case 1: //预约消息
  152 + WDRouterRule.jumpWithPage(WDRouterPage.subscribeMessagePage)
93 break; 153 break;
94 case 2: //历史推送 154 case 2: //历史推送
95 break; 155 break;
  1 +import { SubscribeMessageModel } from '../../../../model/InteractMessageModel'
  2 +
  3 +@Component
  4 +export struct SubscribeListChildComponent{
  5 + @ObjectLink item: SubscribeMessageModel
  6 +
  7 + build() {
  8 + Column(){
  9 + Row(){
  10 + Text(`${this.item.dealTime}`)
  11 + .margin({top:"31lpx",bottom:"23lpx"})
  12 + .fontWeight(400)
  13 + .fontSize("23lpx")
  14 + .lineHeight("33lpx")
  15 + .fontColor($r('app.color.color_999999'))
  16 + }.width('100%')
  17 + .backgroundColor($r('app.color.color_F5F5F5'))
  18 + .justifyContent(FlexAlign.Center)
  19 +
  20 + Column(){
  21 + Column(){
  22 + Text(`${this.item.title}`)
  23 + .fontSize("31lpx")
  24 + .lineHeight("46lpx")
  25 + .fontWeight(500)
  26 + .fontColor($r('app.color.color_333333'))
  27 + .margin({top:"27lpx",bottom:"25lpx"})
  28 + .maxLines(1)
  29 +
  30 + Text().backgroundColor($r('app.color.color_F5F5F5'))
  31 + .width('100%')
  32 + .height('1lpx')
  33 + }.alignItems(HorizontalAlign.Start)
  34 + .width("100%")
  35 + .height("98lpx")
  36 +
  37 + Row(){
  38 + Image(`${this.item.imgUrl}`)
  39 + .width('204lpx')
  40 + .height('115lpx')
  41 + .borderRadius("6lpx")
  42 + .objectFit(ImageFit.Auto)
  43 + .margin({right:"23lpx"})
  44 +
  45 + Text(`${this.item.desc}`)
  46 + .fontSize("27lpx")
  47 + .lineHeight("38lpx")
  48 + .fontWeight(400)
  49 + .fontColor($r('app.color.color_222222'))
  50 + .layoutWeight(1)
  51 + }.alignItems(VerticalAlign.Center)
  52 + .width("100%")
  53 + .height("160lpx")
  54 +
  55 + Text().backgroundColor($r('app.color.color_F5F5F5'))
  56 + .width('100%')
  57 + .height('1lpx')
  58 +
  59 + Row(){
  60 + Text(`${this.item.time}开始`)
  61 + .fontSize("23lpx")
  62 + .fontWeight(600)
  63 + .lineHeight("31lpx")
  64 +
  65 + Row(){
  66 + Text("查看详情")
  67 + .fontSize("23lpx")
  68 + .lineHeight("38lpx")
  69 + .fontWeight(400)
  70 + .fontColor($r('app.color.color_666666'))
  71 + .margin({right:"8lpx"})
  72 +
  73 + Image($r('app.media.subscribe_arrow_icon'))
  74 + .width('23lpx')
  75 + .height('13lpx')
  76 + .objectFit(ImageFit.Auto)
  77 + .interpolation(ImageInterpolation.High)
  78 + .margin({right:"4lpx"})
  79 + }
  80 + }.alignItems(VerticalAlign.Center)
  81 + .justifyContent(FlexAlign.SpaceBetween)
  82 + .width("100%")
  83 + .height("73lpx")
  84 +
  85 + }.backgroundColor($r('app.color.white'))
  86 + .borderRadius("8lpx")
  87 + .width("100%")
  88 + .padding({left:"23lpx",right:"23lpx"})
  89 + }
  90 + .backgroundColor($r('app.color.color_F5F5F5'))
  91 + .width("100%")
  92 + .padding({left:"31lpx",right:"31lpx"})
  93 + .alignItems(HorizontalAlign.Center)
  94 + }
  95 +
  96 +
  97 +}
  1 +import { LazyDataSource, StringUtils } from 'wdKit/Index';
  2 +import { Remark, SubscribeMessageModel,
  3 + WDMessageCenterMessageType } from '../../../../model/InteractMessageModel';
  4 +import MinePageDatasModel from '../../../../model/MinePageDatasModel';
  5 +import { CustomTitleUI } from '../../../reusable/CustomTitleUI';
  6 +import { ListHasNoMoreDataUI } from '../../../reusable/ListHasNoMoreDataUI';
  7 +import { EmptyComponent } from '../../../view/EmptyComponent';
  8 +import { SubscribeListChildComponent } from './SubscribeListChildComponent';
  9 +
  10 +const TAG = "SubscribeMessageComponent"
  11 +
  12 +@Component
  13 +export struct SubscribeMessageComponent{
  14 + @State data: LazyDataSource<SubscribeMessageModel> = new LazyDataSource();
  15 + @State count: number = 0;
  16 + @State isLoading: boolean = false
  17 + @State hasMore: boolean = true
  18 + curPageNum: number = 1;
  19 + @State isGetRequest: boolean = false
  20 +
  21 + aboutToAppear() {
  22 + this.getNewPageData()
  23 + }
  24 +
  25 + build() {
  26 + Column() {
  27 + //标题栏目
  28 + CustomTitleUI({ titleName: "预约消息" })
  29 + if (this.count == 0) {
  30 + if (this.isGetRequest == true) {
  31 + EmptyComponent({ emptyType: 5 })
  32 + .height('100%')
  33 + .width('100%')
  34 + }
  35 +
  36 + } else {
  37 + //刷新控件 TODO
  38 + //List
  39 + List() {
  40 + LazyForEach(this.data, (item: SubscribeMessageModel, index: number) => {
  41 + ListItem() {
  42 + SubscribeListChildComponent({ item: item })
  43 + }.width('100%')
  44 + .onClick(() => {
  45 + })
  46 + })
  47 +
  48 + //没有更多数据 显示提示
  49 + if (!this.hasMore) {
  50 + ListItem() {
  51 + ListHasNoMoreDataUI()
  52 + }
  53 + }
  54 + }.width('100%')
  55 + .cachedCount(4)
  56 + .scrollBar(BarState.Off)
  57 + .layoutWeight(1)
  58 + .onReachEnd(() => {
  59 + if (!this.isLoading) {
  60 + //加载分页数据
  61 + this.getNewPageData()
  62 + }
  63 + })
  64 + }
  65 + }
  66 + .backgroundColor($r('app.color.color_F9F9F9'))
  67 + .height('100%')
  68 + .width('100%')
  69 + }
  70 +
  71 + getNewPageData() {
  72 + this.isLoading = true
  73 + if (this.hasMore) {
  74 + MinePageDatasModel.getSubscribeMessageData(WDMessageCenterMessageType.WDMessageCenterMessageType_Subscribe,"20",`${this.curPageNum}`).then((value) => {
  75 + if (!this.data || value.list.length == 0) {
  76 + this.hasMore = false
  77 + } else {
  78 + value.list.forEach((value) => {
  79 + let dealTime = this.DealStartTime(value.time,1)
  80 + let dealTime2 = this.DealStartTime(value.time,2)
  81 +
  82 + let remark = JSON.parse(value.remark) as Remark
  83 +
  84 + this.data.push(new SubscribeMessageModel(dealTime,value.message,remark.coverImageUrl,value.title,dealTime2,value.contentId))
  85 + })
  86 + this.data.notifyDataReload()
  87 + this.count = this.data.totalCount()
  88 + if (this.data.totalCount() < value.totalCount) {
  89 + this.curPageNum++
  90 + } else {
  91 + this.hasMore = false
  92 + }
  93 + }
  94 + this.isGetRequest = true
  95 + this.isLoading = false
  96 + }).catch((err: Error) => {
  97 + console.log(TAG, JSON.stringify(err))
  98 + this.isGetRequest = true
  99 + this.isLoading = false
  100 + })
  101 + }
  102 + }
  103 +
  104 +
  105 + DealStartTime(planStartTime: string,type:number): string {
  106 + let dealData: string = ""
  107 +
  108 + if (StringUtils.isEmpty(planStartTime)) {
  109 + console.log(TAG, "格式有误")
  110 + return planStartTime
  111 + }
  112 +
  113 + if (planStartTime.indexOf(" ") === -1) {
  114 + console.log(TAG, "格式有误")
  115 + return planStartTime
  116 + }
  117 +
  118 + let arr = planStartTime.split(" ")
  119 + if (arr != null && StringUtils.isNotEmpty(arr[0])) { //处理年月日
  120 + let time = arr[0].split("-");
  121 + if (time.length === 3) {
  122 + dealData = `${time[1]}-${time[2]}`
  123 + if(type === 1){
  124 + return dealData
  125 + }
  126 + }
  127 + }
  128 +
  129 + if (arr != null && StringUtils.isNotEmpty(arr[1])) { //处理时分
  130 + let time = arr[1].split(":");
  131 + if (time.length === 3) {
  132 + dealData = `${dealData} ${time[0]}:${time[1]}`
  133 + }
  134 + }
  135 + console.log(TAG, JSON.stringify(dealData))
  136 + return dealData
  137 + }
  138 +
  139 +
  140 +}
@@ -32,6 +32,9 @@ export struct MinePageComponent { @@ -32,6 +32,9 @@ export struct MinePageComponent {
32 }else { 32 }else {
33 this.isLogin = true 33 this.isLogin = true
34 this.addRecordDialog() 34 this.addRecordDialog()
  35 + if(this.personalData.length > 0){
  36 + this.getMessageData()
  37 + }
35 } 38 }
36 } 39 }
37 } 40 }
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 */ 4 */
5 export const enum WDMessageCenterMessageType { 5 export const enum WDMessageCenterMessageType {
6 WDMessageCenterMessageType_Interact = 1, //互动通知 6 WDMessageCenterMessageType_Interact = 1, //互动通知
7 - WDMessageCenterMessageType_Subscribe, //预约消息 7 + WDMessageCenterMessageType_Subscribe = 2, //预约消息
8 WDMessageCenterMessageType_System, //系统消息 8 WDMessageCenterMessageType_System, //系统消息
9 } 9 }
10 10
@@ -81,3 +81,29 @@ export interface InteractMDTO{ @@ -81,3 +81,29 @@ export interface InteractMDTO{
81 data: number; 81 data: number;
82 timestamp?: number; 82 timestamp?: number;
83 } 83 }
  84 +
  85 +@Observed
  86 +export class SubscribeMessageModel{
  87 + dealTime:string = ""
  88 + title:string = ""
  89 + imgUrl:string = ""
  90 + desc:string = ""
  91 + time:string = ""
  92 + contentId:string = ""
  93 +
  94 + constructor(dealTime: string, title: string, imgUrl: string, desc: string , time: string, contentId: string) {
  95 + this.dealTime = dealTime
  96 + this.title = title
  97 + this.imgUrl = imgUrl
  98 + this.desc = desc
  99 + this.time = time
  100 + this.contentId = contentId
  101 + }
  102 +}
  103 +
  104 +export class Remark{
  105 + relationType:string = ""
  106 + coverImageUrl:string = ""
  107 + relationId:string = ""
  108 + status:string = ""
  109 +}
@@ -25,6 +25,9 @@ import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestI @@ -25,6 +25,9 @@ import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestI
25 import { SpConstants } from 'wdConstant/Index'; 25 import { SpConstants } from 'wdConstant/Index';
26 import { MessageItem } from '../viewmodel/MessageItem'; 26 import { MessageItem } from '../viewmodel/MessageItem';
27 import { MessageUnReadItem } from '../viewmodel/MessageUnReadItem'; 27 import { MessageUnReadItem } from '../viewmodel/MessageUnReadItem';
  28 +import { HistoryPushDataItem } from '../viewmodel/HistoryPushDataItem';
  29 +import { HashMap } from '@kit.ArkTS';
  30 +import { InteractMessageMItem } from './InteractMessageModel';
28 31
29 const TAG = "MinePageDatasModel" 32 const TAG = "MinePageDatasModel"
30 33
@@ -601,8 +604,6 @@ class MinePageDatasModel{ @@ -601,8 +604,6 @@ class MinePageDatasModel{
601 604
602 /** 605 /**
603 * 获取消息未读数据 606 * 获取消息未读数据
604 - * @param pageSize  
605 - * @param pageNum  
606 * @returns 607 * @returns
607 */ 608 */
608 getMessageUnReadData(): Promise<MessageUnReadItem> { 609 getMessageUnReadData(): Promise<MessageUnReadItem> {
@@ -625,6 +626,81 @@ class MinePageDatasModel{ @@ -625,6 +626,81 @@ class MinePageDatasModel{
625 return WDHttp.get<ResponseDTO<MessageUnReadItem>>(url) 626 return WDHttp.get<ResponseDTO<MessageUnReadItem>>(url)
626 }; 627 };
627 628
  629 + /**
  630 + * 点击消息(进入消息页面)
  631 + * @returns
  632 + */
  633 + sendClickMessageData(): Promise<String> {
  634 + return new Promise<String>((success, error) => {
  635 + this.fetchClickMessageData().then((navResDTO: ResponseDTO<String>) => {
  636 + if (!navResDTO || navResDTO.code != 0) {
  637 + error(null)
  638 + return
  639 + }
  640 + success("1");
  641 + }).catch((err: Error) => {
  642 + error(err)
  643 + })
  644 + })
  645 + }
  646 +
  647 + fetchClickMessageData() {
  648 + let url = HttpUrlUtils.getSendClickMessageUrl()
  649 + return WDHttp.get<ResponseDTO<String>>(url)
  650 + };
  651 +
  652 + /**
  653 + * 历史推送消息
  654 + * @returns
  655 + */
  656 + getHistoryPushData(pageSize:string,pageNum:string): Promise<HistoryPushDataItem> {
  657 + return new Promise<HistoryPushDataItem>((success, error) => {
  658 + this.fetchHistoryPushData(pageSize,pageNum).then((navResDTO: ResponseDTO<HistoryPushDataItem>) => {
  659 + if (!navResDTO || navResDTO.code != 0) {
  660 + error(null)
  661 + return
  662 + }
  663 + let navigationBean = navResDTO.data as HistoryPushDataItem
  664 + success(navigationBean);
  665 + }).catch((err: Error) => {
  666 + error(err)
  667 + })
  668 + })
  669 + }
  670 +
  671 + fetchHistoryPushData(pageSize:string,pageNum:string) {
  672 + let url = HttpUrlUtils.getHistoryPushUrl()+ `?pageSize=${pageSize}&pageNum=${pageNum}`
  673 + let headers: HashMap<string, string> = new HashMap<string, string>();
  674 + headers.set('system', 'Android');
  675 + return WDHttp.get<ResponseDTO<HistoryPushDataItem>>(url, headers)
  676 + };
  677 +
  678 + /**
  679 + * 推送消息
  680 + * @returns
  681 + */
  682 + getSubscribeMessageData(contentType:number,pageSize:string,pageNum:string): Promise<InteractMessageMItem> {
  683 + return new Promise<InteractMessageMItem>((success, error) => {
  684 + this.fetchSubscribeMessageData(contentType,pageSize,pageNum).then((navResDTO: ResponseDTO<InteractMessageMItem>) => {
  685 + if (!navResDTO || navResDTO.code != 0) {
  686 + error(null)
  687 + return
  688 + }
  689 + let navigationBean = navResDTO.data as InteractMessageMItem
  690 + success(navigationBean);
  691 + }).catch((err: Error) => {
  692 + error(err)
  693 + })
  694 + })
  695 + }
  696 +
  697 + fetchSubscribeMessageData(contentType:number,pageSize:string,pageNum:string) {
  698 + let userID = HttpUtils.getUserId();
  699 + let url = HttpUrlUtils.getMessageListDataUrl()+`?createTime=${''}&contentType=${contentType}&userId=${userID}&pageSize=${pageSize}&pageNum=${pageNum}`
  700 + return WDHttp.get<ResponseDTO<InteractMessageMItem>>(url)
  701 + };
  702 +
  703 +
628 } 704 }
629 705
630 const minePageDatasModel = MinePageDatasModel.getInstance() 706 const minePageDatasModel = MinePageDatasModel.getInstance()
  1 +import { SubscribeMessageComponent } from '../components/mine/message/subscribe/SubscribeMessageComponent'
  2 +
  3 +//预约消息 页面
  4 +@Entry
  5 +@Component
  6 +struct SubscribeMessagePage {
  7 +
  8 + build() {
  9 + Column(){
  10 + SubscribeMessageComponent()
  11 + }
  12 + }
  13 +}
  1 +export class HistoryPushDataItem{
  2 + hasNext: number = 0
  3 + list: Array< HistoryPushItem > = []
  4 + pageNum: number = 0
  5 + pageSize: number = 0
  6 + totalCount: number = 0
  7 +}
  8 +
  9 +export class HistoryPushItem{
  10 + activityExt?: null
  11 + appStyle: string = ""
  12 + askInfo?: null
  13 + axisColor: string = ""
  14 + bestNoticer?: null
  15 + bottomNavId?: null
  16 + cardItemId: string = ""
  17 + channelId: number= 0
  18 + commentInfo?: null
  19 + corner: string = ""
  20 + coverSize: string = ""
  21 + coverType?: number
  22 + coverUrl: string = ""
  23 + expIds: string = ""
  24 + extra: string = ""
  25 + fullColumnImgUrls: Array< FullColumnImgUrl > = []
  26 + hasMore?: null
  27 + itemId: string = ""
  28 + itemType: string = ""
  29 + itemTypeCode: string = ""
  30 + keyArticle: number= 0
  31 + landscape?: null
  32 + likeStyle?: null
  33 + linkUrl: string = ""
  34 + liveInfo?: null
  35 + menuShow: number = 0
  36 + newTags: string = ""
  37 + newsAuthor: string = ""
  38 + newsSubTitle: string = ""
  39 + newsSummary: string = ""
  40 + newsTitle: string = ""
  41 + newsTitleColor: string = ""
  42 + objectId: string = ""
  43 + objectLevel: string = ""
  44 + objectType: string = ""
  45 + openComment?: null
  46 + openLikes?: null
  47 + pageId: string = ""
  48 + photoNum?: null
  49 + position?: null
  50 + productNum?: null
  51 + publishTime: string = ""
  52 + pushTime: number = 0
  53 + pushUnqueId: number = 0
  54 + readFlag: number = 0
  55 + recommend?: null
  56 + relId: number = 0
  57 + relObjectId: string = ""
  58 + relType: number = 0
  59 + rmhInfo?: null
  60 + rmhPlatform: number = 0
  61 + sceneId: string = ""
  62 + shareInfo?: null
  63 + // slideShows: Array< unknown >
  64 + sortValue?: null
  65 + source: string = ""
  66 + subObjectType: string = ""
  67 + subSceneId: string = ""
  68 + // tagIds: Array< unknown >
  69 + tagWord?: null
  70 + titleShow?: null
  71 + titleShowPolicy?: null
  72 + topicTemplate?: null
  73 + traceId: string = ""
  74 + traceInfo: string = ""
  75 + userInfo?: null
  76 + videoInfo?: null
  77 + visitorComment: number = 0
  78 + voiceInfo?: null
  79 +}
  80 +
  81 +export class FullColumnImgUrl{
  82 +
  83 +}
  1 +@Observed
1 export class MessageItem{ 2 export class MessageItem{
2 imgSrc:Resource = $r("app.media.xxhdpi_pic_wb") 3 imgSrc:Resource = $r("app.media.xxhdpi_pic_wb")
3 title:string = "" 4 title:string = ""
4 desc:string = "" 5 desc:string = ""
5 time:string = "" 6 time:string = ""
  7 + unReadCount:number = 0
6 8
7 constructor(imgSrc:Resource,title:string,desc:string,time:string){ 9 constructor(imgSrc:Resource,title:string,desc:string,time:string){
8 this.imgSrc = imgSrc 10 this.imgSrc = imgSrc
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 "pages/ShowUserHeaderPage", 25 "pages/ShowUserHeaderPage",
26 "pages/MineMessagePage", 26 "pages/MineMessagePage",
27 "components/page/InteractMessagePage", 27 "components/page/InteractMessagePage",
28 - "pages/ShowHomePageHeaderPage" 28 + "pages/ShowHomePageHeaderPage",
  29 + "pages/SubscribeMessagePage"
29 ] 30 ]
30 } 31 }