提现功能需要添加
This commit is contained in:
@@ -26,64 +26,84 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { deepCopy } from '../../../TUIChat/utils/utils';
|
||||
import ContactListItem from '../contact-list-item/index.vue';
|
||||
import { sortByFirstChar } from '../../utils/sortByFirstChar';
|
||||
import { onMounted, onUnmounted, ref } from '../../../../adapter-vue';
|
||||
import { Friend, StoreName, TUIStore } from '@tencentcloud/chat-uikit-engine-lite';
|
||||
import { FriendListData } from '../../../../interface';
|
||||
import { deepCopy } from '../../../TUIChat/utils/utils'
|
||||
import ContactListItem from '../contact-list-item/index.vue'
|
||||
import { sortByFirstChar } from '../../utils/sortByFirstChar'
|
||||
import { onMounted, onUnmounted, ref } from '../../../../adapter-vue'
|
||||
import {
|
||||
Friend,
|
||||
StoreName,
|
||||
TUIStore
|
||||
} from '@tencentcloud/chat-uikit-engine-lite'
|
||||
import { FriendListData } from '../../../../interface'
|
||||
|
||||
const emits = defineEmits(['enterConversation']);
|
||||
const emits = defineEmits(['enterConversation'])
|
||||
|
||||
const friendListData = ref<FriendListData>({
|
||||
key: 'friendList',
|
||||
title: '我的好友',
|
||||
map: {},
|
||||
});
|
||||
const friendListData = ref<FriendListData>({
|
||||
key: 'friendList',
|
||||
title: '我的好友',
|
||||
map: {}
|
||||
})
|
||||
|
||||
function onFriendListUpdated(friendList: Friend[]) {
|
||||
const { groupedList } = sortByFirstChar(
|
||||
friendList,
|
||||
(friend: Friend) => friend.remark || friend.profile?.nick || friend.userID || '');
|
||||
friendListData.value.map = groupedList;
|
||||
}
|
||||
function onFriendListUpdated(friendList: Friend[]) {
|
||||
const { groupedList } = sortByFirstChar(
|
||||
friendList,
|
||||
(friend: Friend) =>
|
||||
friend.remark || friend.profile?.nick || friend.userID || ''
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
TUIStore.watch(StoreName.FRIEND, {
|
||||
friendList: onFriendListUpdated,
|
||||
});
|
||||
});
|
||||
console.log(groupedList, '====222==')
|
||||
friendListData.value.map = {
|
||||
A: [
|
||||
{
|
||||
profile: {
|
||||
nick: '测试第三方',
|
||||
avatar:
|
||||
'https://jckj-1309258891.cos.ap-chengdu.myqcloud.com/common/19101767159307246_.png'
|
||||
}
|
||||
}
|
||||
],
|
||||
...groupedList
|
||||
}
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
TUIStore.unwatch(StoreName.FRIEND, {
|
||||
friendList: onFriendListUpdated,
|
||||
});
|
||||
});
|
||||
onMounted(() => {
|
||||
TUIStore.watch(StoreName.FRIEND, {
|
||||
friendList: onFriendListUpdated
|
||||
})
|
||||
})
|
||||
|
||||
const enterConversation = (item: any) => {
|
||||
emits('enterConversation', item);
|
||||
};
|
||||
onUnmounted(() => {
|
||||
TUIStore.unwatch(StoreName.FRIEND, {
|
||||
friendList: onFriendListUpdated
|
||||
})
|
||||
})
|
||||
|
||||
const enterConversation = (item: any) => {
|
||||
emits('enterConversation', item)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.friend-list {
|
||||
ul, li {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
.friend-list {
|
||||
ul,
|
||||
li {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.friend-group-title {
|
||||
padding: 8px 16px;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
line-height: 20px;
|
||||
}
|
||||
.friend-group-title {
|
||||
padding: 8px 16px;
|
||||
background-color: #f8f9fa;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #666;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.friend-item {
|
||||
margin: 0 15px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
.friend-item {
|
||||
margin: 0 15px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -28,7 +28,13 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="tui-contact-list-item-header-right">
|
||||
<div>{{ TUITranslateService.t(`TUIContact.${contactListObj.title}`) }}</div>
|
||||
<div>
|
||||
{{
|
||||
TUITranslateService.t(
|
||||
`TUIContact.${contactListObj.title}`
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
<Icon
|
||||
:file="currentContactListKey === key ? downSVG : rightSVG"
|
||||
size="20px"
|
||||
@@ -41,7 +47,8 @@
|
||||
</div>
|
||||
<template v-else>
|
||||
<li
|
||||
v-for="contactListItem in contactListMap[currentContactListKey].list"
|
||||
v-for="contactListItem in contactListMap[currentContactListKey]
|
||||
.list"
|
||||
:key="contactListItem.renderKey"
|
||||
class="tui-contact-list-item-main-item"
|
||||
:class="['selected']"
|
||||
@@ -55,19 +62,13 @@
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<ul
|
||||
v-else-if="contactSearchingStatus"
|
||||
class="tui-contact-list"
|
||||
>
|
||||
<ul v-else-if="contactSearchingStatus" class="tui-contact-list">
|
||||
<li
|
||||
v-for="(item, key) in contactSearchResult"
|
||||
:key="key"
|
||||
class="tui-contact-list-item"
|
||||
>
|
||||
<div
|
||||
v-if="item.list[0]"
|
||||
class="tui-contact-search-list"
|
||||
>
|
||||
<div v-if="item.list[0]" class="tui-contact-search-list">
|
||||
<div class="tui-contact-search-list-title">
|
||||
{{ TUITranslateService.t(`TUIContact.${item.label}`) }}
|
||||
</div>
|
||||
@@ -89,288 +90,369 @@
|
||||
v-if="isContactSearchNoResult"
|
||||
class="tui-contact-search-list-default"
|
||||
>
|
||||
{{ TUITranslateService.t("TUIContact.无搜索结果") }}
|
||||
{{ TUITranslateService.t('TUIContact.无搜索结果') }}
|
||||
</div>
|
||||
</ul>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
TUITranslateService,
|
||||
TUIStore,
|
||||
StoreName,
|
||||
TUIFriendService,
|
||||
TUIUserService,
|
||||
} from '@tencentcloud/chat-uikit-engine-lite';
|
||||
import TUICore, { TUIConstants } from '@tencentcloud/tui-core-lite';
|
||||
import { ref, computed, onMounted, onUnmounted, provide } from '../../../adapter-vue';
|
||||
import { isPC } from '../../../utils/env';
|
||||
import { deepCopy } from '../../TUIChat/utils/utils';
|
||||
import {
|
||||
TUITranslateService,
|
||||
TUIStore,
|
||||
StoreName,
|
||||
TUIFriendService,
|
||||
TUIUserService
|
||||
} from '@tencentcloud/chat-uikit-engine-lite'
|
||||
import TUICore, { TUIConstants } from '@tencentcloud/tui-core-lite'
|
||||
import {
|
||||
ref,
|
||||
computed,
|
||||
onMounted,
|
||||
onUnmounted,
|
||||
provide
|
||||
} from '../../../adapter-vue'
|
||||
import { isPC } from '../../../utils/env'
|
||||
import { deepCopy } from '../../TUIChat/utils/utils'
|
||||
|
||||
import Icon from '../../common/Icon.vue';
|
||||
import ContactListItem from './contact-list-item/index.vue';
|
||||
import FriendList from './components/FriendList.vue';
|
||||
import Icon from '../../common/Icon.vue'
|
||||
import ContactListItem from './contact-list-item/index.vue'
|
||||
import FriendList from './components/FriendList.vue'
|
||||
|
||||
import downSVG from '../../../assets/icon/down-icon.svg';
|
||||
import rightSVG from '../../../assets/icon/right-icon.svg';
|
||||
import newContactsSVG from '../../../assets/icon/new-contacts.svg';
|
||||
import groupSVG from '../../../assets/icon/groups.svg';
|
||||
import blackListSVG from '../../../assets/icon/black-list.svg';
|
||||
import downSVG from '../../../assets/icon/down-icon.svg'
|
||||
import rightSVG from '../../../assets/icon/right-icon.svg'
|
||||
import newContactsSVG from '../../../assets/icon/new-contacts.svg'
|
||||
import groupSVG from '../../../assets/icon/groups.svg'
|
||||
import blackListSVG from '../../../assets/icon/black-list.svg'
|
||||
|
||||
import type {
|
||||
IContactList,
|
||||
IContactSearchResult,
|
||||
IBlackListUserItem,
|
||||
IUserStatus,
|
||||
IUserStatusMap,
|
||||
IContactInfoType,
|
||||
} from '../../../interface';
|
||||
import type {
|
||||
IGroupModel,
|
||||
Friend,
|
||||
FriendApplication } from '@tencentcloud/chat-uikit-engine-lite';
|
||||
import type {
|
||||
IContactList,
|
||||
IContactSearchResult,
|
||||
IBlackListUserItem,
|
||||
IUserStatus,
|
||||
IUserStatusMap,
|
||||
IContactInfoType
|
||||
} from '../../../interface'
|
||||
import type {
|
||||
IGroupModel,
|
||||
Friend,
|
||||
FriendApplication
|
||||
} from '@tencentcloud/chat-uikit-engine-lite'
|
||||
|
||||
const currentContactListKey = ref<keyof IContactList>('');
|
||||
const currentContactInfo = ref<IContactInfoType>({} as IContactInfoType);
|
||||
const contactListMap = ref<IContactList>({
|
||||
friendApplicationList: {
|
||||
icon: newContactsSVG,
|
||||
key: 'friendApplicationList',
|
||||
title: '新的联系人',
|
||||
list: [] as FriendApplication[],
|
||||
unreadCount: 0,
|
||||
},
|
||||
groupList: {
|
||||
icon: groupSVG,
|
||||
key: 'groupList',
|
||||
title: '我的群聊',
|
||||
list: [] as IGroupModel[],
|
||||
},
|
||||
blackList: {
|
||||
icon: blackListSVG,
|
||||
key: 'blackList',
|
||||
title: '黑名单',
|
||||
list: [] as IBlackListUserItem[],
|
||||
},
|
||||
});
|
||||
const currentContactListKey = ref<keyof IContactList>('')
|
||||
const currentContactInfo = ref<IContactInfoType>({} as IContactInfoType)
|
||||
const contactListMap = ref<IContactList>({
|
||||
friendApplicationList: {
|
||||
icon: newContactsSVG,
|
||||
key: 'friendApplicationList',
|
||||
title: '新的联系人',
|
||||
list: [] as FriendApplication[],
|
||||
unreadCount: 0
|
||||
},
|
||||
groupList: {
|
||||
icon: groupSVG,
|
||||
key: 'groupList',
|
||||
title: '我的群聊',
|
||||
list: [] as IGroupModel[]
|
||||
},
|
||||
blackList: {
|
||||
icon: blackListSVG,
|
||||
key: 'blackList',
|
||||
title: '黑名单',
|
||||
list: [] as IBlackListUserItem[]
|
||||
}
|
||||
})
|
||||
|
||||
const contactSearchingStatus = ref<boolean>(false);
|
||||
const contactSearchResult = ref<IContactSearchResult>();
|
||||
const displayOnlineStatus = ref<boolean>(false);
|
||||
const userOnlineStatusMap = ref<IUserStatusMap>();
|
||||
const contactSearchingStatus = ref<boolean>(false)
|
||||
const contactSearchResult = ref<IContactSearchResult>()
|
||||
const displayOnlineStatus = ref<boolean>(false)
|
||||
const userOnlineStatusMap = ref<IUserStatusMap>()
|
||||
|
||||
const isContactSearchNoResult = computed((): boolean => (
|
||||
!contactSearchResult?.value?.user?.list[0]
|
||||
&& !contactSearchResult?.value?.group?.list[0]
|
||||
));
|
||||
const isContactSearchNoResult = computed(
|
||||
(): boolean =>
|
||||
!contactSearchResult?.value?.user?.list[0] &&
|
||||
!contactSearchResult?.value?.group?.list[0]
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
TUIStore.watch(StoreName.APP, {
|
||||
enabledCustomerServicePlugin: onCustomerServiceCommercialPluginUpdated,
|
||||
});
|
||||
onMounted(() => {
|
||||
TUIStore.watch(StoreName.APP, {
|
||||
enabledCustomerServicePlugin:
|
||||
onCustomerServiceCommercialPluginUpdated
|
||||
})
|
||||
|
||||
TUIStore.watch(StoreName.GRP, {
|
||||
groupList: onGroupListUpdated,
|
||||
});
|
||||
TUIStore.watch(StoreName.GRP, {
|
||||
groupList: onGroupListUpdated
|
||||
})
|
||||
|
||||
TUIStore.watch(StoreName.USER, {
|
||||
userBlacklist: onUserBlacklistUpdated,
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated,
|
||||
});
|
||||
TUIStore.watch(StoreName.USER, {
|
||||
userBlacklist: onUserBlacklistUpdated,
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated
|
||||
})
|
||||
|
||||
TUIStore.watch(StoreName.FRIEND, {
|
||||
friendApplicationList: onFriendApplicationListUpdated,
|
||||
friendApplicationUnreadCount: onFriendApplicationUnreadCountUpdated,
|
||||
});
|
||||
TUIStore.watch(StoreName.FRIEND, {
|
||||
friendApplicationList: onFriendApplicationListUpdated,
|
||||
friendApplicationUnreadCount: onFriendApplicationUnreadCountUpdated
|
||||
})
|
||||
|
||||
TUIStore.watch(StoreName.CUSTOM, {
|
||||
currentContactSearchingStatus: onCurrentContactSearchingStatusUpdated,
|
||||
currentContactSearchResult: onCurrentContactSearchResultUpdated,
|
||||
currentContactListKey: onCurrentContactListKeyUpdated,
|
||||
currentContactInfo: onCurrentContactInfoUpdated,
|
||||
});
|
||||
});
|
||||
TUIStore.watch(StoreName.CUSTOM, {
|
||||
currentContactSearchingStatus:
|
||||
onCurrentContactSearchingStatusUpdated,
|
||||
currentContactSearchResult: onCurrentContactSearchResultUpdated,
|
||||
currentContactListKey: onCurrentContactListKeyUpdated,
|
||||
currentContactInfo: onCurrentContactInfoUpdated
|
||||
})
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
TUIStore.unwatch(StoreName.APP, {
|
||||
enabledCustomerServicePlugin: onCustomerServiceCommercialPluginUpdated,
|
||||
});
|
||||
onUnmounted(() => {
|
||||
TUIStore.unwatch(StoreName.APP, {
|
||||
enabledCustomerServicePlugin:
|
||||
onCustomerServiceCommercialPluginUpdated
|
||||
})
|
||||
|
||||
TUIStore.unwatch(StoreName.GRP, {
|
||||
groupList: onGroupListUpdated,
|
||||
});
|
||||
TUIStore.unwatch(StoreName.GRP, {
|
||||
groupList: onGroupListUpdated
|
||||
})
|
||||
|
||||
TUIStore.unwatch(StoreName.USER, {
|
||||
userBlacklist: onUserBlacklistUpdated,
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated,
|
||||
});
|
||||
TUIStore.unwatch(StoreName.USER, {
|
||||
userBlacklist: onUserBlacklistUpdated,
|
||||
displayOnlineStatus: onDisplayOnlineStatusUpdated,
|
||||
userStatusList: onUserStatusListUpdated
|
||||
})
|
||||
|
||||
TUIStore.unwatch(StoreName.FRIEND, {
|
||||
friendApplicationList: onFriendApplicationListUpdated,
|
||||
friendApplicationUnreadCount: onFriendApplicationUnreadCountUpdated,
|
||||
});
|
||||
TUIStore.unwatch(StoreName.FRIEND, {
|
||||
friendApplicationList: onFriendApplicationListUpdated,
|
||||
friendApplicationUnreadCount: onFriendApplicationUnreadCountUpdated
|
||||
})
|
||||
|
||||
TUIStore.unwatch(StoreName.CUSTOM, {
|
||||
currentContactSearchingStatus: onCurrentContactSearchingStatusUpdated,
|
||||
currentContactSearchResult: onCurrentContactSearchResultUpdated,
|
||||
currentContactListKey: onCurrentContactListKeyUpdated,
|
||||
currentContactInfo: onCurrentContactInfoUpdated,
|
||||
});
|
||||
});
|
||||
TUIStore.unwatch(StoreName.CUSTOM, {
|
||||
currentContactSearchingStatus:
|
||||
onCurrentContactSearchingStatusUpdated,
|
||||
currentContactSearchResult: onCurrentContactSearchResultUpdated,
|
||||
currentContactListKey: onCurrentContactListKeyUpdated,
|
||||
currentContactInfo: onCurrentContactInfoUpdated
|
||||
})
|
||||
})
|
||||
|
||||
function toggleCurrentContactList(key: keyof IContactList) {
|
||||
if (currentContactListKey.value === key) {
|
||||
currentContactListKey.value = '';
|
||||
currentContactInfo.value = {} as IContactInfoType;
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', '');
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactInfo', {} as IContactInfoType);
|
||||
} else {
|
||||
currentContactListKey.value = key;
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', key);
|
||||
if (key === 'friendApplicationList') {
|
||||
TUIFriendService.setFriendApplicationRead();
|
||||
function toggleCurrentContactList(key: keyof IContactList) {
|
||||
if (currentContactListKey.value === key) {
|
||||
currentContactListKey.value = ''
|
||||
currentContactInfo.value = {} as IContactInfoType
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', '')
|
||||
TUIStore.update(
|
||||
StoreName.CUSTOM,
|
||||
'currentContactInfo',
|
||||
{} as IContactInfoType
|
||||
)
|
||||
} else {
|
||||
currentContactListKey.value = key
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', key)
|
||||
|
||||
console.log(111)
|
||||
if (key === 'friendApplicationList') {
|
||||
TUIFriendService.setFriendApplicationRead()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectItem(item: any) {
|
||||
currentContactInfo.value = item;
|
||||
// For a result in the search list, before viewing the contactInfo details,
|
||||
// it is necessary to update the data for the "already in the group list/already in the friend list" situation to obtain more detailed information
|
||||
if (contactSearchingStatus.value) {
|
||||
let targetListItem;
|
||||
if ((currentContactInfo.value as Friend)?.userID) {
|
||||
targetListItem = contactListMap.value?.friendList?.list?.find(
|
||||
(item: IContactInfoType) => (item as Friend)?.userID === (currentContactInfo.value as Friend)?.userID,
|
||||
);
|
||||
} else if ((currentContactInfo.value as IGroupModel)?.groupID) {
|
||||
targetListItem = contactListMap.value?.groupList?.list?.find(
|
||||
(item: IContactInfoType) => (item as IGroupModel)?.groupID === (currentContactInfo.value as IGroupModel)?.groupID,
|
||||
);
|
||||
function selectItem(item: any) {
|
||||
currentContactInfo.value = item
|
||||
// For a result in the search list, before viewing the contactInfo details,
|
||||
// it is necessary to update the data for the "already in the group list/already in the friend list" situation to obtain more detailed information
|
||||
if (contactSearchingStatus.value) {
|
||||
let targetListItem
|
||||
if ((currentContactInfo.value as Friend)?.userID) {
|
||||
targetListItem = contactListMap.value?.friendList?.list?.find(
|
||||
(item: IContactInfoType) =>
|
||||
(item as Friend)?.userID ===
|
||||
(currentContactInfo.value as Friend)?.userID
|
||||
)
|
||||
} else if ((currentContactInfo.value as IGroupModel)?.groupID) {
|
||||
targetListItem = contactListMap.value?.groupList?.list?.find(
|
||||
(item: IContactInfoType) =>
|
||||
(item as IGroupModel)?.groupID ===
|
||||
(currentContactInfo.value as IGroupModel)?.groupID
|
||||
)
|
||||
}
|
||||
if (targetListItem) {
|
||||
currentContactInfo.value = targetListItem
|
||||
}
|
||||
}
|
||||
if (targetListItem) {
|
||||
currentContactInfo.value = targetListItem;
|
||||
TUIStore.update(
|
||||
StoreName.CUSTOM,
|
||||
'currentContactInfo',
|
||||
currentContactInfo.value
|
||||
)
|
||||
}
|
||||
|
||||
const selectFriend = (item: any) => {
|
||||
TUIStore.update(
|
||||
StoreName.CUSTOM,
|
||||
'currentContactListKey',
|
||||
'friendList'
|
||||
)
|
||||
selectItem(item)
|
||||
}
|
||||
|
||||
function onDisplayOnlineStatusUpdated(status: boolean) {
|
||||
displayOnlineStatus.value = status
|
||||
}
|
||||
|
||||
function onUserStatusListUpdated(list: Map<string, IUserStatus>) {
|
||||
if (list?.size > 0) {
|
||||
userOnlineStatusMap.value = Object.fromEntries(list?.entries())
|
||||
}
|
||||
}
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactInfo', currentContactInfo.value);
|
||||
}
|
||||
|
||||
const selectFriend = (item: any) => {
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', 'friendList');
|
||||
selectItem(item);
|
||||
};
|
||||
function onCustomerServiceCommercialPluginUpdated(isEnabled: boolean) {
|
||||
if (!isEnabled) {
|
||||
return
|
||||
}
|
||||
|
||||
function onDisplayOnlineStatusUpdated(status: boolean) {
|
||||
displayOnlineStatus.value = status;
|
||||
}
|
||||
// After the customer purchases the customer service plug-in,
|
||||
// the engine updates the enabledCustomerServicePlugin to true through the commercial capability bit.
|
||||
const contactListExtensionID =
|
||||
TUIConstants.TUIContact.EXTENSION.CONTACT_LIST.EXT_ID
|
||||
const tuiContactExtensionList = TUICore.getExtensionList(
|
||||
contactListExtensionID
|
||||
)
|
||||
|
||||
function onUserStatusListUpdated(list: Map<string, IUserStatus>) {
|
||||
if (list?.size > 0) {
|
||||
userOnlineStatusMap.value = Object.fromEntries(list?.entries());
|
||||
}
|
||||
}
|
||||
const customerData = tuiContactExtensionList.find(
|
||||
(extension: any) => {
|
||||
const { name, accountList = [] } = extension.data || {}
|
||||
return name === 'customer' && accountList.length > 0
|
||||
}
|
||||
)
|
||||
|
||||
function onCustomerServiceCommercialPluginUpdated(isEnabled: boolean) {
|
||||
if (!isEnabled) {
|
||||
return;
|
||||
if (customerData) {
|
||||
const { data, text } = customerData
|
||||
const { accountList } = (data || {}) as { accountList: string[] }
|
||||
|
||||
TUIUserService.getUserProfile({ userIDList: accountList })
|
||||
.then(res => {
|
||||
if (res.data.length > 0) {
|
||||
const customerList = {
|
||||
title: text,
|
||||
list: res.data.map((item: any, index: number) => ({
|
||||
...item,
|
||||
renderKey: generateRenderKey('customerList', item, index),
|
||||
infoKeyList: [],
|
||||
btnKeyList: ['enterC2CConversation']
|
||||
})),
|
||||
key: 'customerList'
|
||||
}
|
||||
contactListMap.value = {
|
||||
...contactListMap.value,
|
||||
customerList
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
}
|
||||
|
||||
// After the customer purchases the customer service plug-in,
|
||||
// the engine updates the enabledCustomerServicePlugin to true through the commercial capability bit.
|
||||
const contactListExtensionID = TUIConstants.TUIContact.EXTENSION.CONTACT_LIST.EXT_ID;
|
||||
const tuiContactExtensionList = TUICore.getExtensionList(contactListExtensionID);
|
||||
|
||||
const customerData = tuiContactExtensionList.find((extension: any) => {
|
||||
const { name, accountList = [] } = extension.data || {};
|
||||
return name === 'customer' && accountList.length > 0;
|
||||
});
|
||||
|
||||
if (customerData) {
|
||||
const { data, text } = customerData;
|
||||
const { accountList } = (data || {}) as { accountList: string[] };
|
||||
|
||||
TUIUserService.getUserProfile({ userIDList: accountList })
|
||||
.then((res) => {
|
||||
if (res.data.length > 0) {
|
||||
const customerList = {
|
||||
title: text,
|
||||
list: res.data.map((item: any, index: number) => ({
|
||||
...item,
|
||||
renderKey: generateRenderKey('customerList', item, index),
|
||||
infoKeyList: [],
|
||||
btnKeyList: ['enterC2CConversation'],
|
||||
})),
|
||||
key: 'customerList',
|
||||
};
|
||||
contactListMap.value = { ...contactListMap.value, customerList };
|
||||
}
|
||||
})
|
||||
.catch(() => { });
|
||||
function onGroupListUpdated(groupList: IGroupModel[]) {
|
||||
updateContactListMap('groupList', groupList)
|
||||
}
|
||||
}
|
||||
|
||||
function onGroupListUpdated(groupList: IGroupModel[]) {
|
||||
updateContactListMap('groupList', groupList);
|
||||
}
|
||||
function onUserBlacklistUpdated(userBlacklist: IBlackListUserItem[]) {
|
||||
updateContactListMap('blackList', userBlacklist)
|
||||
}
|
||||
|
||||
function onUserBlacklistUpdated(userBlacklist: IBlackListUserItem[]) {
|
||||
updateContactListMap('blackList', userBlacklist);
|
||||
}
|
||||
|
||||
function onFriendApplicationUnreadCountUpdated(friendApplicationUnreadCount: number) {
|
||||
contactListMap.value.friendApplicationList.unreadCount = friendApplicationUnreadCount;
|
||||
}
|
||||
|
||||
function onFriendApplicationListUpdated(friendApplicationList: FriendApplication[]) {
|
||||
updateContactListMap('friendApplicationList', friendApplicationList);
|
||||
}
|
||||
|
||||
function updateContactListMap(key: keyof IContactList, list: IContactInfoType[]) {
|
||||
contactListMap.value[key].list = list;
|
||||
contactListMap.value[key].list.map((item: IContactInfoType, index: number) => item.renderKey = generateRenderKey(key, item, index));
|
||||
updateCurrentContactInfoFromList(contactListMap.value[key].list, key);
|
||||
}
|
||||
|
||||
function updateCurrentContactInfoFromList(list: IContactInfoType[], type: keyof IContactList) {
|
||||
if (
|
||||
!(currentContactInfo.value as Friend)?.userID
|
||||
&& !(currentContactInfo.value as IGroupModel)?.groupID
|
||||
function onFriendApplicationUnreadCountUpdated(
|
||||
friendApplicationUnreadCount: number
|
||||
) {
|
||||
return;
|
||||
contactListMap.value.friendApplicationList.unreadCount =
|
||||
friendApplicationUnreadCount
|
||||
}
|
||||
if (type === currentContactListKey.value || contactSearchingStatus.value) {
|
||||
currentContactInfo.value = list?.find(
|
||||
(item: any) =>
|
||||
(item?.groupID && item?.groupID === (currentContactInfo.value as IGroupModel)?.groupID) || (item?.userID && item?.userID === (currentContactInfo.value as Friend)?.userID),
|
||||
) || {} as IContactInfoType;
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactInfo', currentContactInfo.value);
|
||||
|
||||
function onFriendApplicationListUpdated(
|
||||
friendApplicationList: FriendApplication[]
|
||||
) {
|
||||
updateContactListMap('friendApplicationList', friendApplicationList)
|
||||
}
|
||||
}
|
||||
|
||||
function generateRenderKey(contactListMapKey: keyof IContactList, contactInfo: IContactInfoType, index: number) {
|
||||
return `${contactListMapKey}-${(contactInfo as Friend).userID || (contactInfo as IGroupModel).groupID || (`index${index}`)}`;
|
||||
}
|
||||
function updateContactListMap(
|
||||
key: keyof IContactList,
|
||||
list: IContactInfoType[]
|
||||
) {
|
||||
contactListMap.value[key].list = list
|
||||
contactListMap.value[key].list.map(
|
||||
(item: IContactInfoType, index: number) =>
|
||||
(item.renderKey = generateRenderKey(key, item, index))
|
||||
)
|
||||
updateCurrentContactInfoFromList(contactListMap.value[key].list, key)
|
||||
}
|
||||
|
||||
function onCurrentContactSearchResultUpdated(searchResult: IContactSearchResult) {
|
||||
contactSearchResult.value = searchResult;
|
||||
}
|
||||
function updateCurrentContactInfoFromList(
|
||||
list: IContactInfoType[],
|
||||
type: keyof IContactList
|
||||
) {
|
||||
if (
|
||||
!(currentContactInfo.value as Friend)?.userID &&
|
||||
!(currentContactInfo.value as IGroupModel)?.groupID
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (
|
||||
type === currentContactListKey.value ||
|
||||
contactSearchingStatus.value
|
||||
) {
|
||||
currentContactInfo.value =
|
||||
list?.find(
|
||||
(item: any) =>
|
||||
(item?.groupID &&
|
||||
item?.groupID ===
|
||||
(currentContactInfo.value as IGroupModel)?.groupID) ||
|
||||
(item?.userID &&
|
||||
item?.userID ===
|
||||
(currentContactInfo.value as Friend)?.userID)
|
||||
) || ({} as IContactInfoType)
|
||||
TUIStore.update(
|
||||
StoreName.CUSTOM,
|
||||
'currentContactInfo',
|
||||
currentContactInfo.value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function onCurrentContactSearchingStatusUpdated(searchingStatus: boolean) {
|
||||
contactSearchingStatus.value = searchingStatus;
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactInfo', {} as IContactInfoType);
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', '');
|
||||
}
|
||||
function generateRenderKey(
|
||||
contactListMapKey: keyof IContactList,
|
||||
contactInfo: IContactInfoType,
|
||||
index: number
|
||||
) {
|
||||
return `${contactListMapKey}-${
|
||||
(contactInfo as Friend).userID ||
|
||||
(contactInfo as IGroupModel).groupID ||
|
||||
`index${index}`
|
||||
}`
|
||||
}
|
||||
|
||||
function onCurrentContactInfoUpdated(contactInfo: IContactInfoType) {
|
||||
currentContactInfo.value = contactInfo;
|
||||
}
|
||||
function onCurrentContactSearchResultUpdated(
|
||||
searchResult: IContactSearchResult
|
||||
) {
|
||||
contactSearchResult.value = searchResult
|
||||
}
|
||||
|
||||
function onCurrentContactListKeyUpdated(contactListKey: string) {
|
||||
currentContactListKey.value = contactListKey;
|
||||
}
|
||||
function onCurrentContactSearchingStatusUpdated(
|
||||
searchingStatus: boolean
|
||||
) {
|
||||
contactSearchingStatus.value = searchingStatus
|
||||
TUIStore.update(
|
||||
StoreName.CUSTOM,
|
||||
'currentContactInfo',
|
||||
{} as IContactInfoType
|
||||
)
|
||||
TUIStore.update(StoreName.CUSTOM, 'currentContactListKey', '')
|
||||
}
|
||||
|
||||
provide('userOnlineStatusMap', userOnlineStatusMap);
|
||||
function onCurrentContactInfoUpdated(contactInfo: IContactInfoType) {
|
||||
currentContactInfo.value = contactInfo
|
||||
}
|
||||
|
||||
function onCurrentContactListKeyUpdated(contactListKey: string) {
|
||||
currentContactListKey.value = contactListKey
|
||||
}
|
||||
|
||||
provide('userOnlineStatusMap', userOnlineStatusMap)
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped src="./style/index.scss"></style>
|
||||
|
||||
Reference in New Issue
Block a user