|
@@ -1,22 +1,26 @@
|
|
|
<template>
|
|
|
<s-layout :bgStyle="{ color: '#f2f2f2' }" title="咨询记录">
|
|
|
- <view class="chat-list">
|
|
|
- <view v-for="item in chatList" :key="item.id" class="chat-item" @click="goToChat(item)">
|
|
|
- <view class="avatar">
|
|
|
- <image :src="item.userAvatar || activityright" mode="aspectFill"></image>
|
|
|
- </view>
|
|
|
- <view class="content">
|
|
|
- <view class="top">
|
|
|
- <text class="nickname">{{ item.userNickname }}</text>
|
|
|
- <text class="time">{{ formatTime(item.lastMessageTime) }}</text>
|
|
|
+ <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
|
|
|
+ @refresherrefresh="onRefresh">
|
|
|
+ <view class="chat-list">
|
|
|
+ <view v-for="item in chatList" :key="item.id" class="chat-item" @click="goToChat(item)">
|
|
|
+ <view class="avatar">
|
|
|
+ <image :src="item.userAvatar || activityright" mode="aspectFill"></image>
|
|
|
+ </view>
|
|
|
+ <view class="content">
|
|
|
+ <view class="top">
|
|
|
+ <text class="nickname">{{ item.userNickname }}</text>
|
|
|
+ <text class="time">{{ formatTime(item.lastMessageTime) }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="message">{{ parseMessage(item.lastMessageContent) }}</view>
|
|
|
+ </view>
|
|
|
+ <view v-if="item.relUserId == userInfo.id ? item.relUnreadMessageCount : item.adminUnreadMessageCount"
|
|
|
+ class="unread-count">
|
|
|
+ {{ item.relUserId == userInfo.id ? item.relUnreadMessageCount : item.adminUnreadMessageCount }}
|
|
|
</view>
|
|
|
- <view class="message">{{ parseMessage(item.lastMessageContent) }}</view>
|
|
|
- </view>
|
|
|
- <view v-if="item.adminUnreadMessageCount" class="unread-count">
|
|
|
- {{ item.adminUnreadMessageCount }}
|
|
|
</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </scroll-view>
|
|
|
</s-layout>
|
|
|
</template>
|
|
|
|
|
@@ -24,7 +28,7 @@
|
|
|
import sheep from '@/sheep';
|
|
|
import { reactive, ref, toRefs, computed } from 'vue';
|
|
|
import { useWebSocket } from '@/sheep/hooks/useWebSocket';
|
|
|
-import { onLoad } from '@dcloudio/uni-app';
|
|
|
+import { onLoad, onShow } from '@dcloudio/uni-app';
|
|
|
import SpuHistoryApi from '@/sheep/api/product/history';
|
|
|
import activityright from '@/static/activity-right.png'
|
|
|
import {
|
|
@@ -32,6 +36,7 @@ import {
|
|
|
WebSocketMessageTypeConstants,
|
|
|
} from '@/pages/chat/util/constants';
|
|
|
const chatList = ref([]);
|
|
|
+const triggered = ref(false);
|
|
|
|
|
|
const conversationListAxios = async () => {
|
|
|
const res = await SpuHistoryApi.conversationList();
|
|
@@ -40,6 +45,12 @@ const conversationListAxios = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const onRefresh = async () => {
|
|
|
+ triggered.value = true;
|
|
|
+ await conversationListAxios();
|
|
|
+ triggered.value = false;
|
|
|
+}
|
|
|
+
|
|
|
const formatTime = (timestamp) => {
|
|
|
const date = new Date(timestamp);
|
|
|
const now = new Date();
|
|
@@ -61,6 +72,9 @@ const userInfo = computed(() => sheep.$store('user').userInfo);
|
|
|
console.log(userInfo.value.id, 44444)
|
|
|
const goToChat = (item) => {
|
|
|
console.log(item, 44444)
|
|
|
+ SpuHistoryApi.updateKefuMessageReadStatus({
|
|
|
+ conversationId: item.id,
|
|
|
+ })
|
|
|
sheep.$router.go('/pages/chat/index', { conversationId: item.id, relUserId: userInfo.value.id === item.relUserId ? item.userId : item.relUserId })
|
|
|
|
|
|
}
|
|
@@ -86,14 +100,18 @@ const { options } = useWebSocket({
|
|
|
},
|
|
|
});
|
|
|
const isReconnecting = toRefs(options).isReconnecting; // 重连状态
|
|
|
-onLoad(() => {
|
|
|
+onShow(() => {
|
|
|
conversationListAxios();
|
|
|
+})
|
|
|
+onLoad(() => {
|
|
|
+ // conversationListAxios();
|
|
|
});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
.chat-list {
|
|
|
padding: 20rpx;
|
|
|
+ height: calc(100vh - var(--window-top));
|
|
|
|
|
|
.chat-item {
|
|
|
display: flex;
|