添加红包功能
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<label class="group-list-item-label">
|
||||
{{ TUITranslateService.t('TUIGroup.群头像') }}
|
||||
</label>
|
||||
<Avatar :url="groupInfo.profile.avatar" />
|
||||
<Avatar :url="groupAvatar" @click="selectAvatar" />
|
||||
</li>
|
||||
<ul>
|
||||
<li
|
||||
@@ -158,21 +158,12 @@
|
||||
import Server from '../server'
|
||||
import { IUserProfile } from '../../../interface'
|
||||
import { createImGroup } from '../../../../api/tui-kit'
|
||||
import { chooseImage } from '../../../../utils/media'
|
||||
import { uploadSingleFile } from '../../../../utils/uploadFile'
|
||||
|
||||
const TUIGroupServer = Server.getInstance()
|
||||
const TUIConstants = TUIGroupServer.constants
|
||||
|
||||
/** 自定义数据 */
|
||||
const cbPopupShow = ref(null)
|
||||
const applyJoinOption = ref('NeedPermission')
|
||||
|
||||
const applyJoinOptionName = computed(() => {
|
||||
const data = groupJoinTypeConfig.find(
|
||||
v => v.value === applyJoinOption.value
|
||||
)
|
||||
return data?.label || ''
|
||||
})
|
||||
// =======
|
||||
const groupInfo = reactive<any>({
|
||||
profile: {
|
||||
groupID: '',
|
||||
@@ -195,6 +186,19 @@
|
||||
isEdit: false
|
||||
})
|
||||
|
||||
/** 自定义数据 */
|
||||
const cbPopupShow = ref(null)
|
||||
const applyJoinOption = ref('NeedPermission')
|
||||
// 群头像
|
||||
const groupAvatar = ref(groupInfo.profile.avatar)
|
||||
const applyJoinOptionName = computed(() => {
|
||||
const data = groupJoinTypeConfig.find(
|
||||
v => v.value === applyJoinOption.value
|
||||
)
|
||||
return data?.label || ''
|
||||
})
|
||||
// =======
|
||||
|
||||
watchEffect(() => {
|
||||
const params = TUIGroupServer.getOnCallParams(
|
||||
TUIConstants.TUIGroup.SERVICE.METHOD.CREATE_GROUP
|
||||
@@ -247,35 +251,69 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 选择群头像 */
|
||||
const selectAvatar = async () => {
|
||||
const paths = await chooseImage({ count: 1 })
|
||||
groupAvatar.value = await uploadSingleFile(paths[0], {
|
||||
url: '/api/common/admin/upload/up/single'
|
||||
})
|
||||
}
|
||||
|
||||
const createGroup = async (options: any) => {
|
||||
console.log('确认创建==', options)
|
||||
// const data = {
|
||||
// currentMemberCount:
|
||||
// }
|
||||
// createImGroup()
|
||||
return
|
||||
try {
|
||||
options.memberList = options.memberList.map(
|
||||
(item: IUserProfile) => {
|
||||
return { userID: item.userID }
|
||||
}
|
||||
)
|
||||
if (options.type === TUIChatEngine.TYPES.GRP_COMMUNITY) {
|
||||
delete options.groupID
|
||||
}
|
||||
const res = await TUIGroupService.createGroup(options)
|
||||
const { type } = res.data.group
|
||||
if (type === TUIChatEngine.TYPES.GRP_AVCHATROOM) {
|
||||
await TUIGroupService.joinGroup({
|
||||
groupID: res.data.group.groupID,
|
||||
applyMessage: ''
|
||||
const data = {
|
||||
applyJoinOption: applyJoinOption.value,
|
||||
faceUrl: groupAvatar.value,
|
||||
groupName: options.name,
|
||||
groupType: options.type,
|
||||
memberList: options.memberList.map((item: IUserProfile) => {
|
||||
return { memberAccount: item.userID }
|
||||
})
|
||||
}
|
||||
handleCompleteCreate(res.data.group)
|
||||
|
||||
const res = await createImGroup(data)
|
||||
const e = res.data
|
||||
// const type = e.groupType
|
||||
// if (type === TUIChatEngine.TYPES.GRP_AVCHATROOM) {
|
||||
// await TUIGroupService.joinGroup({
|
||||
// groupID: e.groupID,
|
||||
// applyMessage: ''
|
||||
// })
|
||||
// }
|
||||
|
||||
const newRes = await TUIGroupService.getGroupProfile({
|
||||
groupID: e.groupId
|
||||
})
|
||||
|
||||
handleCompleteCreate(newRes.data.group)
|
||||
Toast({
|
||||
message: TUITranslateService.t('TUIGroup.群组创建成功'),
|
||||
type: TOAST_TYPE.SUCCESS
|
||||
})
|
||||
|
||||
// ========= 原本逻辑
|
||||
// options.memberList = options.memberList.map(
|
||||
// (item: IUserProfile) => {
|
||||
// return { userID: item.userID }
|
||||
// }
|
||||
// )
|
||||
// if (options.type === TUIChatEngine.TYPES.GRP_COMMUNITY) {
|
||||
// delete options.groupID
|
||||
// }
|
||||
// const res = await TUIGroupService.createGroup(options)
|
||||
// console.log(res)
|
||||
// const { type } = res.data.group
|
||||
// if (type === TUIChatEngine.TYPES.GRP_AVCHATROOM) {
|
||||
// await TUIGroupService.joinGroup({
|
||||
// groupID: res.data.group.groupID,
|
||||
// applyMessage: ''
|
||||
// })
|
||||
// }
|
||||
// handleCompleteCreate(res.data.group)
|
||||
// Toast({
|
||||
// message: TUITranslateService.t('TUIGroup.群组创建成功'),
|
||||
// type: TOAST_TYPE.SUCCESS
|
||||
// })
|
||||
} catch (err: any) {
|
||||
Toast({
|
||||
message: err.message,
|
||||
|
||||
Reference in New Issue
Block a user