From f2cabe99f1fb8512faca94faf1e834ad460af0bb Mon Sep 17 00:00:00 2001
From: cbb <1055026847@qq.com>
Date: Thu, 8 Jan 2026 17:54:09 +0800
Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=88=B0=E7=BA=A2=E5=8C=85?=
=?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=90=8E=E6=9B=B4=E6=96=B0UI?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../red-envelope/index.vue | 83 ++++++++++---------
.../components/TUIChat/message-list/index.vue | 34 ++++++++
.../message-elements/message-custom.vue | 18 +++-
api/tui-kit.js | 9 ++
4 files changed, 105 insertions(+), 39 deletions(-)
diff --git a/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue b/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue
index 37ee8e7..b328c11 100644
--- a/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue
+++ b/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue
@@ -20,8 +20,9 @@
import { useUI } from '@/utils/use-ui'
import { navigateTo } from '@/utils/router'
import { sendRedEnvelope } from '../../../../../api/tui-kit'
+ import { useUserStore } from '../../../../../stores/user'
- const { showDialog } = useUI()
+ const { showDialog, showToast } = useUI()
const placeholderStyle = `font-family: PingFang SC, PingFang SC; font-weight: 500; color: #a9a9a9; font-size: 32rpx; font-style: normal; text-transform: none;`
const evaluateIcon = custom
@@ -169,57 +170,65 @@
const pwdModalSubmit = async (e: number[]) => {
// 默认文本
const text = `${formData.title || '恭喜发财,大吉大利'}`
- const payload = {
- data: JSON.stringify({
- businessID: CHAT_MSG_CUSTOM_TYPE.RED_ENVELOPE,
- version: 1,
- // 积分
- integral: Number(formData.integral),
- // 红包个数
- num: Number(formData.num || '1'),
- // 发送类型
- type: currentConversation?.value?.type,
- title: text
- }),
- description: text,
- extension: text
- }
- const options = {
- to:
- currentConversation?.value?.groupProfile?.groupID ||
- currentConversation?.value?.userProfile?.userID,
- conversationType: currentConversation?.value?.type,
- payload,
- needReadReceipt: isEnabledMessageReadReceiptGlobal()
- }
- const offlinePushInfoCreateParams: IOfflinePushInfoCreateParams = {
- conversation: currentConversation.value as IConversationModel,
- payload: options.payload,
- messageType: TUIChatEngine.TYPES.MSG_CUSTOM
- }
-
- const sendMessageOptions: SendMessageOptions = {
- offlinePushInfo: OfflinePushInfoManager.create(
- offlinePushInfoCreateParams
- )
- }
const isGroup = currentConversation?.value?.type === 'GROUP'
const data = {
password: e.join(''),
title: text,
- packetType: isGroup ? 2 : 1,
+ packetType: isGroup ? 2 : 3,
receiverType: isGroup ? 2 : 1,
+ receiverIMIds: isGroup
+ ? []
+ : [currentConversation?.value?.userProfile.userID],
totalAmount: Number(formData.integral),
totalCount: Number(formData.num || '1')
}
try {
tixian.value.close()
- await sendRedEnvelope(data)
+ const res = await sendRedEnvelope(data)
+
+ const payload = {
+ data: JSON.stringify({
+ id: res.data.id,
+ businessID: CHAT_MSG_CUSTOM_TYPE.RED_ENVELOPE,
+ version: 1,
+ // 积分
+ integral: Number(formData.integral),
+ // 红包个数
+ num: Number(formData.num || '1'),
+ // 发送类型
+ type: currentConversation?.value?.type,
+ // 是否打开红包
+ isOpen: false,
+ title: text
+ }),
+ description: text,
+ extension: text
+ }
+ const options = {
+ to:
+ currentConversation?.value?.groupProfile?.groupID ||
+ currentConversation?.value?.userProfile?.userID,
+ conversationType: currentConversation?.value?.type,
+ payload,
+ needReadReceipt: isEnabledMessageReadReceiptGlobal()
+ }
+ const offlinePushInfoCreateParams: IOfflinePushInfoCreateParams = {
+ conversation: currentConversation.value as IConversationModel,
+ payload: options.payload,
+ messageType: TUIChatEngine.TYPES.MSG_CUSTOM
+ }
+
+ const sendMessageOptions: SendMessageOptions = {
+ offlinePushInfo: OfflinePushInfoManager.create(
+ offlinePushInfoCreateParams
+ )
+ }
TUIChatService.sendCustomMessage(
options as SendMessageParams,
sendMessageOptions
)
container?.value?.toggleDialogDisplay(false)
+ await showToast('发送成功', 'success')
} catch (error) {
tixian.value.close()
}
diff --git a/TUIKit/components/TUIChat/message-list/index.vue b/TUIKit/components/TUIChat/message-list/index.vue
index b3310ab..c5fb653 100644
--- a/TUIKit/components/TUIChat/message-list/index.vue
+++ b/TUIKit/components/TUIChat/message-list/index.vue
@@ -142,10 +142,12 @@
v-else-if="item.type === TYPES.MSG_LOCATION"
:content="item.getMessageContent()"
/>
+
@@ -277,6 +279,7 @@
import chatStorage from '../utils/chatStorage'
import { IAudioContext } from '../../../interface'
import { CHAT_MSG_CUSTOM_TYPE } from '../../../constant'
+ import { receiveRedEnvelope } from '../../../../api/tui-kit'
interface IEmits {
(e: 'closeInputToolBar'): void
@@ -601,6 +604,37 @@
})
}
+ /** 领取红包 */
+ const onClaim = (item: IMessageModel) => {
+ const { conversationType, flow, payload } = item
+ const data = JSON.parse(payload.data)
+ // 群聊
+ if (conversationType === TYPES.value.CONV_GROUP) {
+ console.log(item)
+ console.log(data)
+ receiveRedEnvelope({
+ redPacketId: data.id
+ })
+ } else {
+ // 个人红包
+ // 只能对方领取
+ if (flow === 'in') {
+ // 修改后的消息
+ const newMessage = {
+ ...data,
+ isOpen: true
+ }
+ item.modifyMessage({
+ cloudCustomData: JSON.stringify(newMessage)
+ })
+ return
+ receiveRedEnvelope({
+ redPacketId: data.id
+ })
+ }
+ }
+ }
+
const resendMessageConfirm = () => {
reSendDialogShow.value = !reSendDialogShow.value
const messageModel = resendMessageData.value
diff --git a/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue b/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue
index 614cdb7..a61ab66 100644
--- a/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue
+++ b/TUIKit/components/TUIChat/message-list/message-elements/message-custom.vue
@@ -78,14 +78,14 @@
"
>
-
+
{{ customData.title }}
- 积分红包
+ 积分红包{{ customData.isOpen }}
@@ -112,11 +112,19 @@
content: any
}
+ interface IEmit {
+ (key: 'claim'): void
+ }
+
+ const emits = defineEmits()
+
const props = withDefaults(defineProps(), {
messageItem: undefined,
content: undefined
})
+ console.log(props.messageItem, '获取到红包信息后更新UI')
+
const custom = ref()
const message = ref()
const extension = ref()
@@ -137,6 +145,12 @@
const openLink = (url: any) => {
window.open(url)
}
+
+ /** 红包领取 */
+ const onClaim = () => {
+ // console.log(customData.value)
+ emits('claim')
+ }