红包逻辑需要重构
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 = {
|
||||
|
||||
Reference in New Issue
Block a user