zhengyiming
2025-02-10 0f686ea1fe4700a909a6159efcf1fcb0e1f88a17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<template>
  <ProTabs
    v-model="tab"
    name="tradeChatRecord-tabs"
    class="tradeChatRecord-tabs"
    flexTitle
    :showPaneContent="false"
  >
    <ProTabPane :title="`我联系的(${count.myCallCount})`" :pane-key="TradeChatRecordTab.Apply">
    </ProTabPane>
    <ProTabPane :title="`联系我的(${count.callMeCount})`" :pane-key="TradeChatRecordTab.My">
    </ProTabPane>
  </ProTabs>
  <InfiniteLoading
    scrollViewClassName="common-infinite-scroll-list-no-padding"
    v-bind="infiniteLoadingProps"
    :key="tab"
  >
    <template #renderItem="{ item }">
      <AttentionCard
        :key="tab === TradeChatRecordTab.Apply ? item.orderUserId : item.applyUserId"
        :avatarUrl="
          tab === TradeChatRecordTab.Apply ? item.orderUserAvatarUrl : item.applyUserAvatarUrl
        "
        :name="tab === TradeChatRecordTab.Apply ? item.orderUserContact : item.applyUserContact"
        :enterpriseName="
          tab === TradeChatRecordTab.Apply
            ? item.orderUserEnterpriseName
            : item.applyUserEnterpriseName
        "
      >
        <template #actions>
          <nut-button type="default" class="card-action" @click="goChatRoom(item)"
            >发私信</nut-button
          >
        </template>
      </AttentionCard>
    </template>
  </InfiniteLoading>
</template>
 
<script setup lang="ts">
import { ProTabs, ProTabPane } from '@12333/components';
import { useInfiniteLoading } from '@12333/hooks';
import { OrderInputType } from '@12333/constants';
import * as orderServices from '@12333/services/api/Order';
import { useUser } from '@/hooks';
import Taro from '@tarojs/taro';
 
defineOptions({
  name: 'InnerPage',
});
 
enum TradeChatRecordTab {
  Apply = '1',
  My = '2',
}
 
const tab = ref(TradeChatRecordTab.Apply);
 
const count = reactive({ callMeCount: 0, myCallCount: 0 });
 
const { userDetail } = useUser();
 
const { infiniteLoadingProps } = useInfiniteLoading(
  async ({ pageParam }) => {
    let params: API.QueryTradeChatRecordInput = {
      pageModel: {
        rows: 20,
        page: pageParam,
      },
    };
    if (tab.value === TradeChatRecordTab.Apply) {
      params.applyUserId = userDetail.value.userId;
    } else {
      params.orderUserId = userDetail.value.userId;
    }
    let res = await orderServices.getTradeChatRecordPage(params, { showLoading: false });
    count.callMeCount = res.objectData.callMeCount;
    count.myCallCount = res.objectData.myCallCount;
    return res;
  },
  {
    queryKey: ['orderServices/getTradeChatRecordPage', tab],
  }
);
 
function goChatRoom(item: API.TradeChatRecordOutput) {
  Taro.navigateTo({
    url: `${RouterPath.chatRoom}?chatId=${
      tab.value === TradeChatRecordTab.Apply ? item.orderUserId : item.applyUserId
    }`,
  });
}
</script>
 
<style lang="scss">
@import '@/styles/common.scss';
</style>