角标,小红点,群发消息

This commit is contained in:
XiuYun CHEN 2025-08-05 17:02:15 +08:00
parent 9355959b36
commit 76b7785d84
15 changed files with 199 additions and 35 deletions

View File

@ -28,7 +28,7 @@ import { ChatRepo } from './repo/ChatRepo';
import { saveLocalRevokeMessageFormOther } from './utils/MessageUtils';
import { LengthMetrics, router } from '@kit.ArkUI';
import { HMRouterMgr } from '@hadss/hmrouter';
import { ChangeUtil, NotificationUtil } from '@itcast/basic';
import { ChangeUtil, NotificationManagementUtil, NotificationUtil } from '@itcast/basic';
import { BusinessError } from '@kit.BasicServicesKit';
import { NotificationBasicOptions } from '@itcast/basic/src/main/ets/pushnotification/NotificationOptions';
export const currentConversationChanged: string = 'CurrentConversationChanged'
@ -209,7 +209,8 @@ export class ChatKitClient {
// 消息撤回监听,消息撤回后,会收到通知
ChatRepo.onRevokeMessage(ChatKitClient.onRevokeFun)
ChatKitClient.hasInitListener = true
let unreadCount=ChatKitClient.nim.localConversationService?ChatKitClient.nim.localConversationService.getTotalUnreadCount():-1
NotificationManagementUtil.setBadgeNumber(unreadCount)
// ChatKitClient.nim.messageService?.on("onReceiveMessages", (messages: V2NIMMessage[]) => {
// for (const message of messages) {
// let basicOptions: NotificationBasicOptions = {

View File

@ -23,6 +23,7 @@ import {
NECommonUtils,
NetworkBrokenBuilder,
PermissionsUtils,
StringIsEmpty,
UserUtils,
VideoViewerDialog
} from '@nimkit/common';
@ -450,7 +451,13 @@ export struct ChatP2PPage {
let json = JSON.parse(res+'') as Record<string, object>;
let datas=json.data as Record<string, string>;
this.patientUuid=datas.uuid
let tmpname= this.showName
this.showName=await UserUtils.getAvatarName(this.patientUuid,String(this.chatUserInfo.conversationName))
if(StringIsEmpty(this.showName))
{
this.showName=tmpname
}
}).catch((err: BusinessError) => {
})

View File

@ -101,4 +101,6 @@ export { HdTwoNav } from './src/main/ets/components/HdTwoNav'
export { NotificationUtil } from './src/main/ets/utils/NotificationUtil'
export { ScanUtil } from './src/main/ets/utils/ScanUtil'
export { ScanUtil } from './src/main/ets/utils/ScanUtil'
export { NotificationManagementUtil } from './src/main/ets/utils/NotificationManagementUtil'

View File

