From 76b7785d84e1e1547ed4567997559da21e043f2b Mon Sep 17 00:00:00 2001 From: XiuYun CHEN Date: Tue, 5 Aug 2025 17:02:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=92=E6=A0=87=EF=BC=8C=E5=B0=8F=E7=BA=A2?= =?UTF-8?q?=E7=82=B9=EF=BC=8C=E7=BE=A4=E5=8F=91=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chatkit/src/main/ets/ChatKitClient.ets | 5 +- chatkit_ui/src/main/ets/pages/ChatP2PPage.ets | 7 ++ commons/basic/Index.ets | 4 +- .../src/main/ets/constants/BasicConstant.ets | 5 +- .../ets/utils/NotificationManagementUtil.ets | 32 ++++++ commons/basic/src/main/ets/utils/request.ets | 5 +- .../main/ets/view/ConversationViewItem.ets | 3 +- features/Home/oh-package.json5 | 3 +- .../src/main/ets/components/HomeIconComp.ets | 105 ++++++++++++++++-- features/Home/src/main/ets/pages/HomePage.ets | 1 + .../netease/src/main/ets/view/TabBarComp.ets | 6 +- .../ets/components/SendGroupMessageComp.ets | 45 +++++--- .../main/ets/pages/LocalConversationPage.ets | 6 +- .../main/ets/pages/LoginPage/LoginPage.ets | 2 +- .../main/ets/pages/MinePage/SettingPage.ets | 5 +- 15 files changed, 199 insertions(+), 35 deletions(-) create mode 100644 commons/basic/src/main/ets/utils/NotificationManagementUtil.ets diff --git a/chatkit/src/main/ets/ChatKitClient.ets b/chatkit/src/main/ets/ChatKitClient.ets index c4ff031..b37b321 100644 --- a/chatkit/src/main/ets/ChatKitClient.ets +++ b/chatkit/src/main/ets/ChatKitClient.ets @@ -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 = { diff --git a/chatkit_ui/src/main/ets/pages/ChatP2PPage.ets b/chatkit_ui/src/main/ets/pages/ChatP2PPage.ets index 827e83a..fc3e218 100644 --- a/chatkit_ui/src/main/ets/pages/ChatP2PPage.ets +++ b/chatkit_ui/src/main/ets/pages/ChatP2PPage.ets @@ -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; let datas=json.data as Record; 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) => { }) diff --git a/commons/basic/Index.ets b/commons/basic/Index.ets index 6a19bc6..de6c3c3 100644 --- a/commons/basic/Index.ets +++ b/commons/basic/Index.ets @@ -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' \ No newline at end of file +export { ScanUtil } from './src/main/ets/utils/ScanUtil' + +export { NotificationManagementUtil } from './src/main/ets/utils/NotificationManagementUtil' \ No newline at end of file diff --git a/commons/basic/src/main/ets/constants/BasicConstant.ets b/commons/basic/src/main/ets/constants/BasicConstant.ets index 49a8a13..d5e1fc3 100644 --- a/commons/basic/src/main/ets/constants/BasicConstant.ets +++ b/commons/basic/src/main/ets/constants/BasicConstant.ets @@ -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' diff --git a/commons/basic/src/main/ets/utils/NotificationManagementUtil.ets b/commons/basic/src/main/ets/utils/NotificationManagementUtil.ets new file mode 100644 index 0000000..05c1aaf --- /dev/null +++ b/commons/basic/src/main/ets/utils/NotificationManagementUtil.ets @@ -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(() => { + + }); + } + + + +} + diff --git a/commons/basic/src/main/ets/utils/request.ets b/commons/basic/src/main/ets/utils/request.ets index aa5ade2..d65ab14 100644 --- a/commons/basic/src/main/ets/utils/request.ets +++ b/commons/basic/src/main/ets/utils/request.ets @@ -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(url: string, datas: HashMap): Promise> { // 创建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(url: string, datas: HashMap): Promise> { // 创建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, diff --git a/conversationkit_ui/src/main/ets/view/ConversationViewItem.ets b/conversationkit_ui/src/main/ets/view/ConversationViewItem.ets index c89ecad..6abf745 100644 --- a/conversationkit_ui/src/main/ets/view/ConversationViewItem.ets +++ b/conversationkit_ui/src/main/ets/view/ConversationViewItem.ets @@ -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') diff --git a/features/Home/oh-package.json5 b/features/Home/oh-package.json5 index f77ac6c..34da38b 100644 --- a/features/Home/oh-package.json5 +++ b/features/Home/oh-package.json5 @@ -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" } } \ No newline at end of file diff --git a/features/Home/src/main/ets/components/HomeIconComp.ets b/features/Home/src/main/ets/components/HomeIconComp.ets index 519f48c..8b3f22b 100644 --- a/features/Home/src/main/ets/components/HomeIconComp.ets +++ b/features/Home/src/main/ets/components/HomeIconComp.ets @@ -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 = new HashMap(); + hdHttp.httpReq(BasicConstant.indexV2,hashMap).then(async (res: HdResponse) => { + 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) } } + } diff --git a/features/Home/src/main/ets/pages/HomePage.ets b/features/Home/src/main/ets/pages/HomePage.ets index 7e5c157..f4a8797 100644 --- a/features/Home/src/main/ets/pages/HomePage.ets +++ b/features/Home/src/main/ets/pages/HomePage.ets @@ -170,4 +170,5 @@ export struct HomePage { .width('100%') .height('100%') } + } diff --git a/features/netease/src/main/ets/view/TabBarComp.ets b/features/netease/src/main/ets/view/TabBarComp.ets index 915e2e6..1260a59 100644 --- a/features/netease/src/main/ets/view/TabBarComp.ets +++ b/features/netease/src/main/ets/view/TabBarComp.ets @@ -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() diff --git a/features/patient/src/main/ets/components/SendGroupMessageComp.ets b/features/patient/src/main/ets/components/SendGroupMessageComp.ets index 9892bde..d0e37d4 100644 --- a/features/patient/src/main/ets/components/SendGroupMessageComp.ets +++ b/features/patient/src/main/ets/components/SendGroupMessageComp.ets @@ -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 = JSON.parse(res+'') as Record; if(json.code == '200') { - if (Array.isArray(json.data)) { - const data:Array> = json.data - if (data.length>0) { - this.isPossessList = true - } else { - this.getListOutPatient() - } - } else { + let json = JSON.parse(res+'') as Record; + 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> = 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 = JSON.parse(res+'') as Record; if(json.code == '200') { - if (Array.isArray(json.data)) { - const data:Array> = json.data - if (data.length>0) { - this.isPossessList = true - } + let json = JSON.parse(res+'') as Record; + let json1=json.data as Record + let datas:[]=json1.list as [] + if(datas!=null&&datas.length>0) + { + this.isPossessList=true } + // if (Array.isArray(json.data)) { + // const data:Array> = json.data + // if (data.length>0) { + // this.isPossessList = true + // } + // } } else { console.error('门诊列表失败:'+json.message) promptAction.showToast({ message: json.message, duration: 1000 }) diff --git a/localconversationkit_ui/src/main/ets/pages/LocalConversationPage.ets b/localconversationkit_ui/src/main/ets/pages/LocalConversationPage.ets index 4ccab2b..7b44870 100644 --- a/localconversationkit_ui/src/main/ets/pages/LocalConversationPage.ets +++ b/localconversationkit_ui/src/main/ets/pages/LocalConversationPage.ets @@ -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() { diff --git a/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets b/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets index 0937971..3656f33 100644 --- a/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets +++ b/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets @@ -29,7 +29,7 @@ struct LoginPage { onLogins() { - this.login(AppConfig.userId, AppConfig.userToken) + this.login(this.YX_accid,this.YX_token) } private dialog!:CustomDialogController; diff --git a/products/expert/src/main/ets/pages/MinePage/SettingPage.ets b/products/expert/src/main/ets/pages/MinePage/SettingPage.ets index 7e1a644..7c30f97 100644 --- a/products/expert/src/main/ets/pages/MinePage/SettingPage.ets +++ b/products/expert/src/main/ets/pages/MinePage/SettingPage.ets @@ -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() }