From 088891bdbb795f462c0352dfb58715bebbfca4b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B5=B5=E6=AF=85?= <1335909236@qq.com>
Date: Wed, 24 Sep 2025 17:24:22 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AE=A2=E6=9C=8D=E6=A8=A1?=
=?UTF-8?q?=E5=9D=97=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../customerService/chattingRecords/index.vue | 94 ++++-------
packages/customerService/index/index.css | 12 +-
packages/customerService/index/index.vue | 148 +++++++++++++++---
packages/shop/groupPurchaseSubmit/index.vue | 2 +-
packages/user/replenishInfo/index.vue | 1 +
pages/index/index.vue | 3 +-
pages/login/login.vue | 1 +
utils/mqtt.js | 35 ++++-
8 files changed, 199 insertions(+), 97 deletions(-)
diff --git a/packages/customerService/chattingRecords/index.vue b/packages/customerService/chattingRecords/index.vue
index fa81ca88..e17b049a 100644
--- a/packages/customerService/chattingRecords/index.vue
+++ b/packages/customerService/chattingRecords/index.vue
@@ -6,14 +6,15 @@
加载中...
暂无聊天记录
-
-
-
-
- {{ record.title }}
- {{ formatTime(record.lastMsgTime) }}
+
+
+
+
+
+ {{ record.contact_name }}
+ {{ record.update_time }}
+
- {{ record.lastMsg || '暂无消息' }}
@@ -61,63 +62,14 @@ export default {
page_num: this.page_num,
page_size: this.page_size,
}).then((res) => {
- console.log("🚀 ~ loadChattingRecords ~ res:", res)
+ this.recordsList = res.msg_list
})
-
- // const response = await this.$http.get(apiArr.csGetMsgList);
-
- // if (response.success && response.data && response.data.list) {
- // this.recordsList = response.data.list.map(item => ({
- // mchId: item.mchId,
- // title: item.title || `客服${item.mchId}`,
- // avatar: item.avatar,
- // lastMsg: item.lastMsg,
- // lastMsgTime: item.lastMsgTime || Date.now(),
- // unreadCount: item.unreadCount || 0
- // }));
- // } else {
- // // 使用模拟数据
- // this.recordsList = this.getMockRecords();
- // }
} catch (error) {
console.error('加载聊天记录失败', error);
- // 使用模拟数据
- this.recordsList = this.getMockRecords();
} finally {
this.isLoading = false;
}
},
-
- // 获取模拟数据
- getMockRecords() {
- return [
- {
- mchId: '1001',
- title: '客服小明',
- avatar: '/static/logo.png',
- lastMsg: '您好,请问有什么可以帮助您的吗?',
- lastMsgTime: Date.now() - 30 * 60 * 1000,
- unreadCount: 0
- },
- {
- mchId: '1002',
- title: '客服小丽',
- avatar: '/static/logo.png',
- lastMsg: '您的问题我已经记录,稍后会有专人与您联系。',
- lastMsgTime: Date.now() - 2 * 60 * 60 * 1000,
- unreadCount: 1
- },
- {
- mchId: '1003',
- title: '客服小张',
- avatar: '/static/logo.png',
- lastMsg: '感谢您的咨询,还有其他问题吗?',
- lastMsgTime: Date.now() - 5 * 60 * 60 * 1000,
- unreadCount: 0
- }
- ];
- },
-
// 格式化时间
formatTime(time) {
const date = new Date(time);
@@ -152,13 +104,29 @@ export default {
// 跳转到聊天页面
goToChatPage(record) {
- // 存储当前聊天对象的信息,供聊天页面使用
- uni.setStorageSync('currentChatTarget', record);
+ const params = {
+ mch_id: record.mch_id,
+ }
- // 跳转到聊天页面
- uni.navigateTo({
- url: '/packages/customerService/index/index?mchId=' + record.mchId
- });
+ request(apiArr.csGetMchContactList, "POST", params).then((res) => {
+ if (res.rows && res.rows.length > 0) {
+ res.rows.map(item => {
+ item.employee_image = picUrl + item.employee_image;
+ })
+ const itemObj = res.rows.find(item => item.employee_mobile === record.two.account)
+
+ // 跳转到聊天页面
+ uni.navigateTo({
+ url: '/packages/customerService/index/index?item=' + JSON.stringify(itemObj)
+ });
+ } else {
+ console.log("没有获取到客服列表数据");
+ uni.showToast({
+ title: '该客服不存在',
+ icon: 'none'
+ })
+ }
+ })
}
}
};
diff --git a/packages/customerService/index/index.css b/packages/customerService/index/index.css
index fd28095f..a4edd94b 100644
--- a/packages/customerService/index/index.css
+++ b/packages/customerService/index/index.css
@@ -1,7 +1,8 @@
/* 客服聊天页面样式 */
page {
background-color: #f6f7fb;
- overflow-y: hidden;
+ height: 100vh;
+ overflow: hidden;
}
/* 聊天容器 */
@@ -10,6 +11,11 @@ page {
flex-direction: column;
height: 100vh;
background-color: #f6f7fb;
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ z-index: 1;
}
/* 聊天头部 */
@@ -22,6 +28,8 @@ page {
background-color: #fff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding-bottom: 15rpx;
+ position: relative;
+ z-index: 2;
}
.back-btn {
@@ -130,6 +138,8 @@ page {
padding: 10px 15px;
border-top: 1px solid #eee;
margin-bottom: 20rpx;
+ position: relative;
+ z-index: 2;
}
.input-container {
diff --git a/packages/customerService/index/index.vue b/packages/customerService/index/index.vue
index 15b2a82f..315ba84a 100644
--- a/packages/customerService/index/index.vue
+++ b/packages/customerService/index/index.vue
@@ -16,7 +16,7 @@
+ @scrolltoupper="loadMoreHistory" @scrolltolower="loadMoreHistory" lower-threshold="100" upper-threshold="100">
加载历史消息...
@@ -31,7 +31,7 @@
'other': !message.isSelf,
'loading': message.isLoading
}" class="message-item">
-
{{ message.content }}
@@ -44,7 +44,9 @@
+ @confirm="sendMessage" @input="handleInput" auto-height hold-keyboard="true"
+ enable-keyboard-accessory-view="true" cursor-spacing="10" maxlength="500"
+ @focus="onInputFocus" @blur="onInputBlur">
@@ -54,9 +56,9 @@