From 33a4100ed4c851fda542213d0aa6f66be309f4cc Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 10 Nov 2024 13:09:27 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E3=80=91=E5=95=86=E5=9F=8E:=20=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E6=8E=92=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/mall/kefu.ts | 48 +++++----------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/src/store/modules/mall/kefu.ts b/src/store/modules/mall/kefu.ts index 16f1dfc2..2aecee0d 100644 --- a/src/store/modules/mall/kefu.ts +++ b/src/store/modules/mall/kefu.ts @@ -63,48 +63,14 @@ export const useMallKefuStore = defineStore('mall-kefu', { } }, conversationSort() { - // TODO @puhui999:1)逻辑上,先按照置顶、再按照最后消息时间;2)感觉写的有一丢丢小复杂,发给大模型,看看有没可能简化哈。 - this.conversationList.sort((obj1, obj2) => { - // 如果 obj1.adminPinned 为 true,obj2.adminPinned 为 false,obj1 应该排在前面 - if (obj1.adminPinned && !obj2.adminPinned) { - return -1 + // 按置顶属性和最后消息时间排序 + this.conversationList.sort((a, b) => { + // 按照置顶排序,置顶的会在前面 + if (a.adminPinned !== b.adminPinned) { + return a.adminPinned ? -1 : 1 } - // 如果 obj1.adminPinned 为 false,obj2.adminPinned 为 true,obj2 应该排在前面 - if (!obj1.adminPinned && obj2.adminPinned) { - return 1 - } - - // 如果 obj1.adminPinned 和 obj2.adminPinned 都为 true,比较 adminUnreadMessageCount 的值 - if (obj1.adminPinned && obj2.adminPinned) { - return obj1.adminUnreadMessageCount - obj2.adminUnreadMessageCount - } - - // 如果 obj1.adminPinned 和 obj2.adminPinned 都为 false,比较 adminUnreadMessageCount 的值 - if (!obj1.adminPinned && !obj2.adminPinned) { - return obj1.adminUnreadMessageCount - obj2.adminUnreadMessageCount - } - - // 如果 obj1.adminPinned 为 true,obj2.adminPinned 为 true,且 b 都大于 0,比较 adminUnreadMessageCount 的值 - if ( - obj1.adminPinned && - obj2.adminPinned && - obj1.adminUnreadMessageCount > 0 && - obj2.adminUnreadMessageCount > 0 - ) { - return obj1.adminUnreadMessageCount - obj2.adminUnreadMessageCount - } - - // 如果 obj1.adminPinned 为 false,obj2.adminPinned 为 false,且 b 都大于 0,比较 adminUnreadMessageCount 的值 - if ( - !obj1.adminPinned && - !obj2.adminPinned && - obj1.adminUnreadMessageCount > 0 && - obj2.adminUnreadMessageCount > 0 - ) { - return obj1.adminUnreadMessageCount - obj2.adminUnreadMessageCount - } - - return 0 + // 按照最后消息时间排序,最近的会在前面 + return (b.lastMessageTime as unknown as number) - (a.lastMessageTime as unknown as number) }) } } From fdee8d8628ad48bdb2df36e0696a484c71f22329 Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 10 Nov 2024 14:15:15 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E3=80=91=E5=95=86=E5=9F=8E:=20=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E4=BC=9A=E5=91=98=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kefu/components/member/MemberInfo.vue | 54 +++++++++++ .../member/user/detail/UserAccountInfo.vue | 6 +- .../member/user/detail/UserBasicInfo.vue | 95 +++++++++++++++---- 3 files changed, 136 insertions(+), 19 deletions(-) diff --git a/src/views/mall/promotion/kefu/components/member/MemberInfo.vue b/src/views/mall/promotion/kefu/components/member/MemberInfo.vue index 952d34c8..15192808 100644 --- a/src/views/mall/promotion/kefu/components/member/MemberInfo.vue +++ b/src/views/mall/promotion/kefu/components/member/MemberInfo.vue @@ -25,6 +25,21 @@ +
+ + + + + + + + + +
@@ -45,11 +60,17 @@ import { KeFuConversationRespVO } from '@/api/mall/promotion/kefu/conversation' import { isEmpty } from '@/utils/is' import { debounce } from 'lodash-es' import { ElScrollbar as ElScrollbarType } from 'element-plus/es/components/scrollbar/index' +import { CardTitle } from '@/components/Card' +import UserBasicInfo from '@/views/member/user/detail/UserBasicInfo.vue' +import UserAccountInfo from '@/views/member/user/detail/UserAccountInfo.vue' +import * as UserApi from '@/api/member/user' +import * as WalletApi from '@/api/pay/wallet/balance' defineOptions({ name: 'MemberBrowsingHistory' }) const activeTab = ref('会员信息') const tabActivation = computed(() => (tab: string) => activeTab.value === tab) + /** tab 切换 */ const productBrowsingHistoryRef = ref>() const orderBrowsingHistoryRef = ref>() @@ -63,6 +84,8 @@ const handleClick = async (tab: string) => { const getHistoryList = async () => { switch (activeTab.value) { case '会员信息': + await getUserData() + await getUserWallet() break case '最近浏览': await productBrowsingHistoryRef.value?.getHistoryList(conversation.value) @@ -110,6 +133,37 @@ const handleScroll = debounce(() => { loadMore() } }, 200) + +/* 用户钱包相关信息 */ +const WALLET_INIT_DATA = { + balance: 0, + totalExpense: 0, + totalRecharge: 0 +} as WalletApi.WalletVO // 钱包初始化数据 +const wallet = ref(WALLET_INIT_DATA) // 钱包信息 + +/** 查询用户钱包信息 */ +const getUserWallet = async () => { + if (!conversation.value.userId) { + wallet.value = WALLET_INIT_DATA + return + } + const params = { userId: conversation.value.userId } + wallet.value = (await WalletApi.getWallet(params)) || WALLET_INIT_DATA +} + +const loading = ref(true) // 加载中 +const user = ref({} as UserApi.UserVO) + +/** 获得用户 */ +const getUserData = async () => { + loading.value = true + try { + user.value = await UserApi.getUser(conversation.value.userId) + } finally { + loading.value = false + } +} From b9e1529623b35cbf659a7b28c70ad548b1f93a2f Mon Sep 17 00:00:00 2001 From: puhui999 Date: Sun, 10 Nov 2024 16:36:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E3=80=90=E5=8A=9F=E8=83=BD=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E3=80=91=E5=95=86=E5=9F=8E:=20=E5=AE=A2=E6=9C=8D?= =?UTF-8?q?=E6=B6=88=E6=81=AFJSON=20=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kefu/components/KeFuConversationList.vue | 7 ++++--- .../kefu/components/KeFuMessageList.vue | 11 ++++++----- .../kefu/components/message/OrderItem.vue | 17 ++++++++++------- src/views/mall/promotion/kefu/index.vue | 3 +-- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/views/mall/promotion/kefu/components/KeFuConversationList.vue b/src/views/mall/promotion/kefu/components/KeFuConversationList.vue index 7afa711e..3f28f9c2 100644 --- a/src/views/mall/promotion/kefu/components/KeFuConversationList.vue +++ b/src/views/mall/promotion/kefu/components/KeFuConversationList.vue @@ -1,7 +1,7 @@