yangchenggong1_wd

desc:消息 圆点

... ... @@ -316,6 +316,10 @@ export class HttpUrlUtils {
*/
static readonly FEEDBACK_TYPE_PATH: string = "/api/rmrb-interact/interact/c/user/optionClassify/list";
/**
* 查询点赞、回复我的、系统消息的未读数量以及回复/评论人
*/
static readonly MESSAGE_UN_READ_DATA_PATH: string = "/api/rmrb-inside-mail/zh/c/inside-mail/private/polymerizationInfo?createTime=";
static getHost(): string {
return HostManager.getHost();
... ... @@ -714,4 +718,10 @@ export class HttpUrlUtils {
return url;
}
//获取消息未读接口
static getMessageUnReadDataUrl() {
let url = HttpUrlUtils.getHost() + HttpUrlUtils.MESSAGE_UN_READ_DATA_PATH
return url
}
}
\ No newline at end of file
... ...
import { WDRouterRule, WDRouterPage } from 'wdRouter'
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
import { PagePersonFunction } from './PagePersonFunction'
@Component
export default struct MinePagePersonFunctionUI {
... ... @@ -10,30 +11,7 @@ export default struct MinePagePersonFunctionUI {
Grid(){
ForEach(this.personalData,(item:MinePagePersonalFunctionsItem,index:number)=>{
GridItem(){
Row(){
Column(){
Image(item.imgSrc)
.width('46lpx')
.height('46lpx')
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
Text(`${item.msg}`)
.margin({top:'8lpx'})
.height('23lpx')
.fontColor($r('app.color.color_222222'))
.fontSize('23lpx')
}
.alignItems(HorizontalAlign.Center)
.width('100%')
Blank()
.layoutWeight(1)
if(index % 4 < 3 && index != this.personalData.length-1){
Text().backgroundColor($r('app.color.color_222222'))
.opacity(0.1)
.width('2lpx')
.height('29lpx')
}
}
PagePersonFunction({ item: item, noDivider : (index % 4 < 3 && index != this.personalData.length-1) ? false : true})
}.onClick(()=>{
console.log(index+"")
switch (item.msg){
... ... @@ -97,4 +75,5 @@ export default struct MinePagePersonFunctionUI {
.height('234lpx')
.margin({top:'31lpx',left:'23lpx',right:'23lpx' })
}
}
\ No newline at end of file
}
... ...
import MinePagePersonalFunctionsItem from '../../viewmodel/MinePagePersonalFunctionsItem'
@Component
export struct PagePersonFunction{
@ObjectLink item: MinePagePersonalFunctionsItem
@State noDivider:boolean = false
build() {
Row(){
Column(){
Stack({ alignContent: Alignment.TopEnd }){
Image(this.item.imgSrc)
.objectFit(ImageFit.Auto)
.interpolation(ImageInterpolation.High)
if (this.item.isShowRedPoint) {
Button()
.type(ButtonType.Circle)
.width("12lpx")
.height("12lpx")
.backgroundColor($r('app.color.color_ED2800'))
}
}.width('46lpx')
.height('46lpx')
Text(`${this.item.msg}`)
.margin({top:'8lpx'})
.height('23lpx')
.fontColor($r('app.color.color_222222'))
.fontSize('23lpx')
}
.alignItems(HorizontalAlign.Center)
.width('100%')
Blank()
.layoutWeight(1)
if(!this.noDivider){
Text().backgroundColor($r('app.color.color_222222'))
.opacity(0.1)
.width('2lpx')
.height('29lpx')
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -53,8 +53,25 @@ export struct MinePageComponent {
this.getUserLogin()
this.getFunctionData()
this.addLoginStatusObserver()
this.getMessageData()
}
getMessageData(){
MinePageDatasModel.getMessageUnReadData().then((value) => {
if(value !=null) {
if(value.activeCount >0 ||value.subscribeCount > 0 || value.systemCount > 0){
this.personalData.forEach((value) => {
if(value.msg == "消息")
value.isShowRedPoint = true
})
}
}
}).catch((err: Error) => {
console.log(TAG, JSON.stringify(err))
})
}
async addLoginStatusObserver(){
this.preferences = await SPHelper.default.getPreferences();
this.preferences.on('change', this.observer);
... ...
... ... @@ -24,6 +24,7 @@ import { CommentLikeOperationRequestItem } from '../viewmodel/CommentLikeOperati
import { FollowOperationRequestItem } from '../viewmodel/FollowOperationRequestItem';
import { SpConstants } from 'wdConstant/Index';
import { MessageItem } from '../viewmodel/MessageItem';
import { MessageUnReadItem } from '../viewmodel/MessageUnReadItem';
const TAG = "MinePageDatasModel"
... ... @@ -597,6 +598,33 @@ class MinePageDatasModel{
})
})
}
/**
* 获取消息未读数据
* @param pageSize
* @param pageNum
* @returns
*/
getMessageUnReadData(): Promise<MessageUnReadItem> {
return new Promise<MessageUnReadItem>((success, error) => {
this.fetchMessageUnReadData().then((navResDTO: ResponseDTO<MessageUnReadItem>) => {
if (!navResDTO || navResDTO.code != 0) {
error(null)
return
}
let navigationBean = navResDTO.data as MessageUnReadItem
success(navigationBean);
}).catch((err: Error) => {
error(null)
})
})
}
fetchMessageUnReadData() {
let url = HttpUrlUtils.getMessageUnReadDataUrl()
return WDHttp.get<ResponseDTO<MessageUnReadItem>>(url)
};
}
const minePageDatasModel = MinePageDatasModel.getInstance()
... ...
export class MessageUnReadItem{
activeCount: number = 0 //互动通知未读数
subscribeCount: number = 0 //预约消息未读数
systemCount: number = 0 //系统通知未读数
subscribeInfo: SubscribeInfo = new SubscribeInfo()
systemInfo: SystemInfo = new SystemInfo()
activeInfo: ActiveInfo = new ActiveInfo
}
class SubscribeInfo{
classify: string = ""
contentId: string = ""
contentType: string = ""
id: number = -1
message: string = ""
platform: string = ""
privateMailId: number = -1
privateMailIdList: Array< string > = []
privateMailIds: string = ""
privateMailNum: number = -1
read: boolean = false
source: string = ""
time: string = ""
title: string = ""
userId: number = -1
remark: string = ""
}
class SystemInfo{
classify: string = ""
contentType: string = ""
id: number = -1
message: string = ""
platform: string = ""
privateMailId: number = -1
privateMailIdList: Array< string > = []
privateMailIds: string = ""
privateMailNum: number = -1
read: boolean = false
source: string = ""
time: string = ""
title: string = ""
userId: number = -1
}
class ActiveInfo{
id:string = ""
message: string = ""
time: string = ""
title: string = ""
}
\ No newline at end of file
... ...
import FunctionsItem from './FunctionsItem'
@Observed
export default class MinePagePersonalFunctionsItem extends FunctionsItem {
isShowRedPoint:boolean = false
}
\ No newline at end of file
... ...