diff --git a/TUIKit/assets/icon/red-packet.svg b/TUIKit/assets/icon/red-packet.svg new file mode 100644 index 0000000..769f4df --- /dev/null +++ b/TUIKit/assets/icon/red-packet.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/TUIKit/components/TUIChat/chat-header/index.vue b/TUIKit/components/TUIChat/chat-header/index.vue index f47d907..0d305e2 100644 --- a/TUIKit/components/TUIChat/chat-header/index.vue +++ b/TUIKit/components/TUIChat/chat-header/index.vue @@ -3,17 +3,12 @@ @@ -21,78 +16,78 @@ - + diff --git a/TUIKit/components/TUIChat/message-input-toolbar/index.vue b/TUIKit/components/TUIChat/message-input-toolbar/index.vue index c1f8b7b..81dfdb3 100644 --- a/TUIKit/components/TUIChat/message-input-toolbar/index.vue +++ b/TUIKit/components/TUIChat/message-input-toolbar/index.vue @@ -3,7 +3,7 @@ :class="[ 'message-input-toolbar', 'message-input-toolbar-h5', - 'message-input-toolbar-uni', + 'message-input-toolbar-uni' ]" >
@@ -20,18 +20,17 @@ :class="[ 'message-input-toolbar-list', 'message-input-toolbar-h5-list', - 'message-input-toolbar-uni-list', + 'message-input-toolbar-uni-list' ]" > - - + +
diff --git a/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue b/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue new file mode 100644 index 0000000..6f67f61 --- /dev/null +++ b/TUIKit/components/TUIChat/message-input-toolbar/red-envelope/index.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/TUIKit/components/TUIContact/utils/index.ts b/TUIKit/components/TUIContact/utils/index.ts index 45e7432..1cc7b6f 100644 --- a/TUIKit/components/TUIContact/utils/index.ts +++ b/TUIKit/components/TUIContact/utils/index.ts @@ -5,172 +5,175 @@ import TUIChatEngine, { TUIUserService, TUITranslateService, AddFriendParams, - JoinGroupParams, -} from '@tencentcloud/chat-uikit-engine-lite'; -import { TUIGlobal } from '@tencentcloud/universal-api'; -import { Toast, TOAST_TYPE } from '../../common/Toast/index'; + JoinGroupParams +} from '@tencentcloud/chat-uikit-engine-lite' +import { TUIGlobal } from '@tencentcloud/universal-api' +import { Toast, TOAST_TYPE } from '../../common/Toast/index' +import { deleteImGroup, quitImGroup } from '../../../../api/tui-kit' +import { switchTab } from '../../../../utils/router' export const generateAvatar = (item: any): string => { return ( - item?.avatar - || item?.profile?.avatar - || (item?.groupID && 'https://web.sdk.qcloud.com/im/assets/images/Public.svg') - || 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png' - ); -}; + item?.avatar || + item?.profile?.avatar || + (item?.groupID && + 'https://web.sdk.qcloud.com/im/assets/images/Public.svg') || + 'https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png' + ) +} export const generateName = (item: any): string => { return ( - item?.remark - || item?.name - || item?.profile?.nick - || item?.nick - || item?.groupID - || item?.userID - || '' - ); -}; + item?.remark || + item?.name || + item?.profile?.nick || + item?.nick || + item?.groupID || + item?.userID || + '' + ) +} export const generateContactInfoName = (item: any): string => { return ( - item?.name - || item?.profile?.nick - || item?.nick - || item?.groupID - || item?.userID - || '' - ); -}; + item?.name || + item?.profile?.nick || + item?.nick || + item?.groupID || + item?.userID || + '' + ) +} // Parse the basic information display content of the contactInfo module // Group information display: group ID group type // User information display: user ID personal signature -export const generateContactInfoBasic = ( - contactInfo: any, -): any[] => { +export const generateContactInfoBasic = (contactInfo: any): any[] => { const res = [ { label: contactInfo?.groupID ? '群ID' : 'ID', - data: contactInfo?.groupID || contactInfo?.userID || '', - }, - ]; + data: contactInfo?.groupID || contactInfo?.userID || '' + } + ] if (!isApplicationType(contactInfo)) { res.push({ label: contactInfo?.groupID ? '群类型' : '个性签名', - data: contactInfo?.type || contactInfo?.profile?.selfSignature || '', - }); + data: contactInfo?.type || contactInfo?.profile?.selfSignature || '' + }) } - return res; -}; + return res +} export const isApplicationType = (info: any) => { return ( - info?.type === TUIChatEngine?.TYPES?.SNS_APPLICATION_SENT_TO_ME - || info?.type === TUIChatEngine?.TYPES?.SNS_APPLICATION_SENT_BY_ME - ); -}; + info?.type === TUIChatEngine?.TYPES?.SNS_APPLICATION_SENT_TO_ME || + info?.type === TUIChatEngine?.TYPES?.SNS_APPLICATION_SENT_BY_ME + ) +} export const isFriend = (info: any): Promise => { return new Promise((resolve, reject) => { if (info?.groupID || !info?.userID) { - resolve(false); - return; + resolve(false) + return } if (info?.addTime) { - resolve(true); - return; + resolve(true) + return } TUIFriendService.checkFriend({ userIDList: [info?.userID], - type: TUIChatEngine.TYPES.SNS_CHECK_TYPE_BOTH, + type: TUIChatEngine.TYPES.SNS_CHECK_TYPE_BOTH }) .then((res: any) => { switch (res?.data?.successUserIDList[0]?.relation) { // No friend relationship: A does not have B in his friend list, and B does not have A in his friend list case TUIChatEngine.TYPES.SNS_TYPE_NO_RELATION: - resolve(false); - break; + resolve(false) + break // Single-item friend: A has B in his friend list, but B does not have A in his friend list case TUIChatEngine.TYPES.SNS_TYPE_A_WITH_B: - resolve(false); - break; + resolve(false) + break // Single-item friend: A does not have B in his friend list, but B has A in his friend list case TUIChatEngine.TYPES.SNS_TYPE_B_WITH_A: - resolve(false); - break; + resolve(false) + break // Two-way friendship case TUIChatEngine.TYPES.SNS_TYPE_BOTH_WAY: - resolve(true); - break; + resolve(true) + break default: - resolve(false); - break; + resolve(false) + break } }) .catch((error: any) => { - console.warn('checkFriend error', error); - reject(error); - }); - }); -}; + console.warn('checkFriend error', error) + reject(error) + }) + }) +} // Change friend‘s remark export const updateFriendRemark = (userID: string, remark: string) => { // eslint-disable-next-line no-control-regex if (remark?.replace(/[^\u0000-\u00ff]/g, 'aa')?.length > 96) { Toast({ - message: TUITranslateService.t('TUIContact.修改备注失败: 备注长度不得超过 96 字节'), - type: TOAST_TYPE.ERROR, - }); - return; + message: TUITranslateService.t( + 'TUIContact.修改备注失败: 备注长度不得超过 96 字节' + ), + type: TOAST_TYPE.ERROR + }) + return } TUIFriendService.updateFriend({ userID, - remark, + remark }) .then(() => { Toast({ message: TUITranslateService.t('TUIContact.修改备注成功'), - type: TOAST_TYPE.SUCCESS, - }); + type: TOAST_TYPE.SUCCESS + }) }) .catch((error: any) => { - console.warn('update friend remark failed:', error); + console.warn('update friend remark failed:', error) Toast({ message: TUITranslateService.t('TUIContact.修改备注失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Delete one friend export const deleteFriend = (userID: string) => { TUIFriendService.deleteFriend({ userIDList: [userID], - type: TUIChatEngine.TYPES.SNS_DELETE_TYPE_BOTH, + type: TUIChatEngine.TYPES.SNS_DELETE_TYPE_BOTH }) .then((res: any) => { - const { successUserIDList } = res.data; + const { successUserIDList } = res.data if (successUserIDList[0].userID === userID) { Toast({ message: TUITranslateService.t('TUIContact.删除好友成功'), - type: TOAST_TYPE.SUCCESS, - }); + type: TOAST_TYPE.SUCCESS + }) } else { Toast({ message: TUITranslateService.t('TUIContact.删除好友失败'), - type: TOAST_TYPE.ERROR, - }); + type: TOAST_TYPE.ERROR + }) } }) .catch((error: any) => { - console.warn('delete friend failed:', error); + console.warn('delete friend failed:', error) Toast({ message: TUITranslateService.t('TUIContact.删除好友失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Add friend export const addFriend = (params: AddFriendParams) => { @@ -178,54 +181,54 @@ export const addFriend = (params: AddFriendParams) => { .then(() => { Toast({ message: TUITranslateService.t('TUIContact.申请已发送'), - type: TOAST_TYPE.SUCCESS, - }); + type: TOAST_TYPE.SUCCESS + }) }) .catch((error: any) => { - console.warn('delete friend failed:', error); + console.warn('delete friend failed:', error) Toast({ message: TUITranslateService.t('TUIContact.申请发送失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Enter conversation export const enterConversation = (item: any) => { const conversationID = item?.groupID ? `GROUP${item?.groupID}` - : `C2C${item?.userID}`; + : `C2C${item?.userID}` TUIConversationService.switchConversation(conversationID).catch( (error: any) => { - console.warn('switch conversation failed:', error); + console.warn('switch conversation failed:', error) Toast({ message: TUITranslateService.t('TUIContact.进入会话失败'), - type: TOAST_TYPE.ERROR, - }); - }, - ); -}; + type: TOAST_TYPE.ERROR + }) + } + ) +} // Accept friend application export const acceptFriendApplication = (userID: string) => { TUIFriendService.acceptFriendApplication({ userID, - type: TUIChatEngine.TYPES.SNS_APPLICATION_AGREE_AND_ADD, + type: TUIChatEngine.TYPES.SNS_APPLICATION_AGREE_AND_ADD }) .then(() => { Toast({ message: TUITranslateService.t('TUIContact.添加好友成功'), - type: TOAST_TYPE.SUCCESS, - }); + type: TOAST_TYPE.SUCCESS + }) }) .catch((error: any) => { - console.warn('accept friend application failed:', error); + console.warn('accept friend application failed:', error) Toast({ message: TUITranslateService.t('TUIContact.同意好友申请失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Refuse friend application export const refuseFriendApplication = (userID: string) => { @@ -233,127 +236,164 @@ export const refuseFriendApplication = (userID: string) => { .then(() => { Toast({ message: TUITranslateService.t('TUIContact.拒绝成功'), - type: TOAST_TYPE.SUCCESS, - }); + type: TOAST_TYPE.SUCCESS + }) }) .catch((error: any) => { - console.warn('accept friend application failed:', error); + console.warn('accept friend application failed:', error) Toast({ message: TUITranslateService.t('TUIContact.拒绝好友申请失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Dismiss group export const dismissGroup = (groupID: string) => { - TUIGroupService.dismissGroup(groupID) + deleteImGroup(groupID) .then(() => { Toast({ message: TUITranslateService.t('TUIContact.解散群聊成功'), - type: TOAST_TYPE.SUCCESS, - }); - TUIGlobal?.updateContactSearch && TUIGlobal?.updateContactSearch(); + type: TOAST_TYPE.SUCCESS + }) + TUIGlobal?.updateContactSearch && TUIGlobal?.updateContactSearch() + switchTab('/TUIKit/components/TUIConversation/index') }) .catch((error: any) => { - console.warn('dismiss group failed:', error); + console.warn('dismiss group failed:', error) Toast({ message: TUITranslateService.t('TUIContact.解散群聊失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) + // TUIGroupService.dismissGroup(groupID) + // .then(() => { + // Toast({ + // message: TUITranslateService.t('TUIContact.解散群聊成功'), + // type: TOAST_TYPE.SUCCESS, + // }); + // TUIGlobal?.updateContactSearch && TUIGlobal?.updateContactSearch(); + // }) + // .catch((error: any) => { + // console.warn('dismiss group failed:', error); + // Toast({ + // message: TUITranslateService.t('TUIContact.解散群聊失败'), + // type: TOAST_TYPE.ERROR, + // }); + // }); +} // Quit group export const quitGroup = (groupID: string) => { - TUIGroupService.quitGroup(groupID) + console.log('222') + quitImGroup(groupID) .then(() => { Toast({ message: TUITranslateService.t('TUIContact.退出群组成功'), - type: TOAST_TYPE.SUCCESS, - }); + type: TOAST_TYPE.SUCCESS + }) + + switchTab('/TUIKit/components/TUIConversation/index') }) .catch((error: any) => { - console.warn('quit group failed:', error); + console.warn('quit group failed:', error) Toast({ message: TUITranslateService.t('TUIContact.退出群组失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) + + // TUIGroupService.quitGroup(groupID) + // .then(() => { + // Toast({ + // message: TUITranslateService.t('TUIContact.退出群组成功'), + // type: TOAST_TYPE.SUCCESS, + // }); + // }) + // .catch((error: any) => { + // console.warn('quit group failed:', error); + // Toast({ + // message: TUITranslateService.t('TUIContact.退出群组失败'), + // type: TOAST_TYPE.ERROR, + // }); + // }); +} // Join group export const joinGroup = (groupID: string, applyMessage?: string) => { TUIGroupService.joinGroup({ groupID, - applyMessage, + applyMessage } as JoinGroupParams) .then((imResponse: { data: { status?: string } }) => { switch (imResponse?.data?.status) { case TUIChatEngine.TYPES.JOIN_STATUS_WAIT_APPROVAL: // Wait for administrator approval Toast({ message: TUITranslateService.t('TUIContact.等待管理员同意'), - type: TOAST_TYPE.SUCCESS, - }); - break; + type: TOAST_TYPE.SUCCESS + }) + break case TUIChatEngine.TYPES.JOIN_STATUS_SUCCESS: // Join group successfully Toast({ message: TUITranslateService.t('TUIContact.加群成功'), - type: TOAST_TYPE.SUCCESS, - }); - break; + type: TOAST_TYPE.SUCCESS + }) + break case TUIChatEngine.TYPES.JOIN_STATUS_ALREADY_IN_GROUP: // Already in the group Toast({ message: TUITranslateService.t('TUIContact.您已是群成员'), - type: TOAST_TYPE.SUCCESS, - }); - break; + type: TOAST_TYPE.SUCCESS + }) + break default: - break; + break } }) .catch((error: any) => { - console.warn('join group failed:', error); + console.warn('join group failed:', error) Toast({ message: '申请入群失败', - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Add to blacklist -export const addToBlacklist = (userID: string, successCallBack?: () => void) => { +export const addToBlacklist = ( + userID: string, + successCallBack?: () => void +) => { TUIUserService.addToBlacklist({ - userIDList: [userID], + userIDList: [userID] }) .then(() => { - successCallBack && successCallBack(); + successCallBack && successCallBack() }) .catch((error: any) => { - console.warn('add to blacklist failed:', error); + console.warn('add to blacklist failed:', error) Toast({ message: TUITranslateService.t('TUIContact.加入黑名单失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} // Remove from Blacklist export const removeFromBlacklist = ( userID: string, - successCallBack?: () => void, + successCallBack?: () => void ) => { TUIUserService.removeFromBlacklist({ - userIDList: [userID], + userIDList: [userID] }) .then(() => { - successCallBack && successCallBack(); + successCallBack && successCallBack() }) .catch((error: any) => { - console.warn('remove from blacklist failed:', error); + console.warn('remove from blacklist failed:', error) Toast({ message: TUITranslateService.t('TUIContact.移除黑名单失败'), - type: TOAST_TYPE.ERROR, - }); - }); -}; + type: TOAST_TYPE.ERROR + }) + }) +} diff --git a/TUIKit/components/TUIGroup/create-group/index.vue b/TUIKit/components/TUIGroup/create-group/index.vue index ed88992..4b1c508 100644 --- a/TUIKit/components/TUIGroup/create-group/index.vue +++ b/TUIKit/components/TUIGroup/create-group/index.vue @@ -6,7 +6,7 @@ - +
  • { - const data = groupJoinTypeConfig.find( - v => v.value === applyJoinOption.value - ) - return data?.label || '' - }) - // ======= const groupInfo = reactive({ 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, diff --git a/TUIKit/components/TUIGroup/manage-group/index.vue b/TUIKit/components/TUIGroup/manage-group/index.vue index de0b844..a26786c 100644 --- a/TUIKit/components/TUIGroup/manage-group/index.vue +++ b/TUIKit/components/TUIGroup/manage-group/index.vue @@ -1,8 +1,5 @@ diff --git a/TUIKit/components/TUIGroup/manage-group/manage-name.vue b/TUIKit/components/TUIGroup/manage-group/manage-name.vue index a93b844..af1560d 100644 --- a/TUIKit/components/TUIGroup/manage-group/manage-name.vue +++ b/TUIKit/components/TUIGroup/manage-group/manage-name.vue @@ -3,8 +3,10 @@
    @@ -16,28 +18,26 @@
    -
    +
    - {{ - TUITranslateService.t(`关闭`) - }} + + {{ TUITranslateService.t(`关闭`) }} +
    - {{ - TUITranslateService.t( - `TUIGroup.仅限中文、字母、数字和下划线,2-20个字` - ) - }} + /> + + {{ + TUITranslateService.t( + `TUIGroup.仅限中文、字母、数字和下划线,2-20个字` + ) + }} +
    -
    -
    @@ -73,226 +66,226 @@ diff --git a/api/tui-kit.js b/api/tui-kit.js index 88140ba..7695327 100644 --- a/api/tui-kit.js +++ b/api/tui-kit.js @@ -1,10 +1,42 @@ import http from '@/utils/request' -/** 创建群组 */ -export const createImGroup = data => { +/** + * 创建/修改群组 + * @param {*} data + * @param {*} method post 创建 put 修改 + * @returns + */ +export const createImGroup = (data, method = 'post') => { return http({ url: '/api/service/imGroup', - method: 'post', + method, data }) } + +/** 删除群 */ +export const deleteImGroup = groupId => { + return http({ + url: `/api/service/imGroup/remove`, + method: 'post', + data: { groupId } + }) +} + +/** 群成员退出群 */ +export const quitImGroup = groupId => { + return http({ + url: `/api/service/imGroupMember/leave`, + method: 'post', + data: { groupId } + }) +} + +/** 删除群组成员 */ +export const deleteImGroupMember = (groupId, memberId) => { + return http({ + url: `/api/service/imGroup/removeMember`, + method: 'post', + data: { groupId, memberId } + }) +} diff --git a/pages/my-index/my-index.vue b/pages/my-index/my-index.vue index bec1fe5..9ca7d24 100644 --- a/pages/my-index/my-index.vue +++ b/pages/my-index/my-index.vue @@ -11,6 +11,7 @@ url: '/pages/my-index/wallet/index' }, { name: '我的团队', icon: 'team', url: '/pages/my-index/my-team' }, + { name: '群创建直播', icon: 'videocam', url: '' }, { name: '会议记录', icon: 'meeting', @@ -100,12 +101,19 @@ @click="item.url && navigateTo(item.url)" > + - {{ item.name }} + {{ item.name }} { * 登录腾讯 IM */ const loginTencentIM = async () => { - console.log(11111111111111111111111) await TUILogin.login({ SDKAppID: tencentUserSig.value.sdkappID, userID: tencentUserSig.value.userId, diff --git a/utils/media.js b/utils/media.js index 60ed82d..f44382c 100644 --- a/utils/media.js +++ b/utils/media.js @@ -3,7 +3,7 @@ * @param {Object} options - 透传给 uni.chooseImage 的配置 * @returns {Promise>} 返回选中的临时图片路径数组 */ -export function chooseImage(options = {}) { +export const chooseImage = (options = {}) => { // 默认配置 const defaultOptions = { count: 1,