@ -13,7 +13,7 @@ export class BasicConstant {
static readonly urlExpert = "https://dev-app.igandan.com/app/expert/"
static readonly wxUrl = "https://dev-wx.igandan.com/";
static readonly polvId = "11";//保利威视学员id
static readonly urlApp="https://dev-app.igandan.com/app/"
//正式环境
// static readonly urlExpertAPI = "https://app.igandan.com/app/expertAPI/";
// static readonly urlExpertApp = "http://app.igandan.com/app/expertApp/"
@ -22,8 +22,9 @@ export class BasicConstant {
// static readonly urlExpert = "http://app.igandan.com/app/expert/"
// static readonly wxUrl = "https://wx.igandan.com/";// 微信服务器地址
// static readonly polvId = "21";//保利威视学员id
// static readonly urlApp="http://app.igandan.com/app/"
static readonly getSystemTimeStamp = BasicConstant.urlImage+'manager/getSystemTimeStamp'
static readonly getSystemTimeStamp = BasicConstant.urlApp+'manager/getSystemTimeStamp'
static readonly addBonusPoints = BasicConstant.urlExpertApp+'addBonusPoints'
static readonly indexV2 = BasicConstant.urlExpertAPI+'indexV2';//首页轮播
static readonly applyList = BasicConstant.urlExpert+'applyList'

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { notificationManager } from '@kit.NotificationKit';
export class NotificationManagementUtil {
static async setBadgeNumber(num: number) {
if(num<0)
{
return
}
await notificationManager.setBadgeNumber(num).then(() => {
});
}
}

View File

@ -11,6 +11,7 @@ import { bundleManager} from '@kit.AbilityKit';
import { deviceInfo } from '@kit.BasicServicesKit';
import { cryptoFramework } from '@kit.CryptoArchitectureKit';
import { rcp } from '@kit.RemoteCommunicationKit';
import { BasicConstant } from '../../../../Index';
interface HdRequestOptions {
baseURL?: string
@ -188,7 +189,7 @@ class HdHttp {
httpReq<T>(url: string, datas: HashMap<string, string>): Promise<HdResponse<T>> {
// 创建httpRequest对象。
let httpRequest = http.createHttp();
let url1 = "https://dev-app.igandan.com/app/manager/getSystemTimeStamp";
let url1 = BasicConstant.getSystemTimeStamp;
let promise = httpRequest.request(
// 请求url地址
url1,
@ -230,7 +231,7 @@ class HdHttp {
httpReqObject<T>(url: string, datas: HashMap<string, Object>): Promise<HdResponse<T>> {
// 创建httpRequest对象。
let httpRequest = http.createHttp();
let url1 = "https://dev-app.igandan.com/app/manager/getSystemTimeStamp";
let url1 = BasicConstant.getSystemTimeStamp;
let promise = httpRequest.request(
// 请求url地址
url1,

View File

@ -208,7 +208,8 @@ export struct ConversationViewItem {
return $r('app.string.msg_type_rtc_video')
}
}
case V2NIMMessageType.V2NIM_MESSAGE_TYPE_CUSTOM:
return $r('app.string.tipMessageType')
}
return item.lastMessage?.text ?? $r('app.string.chatMessageNonsupportType')

View File

@ -10,6 +10,7 @@
"@polyvharmony/media-player-sdk": "2.5.0",
"@polyvharmony/media-player-sdk-addon-cache-down": "2.5.0",
"scene_single_video": "file:../../scene_single_video",
"media-player-common": "file:../../polyv"
"media-player-common": "file:../../polyv",
"@nimkit/chatkit": "file:../../chatkit"
}
}

View File

@ -1,6 +1,6 @@
import { iconsModel } from '../model/HomeModel'
import { patientDbManager, PatientEntity } from '@itcast/basic';
import { promptAction, router } from '@kit.ArkUI';
import { HomeModel, iconsModel } from '../model/HomeModel'
import { BasicConstant, hdHttp, HdResponse, patientDbManager, PatientEntity } from '@itcast/basic';
import { promptAction, router, UIObserver, uiObserver } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
import { pushService } from '@kit.PushKit';
@ -9,18 +9,34 @@ import { pushService } from '@kit.PushKit';
// name:string;
// isRed:boolean;
// }
import { ChatKitClient, LocalConversationRepo } from '@nimkit/chatkit';
import { HashMap } from '@kit.ArkTS';
@Component
export struct HomeIconComp {
@Prop iconList: iconsModel[];
@State patientIcon: string = '';
@State patientName: string = '我的患者';
@State patientRed: boolean = false;
@State videoIcon: string = '';
@State videoName: string = '肝胆视频';
@State zixunIcon: string = '';
@State consultation: string = '公益咨询';
@State consultationRed: boolean = false;
@State iconListtmp:iconsModel[]=[];
listener: (info: uiObserver.RouterPageInfo) => void = (info: uiObserver.RouterPageInfo) => {
let routerInfo: uiObserver.RouterPageInfo | undefined = this.queryRouterPageInfo();
if (info.pageId == routerInfo?.pageId) {
if (info.state == uiObserver.RouterPageState.ON_PAGE_SHOW) {
this.getRedCount()
} else if (info.state == uiObserver.RouterPageState.ON_PAGE_HIDE) {
}
}
}
aboutToAppear(): void {
let uiObserver: UIObserver = this.getUIContext().getUIObserver();
uiObserver.on('routerPageUpdate', this.listener);
for (const icons of this.iconList) {
if (icons.name === '我的患者') {
this.patientIcon = icons.img;
@ -30,19 +46,91 @@ export struct HomeIconComp {
this.zixunIcon = icons.img
}
}
this.initList()
// for (let index = 0; index < this.iconList!.length; index++) {
// const iconModel = this.iconList![index] as iconsModel ;
// if (index == 0) {
// iconModel.isRed = true;
// }
// }
this.getRedCount()
}
for (let index = 0; index < this.iconList!.length; index++) {
const iconModel = this.iconList![index] as iconsModel ;
if (index == 0) {
iconModel.isRed = true;
aboutToDisappear(): void {
let uiObserver: UIObserver = this.getUIContext().getUIObserver();
uiObserver.off('routerPageUpdate', this.listener);
}
async getRedCount()
{
let unreadCount = LocalConversationRepo.getTotalUnreadCount() ?? 0
let consultcount=0
const result = await LocalConversationRepo.getConversationList(0,100)
if(result!=null&&result.conversationList!=null)
{
for (const conversation of result.conversationList) {
const uuid = ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(conversation.conversationId);
// 假设 selectUserStyleWithModel 返回 "1" 表示 type=1
const style = await patientDbManager.getPatientTypeByUuid(uuid);
if (style != 1) {
if(conversation.unreadCount>0)
{
consultcount++
}
}
}
}
unreadCount=unreadCount-consultcount
if(unreadCount>0)
{
this.patientRed=true
}
else
{
this.patientRed=false
}
if(consultcount>0)
{
this.consultationRed=true
}
this.initList()
const hashMap: HashMap<string, string> = new HashMap();
hdHttp.httpReq<string>(BasicConstant.indexV2,hashMap).then(async (res: HdResponse<string>) => {
let json:HomeModel = JSON.parse(res+'') as HomeModel;
if(json.data!=null&&json.data.consult_list!=null&&json.data.consult_list.list!=null)
{
consultcount=consultcount>0?consultcount:json.data.consult_list.list.length
if(consultcount>0)
{
this.consultationRed=true
}
else
{
this.consultationRed=false
}
this.initList()
}
}).catch((err: BusinessError) => {
})
}
initList()
{
this.iconListtmp=[...[{ 'img': this.patientIcon, 'name': this.patientName,'isRed':this.patientRed } as iconsModel,
{ 'img': this.videoIcon, 'name': this.videoName} as iconsModel,
{'img':this.zixunIcon,'name':this.consultation,'isRed':this.consultationRed} as iconsModel]]
}
build() {
Row() {
Grid() {
ForEach([{ 'img': this.patientIcon, 'name': this.patientName },{ 'img': this.videoIcon, 'name': this.videoName},{'img':this.zixunIcon,'name':this.consultation}], (item: iconsModel) => {//this.iconList
ForEach(this.iconListtmp, (item: iconsModel) => {//this.iconList
GridItem(){
Stack() {
Column() {
@ -76,4 +164,5 @@ export struct HomeIconComp {
}.width('100%').backgroundColor(Color.White)
}
}
}

View File

@ -170,4 +170,5 @@ export struct HomePage {
.width('100%')
.height('100%')
}
}

View File

@ -1,11 +1,13 @@
import { TabBarCompModel } from '../model/TabBarCompModel'
import { TabBarItems } from '../components/TabBarItems'
import { authStore, BasicConstant, hdHttp, HdLoadingDialog, HdResponse } from '@itcast/basic'
import { authStore, BasicConstant, hdHttp, HdLoadingDialog, HdResponse,
NotificationManagementUtil } from '@itcast/basic'
import { MessageComp } from '../view/MessageComp'
import { PatientListComp, updateExtraData } from './PatientListComp'
import { applyListCallBacl, FollowPlanListComp } from 'patient'
import { HMLifecycleState, HMRouterMgr } from '@hadss/hmrouter'
import { BusinessError } from '@kit.BasicServicesKit'
import { LocalConversationRepo } from '@nimkit/chatkit'
@Component
export struct TabBarComp {
@ -17,6 +19,8 @@ export struct TabBarComp {
private lifecycleOwner = HMRouterMgr.getCurrentLifecycleOwner()
private handleCallback = () => {
this.getApplyList()
let unreadCount=LocalConversationRepo.getTotalUnreadCount() ?? -1
NotificationManagementUtil.setBadgeNumber(unreadCount)
}
aboutToAppear() {
this.getApplyList()

View File

@ -67,7 +67,8 @@ export struct SendGroupMessageComp {
if (this.isPossessList) {
this.submintMessage("5")
} else {
HMRouterMgr.push({})
HMRouterMgr.push({pageUrl:'OutpatientComp',param:"send"})
}
this.outpatient.close();
}
@ -168,16 +169,25 @@ export struct SendGroupMessageComp {
logger.info('Response stopOutPatientList'+res);
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '200') {
if (Array.isArray(json.data)) {
const data:Array<Record<string,string>> = json.data
if (data.length>0) {
this.isPossessList = true
} else {
this.getListOutPatient()
}
} else {
let json = JSON.parse(res+'') as Record<string, object>;
let datas:[]=json.data as []
if(datas!=null&&datas.length>0)
{
this.isPossessList=true
}
else {
this.getListOutPatient()
}
// if (Array.isArray(json.data)) {
// const data:Array<Record<string,string>> = json.data
// if (data.length>0) {
// this.isPossessList = true
// } else {
// this.getListOutPatient()
// }
// } else {
// this.getListOutPatient()
// }
} else {
console.error('停/出诊公告列表失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })
@ -197,12 +207,19 @@ export struct SendGroupMessageComp {
logger.info('Response listOutPatient'+res);
let json:Record<string,string> = JSON.parse(res+'') as Record<string,string>;
if(json.code == '200') {
if (Array.isArray(json.data)) {
const data:Array<Record<string,string>> = json.data
if (data.length>0) {
this.isPossessList = true
}
let json = JSON.parse(res+'') as Record<string, object>;
let json1=json.data as Record<string, object>
let datas:[]=json1.list as []
if(datas!=null&&datas.length>0)
{
this.isPossessList=true
}
// if (Array.isArray(json.data)) {
// const data:Array<Record<string,string>> = json.data
// if (data.length>0) {
// this.isPossessList = true
// }
// }
} else {
console.error('门诊列表失败:'+json.message)
promptAction.showToast({ message: json.message, duration: 1000 })

View File

@ -27,7 +27,11 @@ export struct LocalConversationPage {
this.viewModel.onUreadMessageChange = this.onUreadMessageChange
//初始化@ 服务
// AitServer.instance.init()
this.viewModel.initConversation()
if(ChatKitClient.hasLogin())
{
this.viewModel.initConversation()
}
}
build() {

View File

@ -29,7 +29,7 @@ struct LoginPage {
onLogins()
{
this.login(AppConfig.userId, AppConfig.userToken)
this.login(this.YX_accid,this.YX_token)
}
private dialog!:CustomDialogController;

View File

@ -1,4 +1,6 @@
import { authStore, BasicConstant, ChangeUtil, HdNav , preferenceStore} from '@itcast/basic';
import { authStore, BasicConstant, ChangeUtil, HdNav ,
NotificationManagementUtil,
preferenceStore} from '@itcast/basic';
import { bundleManager, common, ConfigurationConstant, Want } from '@kit.AbilityKit';
import { fileIo, storageStatistics } from '@kit.CoreFileKit';
import { promptAction, router } from '@kit.ArkUI';
@ -60,6 +62,7 @@ struct SettingPage {
if (appExist) {
fileIo.rmdirSync(appCacheDir)
}
NotificationManagementUtil.setBadgeNumber(0)
promptAction.showToast({ message: '清理完毕' })
this.calcCache()
}