获取到红包信息后更新UI
This commit is contained in:
@@ -142,10 +142,12 @@
|
||||
v-else-if="item.type === TYPES.MSG_LOCATION"
|
||||
:content="item.getMessageContent()"
|
||||
/>
|
||||
<!-- 自定义消息,目前只支持【红包】 -->
|
||||
<MessageCustom
|
||||
v-else-if="item.type === TYPES.MSG_CUSTOM"
|
||||
:content="item.getMessageContent()"
|
||||
:messageItem="item"
|
||||
@claim="onClaim(item)"
|
||||
/>
|
||||
</MessageBubble>
|
||||
</div>
|
||||
@@ -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
|
||||
|
||||
@@ -78,14 +78,14 @@
|
||||
"
|
||||
>
|
||||
<!-- 红包 -->
|
||||
<view class="red-envelope">
|
||||
<view class="red-envelope" @click="onClaim">
|
||||
<view class="top-title">
|
||||
<Icon :file="unopenedEnvelope" width="78rpx" height="80rpx" />
|
||||
<text class="title">
|
||||
{{ customData.title }}
|
||||
</text>
|
||||
</view>
|
||||
<text class="bottom-text">积分红包</text>
|
||||
<text class="bottom-text">积分红包{{ customData.isOpen }}</text>
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -112,11 +112,19 @@
|
||||
content: any
|
||||
}
|
||||
|
||||
interface IEmit {
|
||||
(key: 'claim'): void
|
||||
}
|
||||
|
||||
const emits = defineEmits<IEmit>()
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
messageItem: undefined,
|
||||
content: undefined
|
||||
})
|
||||
|
||||
console.log(props.messageItem, '获取到红包信息后更新UI')
|
||||
|
||||
const custom = ref()
|
||||
const message = ref<IMessageModel>()
|
||||
const extension = ref()
|
||||
@@ -137,6 +145,12 @@
|
||||
const openLink = (url: any) => {
|
||||
window.open(url)
|
||||
}
|
||||
|
||||
/** 红包领取 */
|
||||
const onClaim = () => {
|
||||
// console.log(customData.value)
|
||||
emits('claim')
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import '../../../../assets/styles/common';
|
||||
|
||||
Reference in New Issue
Block a user