红包逻辑需要重构
This commit is contained in:
@@ -279,7 +279,12 @@
|
||||
import chatStorage from '../utils/chatStorage'
|
||||
import { IAudioContext } from '../../../interface'
|
||||
import { CHAT_MSG_CUSTOM_TYPE } from '../../../constant'
|
||||
import { receiveRedEnvelope } from '../../../../api/tui-kit'
|
||||
import {
|
||||
receiveRedEnvelope,
|
||||
getRedEnvelopeDetail
|
||||
} from '../../../../api/tui-kit'
|
||||
import { navigateTo } from '../../../../utils/router'
|
||||
import { useUI } from '../../../../utils/use-ui'
|
||||
|
||||
interface IEmits {
|
||||
(e: 'closeInputToolBar'): void
|
||||
@@ -604,9 +609,10 @@
|
||||
})
|
||||
}
|
||||
|
||||
const { showDialog } = useUI()
|
||||
/** 领取红包 */
|
||||
const onClaim = (item: IMessageModel) => {
|
||||
const { conversationType, flow, payload } = item
|
||||
const { conversationType, cloudCustomData, flow, payload } = item
|
||||
const data = JSON.parse(payload.data)
|
||||
// 群聊
|
||||
if (conversationType === TYPES.value.CONV_GROUP) {
|
||||
@@ -617,7 +623,43 @@
|
||||
})
|
||||
} else {
|
||||
// 个人红包
|
||||
// 只能对方领取
|
||||
getRedEnvelopeDetail(data.id).then(async (res: any) => {
|
||||
console.log(res)
|
||||
let newMessage = {
|
||||
// ...data,
|
||||
in: false,
|
||||
out: false
|
||||
}
|
||||
if (cloudCustomData) {
|
||||
newMessage = JSON.parse(cloudCustomData)
|
||||
}
|
||||
// 只能对方领取
|
||||
if (flow === 'in') {
|
||||
if (res.data.hasReceived) {
|
||||
// 直接去详情页
|
||||
} else {
|
||||
const show = await showDialog('提示', '是否领取该红包?')
|
||||
if (show) {
|
||||
newMessage.in = true
|
||||
|
||||
item.modifyMessage({
|
||||
cloudCustomData: JSON.stringify(newMessage)
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newMessage.out = true
|
||||
item.modifyMessage({
|
||||
cloudCustomData: JSON.stringify(newMessage)
|
||||
})
|
||||
navigateTo('/pages/red-packet/details', {
|
||||
id: data.id,
|
||||
type: conversationType
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return
|
||||
if (flow === 'in') {
|
||||
// 修改后的消息
|
||||
const newMessage = {
|
||||
|
||||
@@ -86,6 +86,13 @@
|
||||
</text>
|
||||
</view>
|
||||
<text class="bottom-text">积分红包{{ customData.isOpen }}</text>
|
||||
<!-- 需要处理报错 -->
|
||||
<!-- <text>
|
||||
{{
|
||||
props.messageItem?.cloudCustomData &&
|
||||
JSON.parse(props.messageItem?.cloudCustomData)
|
||||
}}
|
||||
</text> -->
|
||||
</view>
|
||||
</template>
|
||||
<template v-else>
|
||||
@@ -95,7 +102,13 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watchEffect, ref } from '../../../../adapter-vue'
|
||||
import {
|
||||
watchEffect,
|
||||
ref,
|
||||
watch,
|
||||
computed,
|
||||
reactive
|
||||
} from '../../../../adapter-vue'
|
||||
import {
|
||||
TUITranslateService,
|
||||
IMessageModel
|
||||
@@ -123,7 +136,7 @@
|
||||
content: undefined
|
||||
})
|
||||
|
||||
console.log(props.messageItem, '获取到红包信息后更新UI')
|
||||
// console.log(props.messageItem, '获取到红包信息后更新UI')
|
||||
|
||||
const custom = ref()
|
||||
const message = ref<IMessageModel>()
|
||||
@@ -142,6 +155,7 @@
|
||||
extension.value = JSONToObject(payload.extension)
|
||||
}
|
||||
})
|
||||
|
||||
const openLink = (url: any) => {
|
||||
window.open(url)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user