扩展消息部分代码提交

This commit is contained in:
XiuYun CHEN
2025-07-14 17:37:45 +08:00
parent cf7aa93d6e
commit 1121cc3f20
15 changed files with 200 additions and 73 deletions
+15 -6
View File
@@ -75,7 +75,7 @@ import { TextMessageDetailDialog } from '../view/TextMessageDetailDialog';
import { TeachDialog } from '../view/TeachDialog';
import { NewWaDialog } from '../view/NewWaDialog';
import { PerfactInputSheet } from '@itcast/basic/src/main/ets/Views/PerfactInputSheet'
import { hdHttp, HdResponse,BasicConstant, authStore} from '@itcast/basic'
import { hdHttp, HdResponse,BasicConstant, authStore, preferenceStore, ChatParam} from '@itcast/basic'
import { HashMap } from '@kit.ArkTS';
import { customAttachment } from '../view/MessageComponentBuilder'
@@ -84,6 +84,8 @@ export struct ChatP2PPage {
pathStack: NavPathStack = new NavPathStack()
sessionId=''//患者的云信id
patientUuid=''//患者uuid
@Local chat_state:string=''
@Local gdxz_sessionType:string= preferenceStore.getItemString('gdxz_sessionType')
@Local statusBarHeight:number=0
@Local havestopout:boolean=false;//是否有出诊公告
@Local chatUserInfo: ChatUserInfo = new ChatUserInfo();
@@ -420,6 +422,11 @@ export struct ChatP2PPage {
}
aboutToAppear() {
if(this.chat_state=='3')
{
this.bottomHeight==0
}
NEEmojiManager.instance.setup();
DeviceUtils.rootDirPath = getContext(this).filesDir
this.operationMoreDataList = setupMoreOperationData()
@@ -574,8 +581,8 @@ export struct ChatP2PPage {
NavDestination() {
NavigationBackBuilder({
title:this.showName ,
rightButtonIcon: this.showMultiSelect ? undefined : $r('app.media.ic_public_more_dot'),
rightButtonTitle: this.showMultiSelect ? $r('app.string.chat_msg_dialog_cancel') : undefined,
rightButtonIcon: this.gdxz_sessionType==BasicConstant.general ? $r('app.media.more') :undefined,
rightButtonTitle: this.gdxz_sessionType==BasicConstant.consult && this.chat_state!='3'? '关闭会话' : undefined,
top:this.statusBarHeight,
rightButtonAction: () => {
this.goToSettingPage(this.pathStack)
@@ -776,7 +783,7 @@ export struct ChatP2PPage {
top: { anchor: "chatPageListView", align: VerticalAlign.Bottom },
})
if (this.hideInput === false && !this.showMultiSelect) {
if (this.hideInput === false && !this.showMultiSelect&&this.chat_state!='3') {
NEChatInputView({
controller: this.controller,
placeHolder: (this.chatUserInfo.conversationName ?? '').length > 15 ?
@@ -1087,9 +1094,11 @@ export struct ChatP2PPage {
.hideTitleBar(true)
.onReady((context: NavDestinationContext) => {
this.pathStack = context.pathStack
let param = this.pathStack.getParamByName("ChatP2PPage") as string[];
let param = this.pathStack.getParamByName("ChatP2PPage") as ChatParam[];
if (param.length > 0) {
this.conversationId = param[0];
this.conversationId = param[0].conversationId;
this.showName= param[0].name+'';
this.chat_state=param[0].chat_state
this.loadChatData();
} else {
this.pathStack.removeByName("ChatP2PPage")
@@ -36,6 +36,7 @@ import {
V2NIMMessageFileAttachment,
V2NIMMessagePinNotification,
V2NIMMessagePinState,
V2NIMMessagePushConfig,
V2NIMMessageRevokeNotification,
V2NIMMessageSendingState,
V2NIMMessageType,
@@ -57,10 +58,10 @@ import { ChatKitConfig } from '../ChatKitConfig';
import { sceneMap } from '@kit.MapKit';
import { clearForwardAtMark, createForwardMessageListFileDetail, sendMessageFailedTips } from '../common/MessageHelper';
import { instanceToPlain } from 'class-transformer';
import { NECommonUtils } from '@nimkit/common';
import { NECommonUtils, UserUtils } from '@nimkit/common';
import { HashMap, JSON } from '@kit.ArkTS';
import { assign } from '@nimsdk/vendor';
import { BasicConstant, ChatExtModel } from '@itcast/basic';
import { BasicConstant, ChatExtModel, preferenceStore } from '@itcast/basic';
@ObservedV2
export class ChatBaseViewModel {
@@ -654,13 +655,14 @@ export class ChatBaseViewModel {
}
// 消息发送之前调用,用于配置消息通用参数
beforeSendMessage(msg: V2NIMMessage): V2NIMMessage {
beforeSendMessage(msg: V2NIMMessage){
// if (ChatKitConfig.messageReadState) {
// let msgConfig: V2NIMMessageConfig = {
// readReceiptEnabled: false
// }
// msg.messageConfig = msgConfig
// }
return msg
}
@@ -689,12 +691,7 @@ export class ChatBaseViewModel {
// let extension = JSON.stringify(instanceToPlain(extensionMap))
// message.serverExtension = extension
// }
let extension:ChatExtModel= {
gdxz_sessionType: '',
gdxz_consult_uuid: '',
gdxz_nickName: ''
}
message.serverExtension =JSON.stringify(extension)
//设置推送
@@ -911,6 +908,19 @@ export class ChatBaseViewModel {
* @param progress 消息发送进度
*/
async sendMessage(msg: V2NIMMessage, params?: V2NIMSendMessageParams, progress?: (percentage: number) => void) {
let extension:ChatExtModel= {
gdxz_sessionType: preferenceStore.getItemString('gdxz_sessionType'),
gdxz_consult_uuid: preferenceStore.getItemString('gdxz_consult_uuid')+'',
gdxz_nickName:await UserUtils.getAvatarName(ChatKitClient.nim.conversationIdUtil.parseConversationTargetId(this.conversationId),'')
}
msg.serverExtension =JSON.stringify(extension)
// Map<String,Integer> p=new HashMap<>();
// p.put("classification",1);
// payload.put("vivoField",p);//vivo推送
// payload.put("apns-collapse-id", "321");//ios需要
// payload.put("apns-from-id", NimUIKit.getAccount());//ios需要
// msg.pushConfig = {} as V2NIMMessagePushConfig
// msg.pushConfig.pushPayload=''
ChatRepo.sendMessage(this.beforeSendMessage(msg), this.conversationId!, params, progress)
.catch((err: BusinessError) => {
console.error("net ease send message error", err.code, err.message);
Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B