diff --git a/src/addon/aikefu/shop/controller/Kefu.php b/src/addon/aikefu/shop/controller/Kefu.php index c0bc7ea24..8d47db8d9 100644 --- a/src/addon/aikefu/shop/controller/Kefu.php +++ b/src/addon/aikefu/shop/controller/Kefu.php @@ -221,16 +221,16 @@ class Kefu extends BaseShop $limit = input("limit/d", 50); $conversation_id = input("conversation_id/s", ""); - if (empty($conversation_id)) { - return $this->error('会话ID不能为空'); - } - $kefu_message_model = new KefuMessageModel(); $condition = [ - ['site_id', '=', $this->site_id], - ['conversation_id', '=', $conversation_id] + ['site_id', '=', $this->site_id] ]; + // 只有当会话ID不为空时才添加会话ID条件 + if (!empty($conversation_id)) { + $condition[] = ['conversation_id', '=', $conversation_id]; + } + $message_list = $kefu_message_model->getMessageList($condition, '*', 'create_time asc', $page, $limit); return $this->success('获取消息列表成功', null, $message_list); diff --git a/src/addon/aikefu/shop/view/kefu/conversation.html b/src/addon/aikefu/shop/view/kefu/conversation.html index 8b24bae93..55f96e889 100644 --- a/src/addon/aikefu/shop/view/kefu/conversation.html +++ b/src/addon/aikefu/shop/view/kefu/conversation.html @@ -80,14 +80,14 @@ toolbar: '#toolbarDemo', defaultToolbar: ['filter', 'exports', 'print'], title: '会话管理', + width: '100%', cols: [[ - {field: 'id', title: 'ID', width: 80, align: 'center', fixed: 'left'}, - {field: 'conversation_id', title: '会话ID', width: 200, align: 'center'}, - {field: 'user_id', title: '用户ID', width: 150, align: 'center'}, - {field: 'name', title: '会话名称', width: 180, align: 'center'}, - {field: 'status', title: '状态', width: 100, align: 'center' }, - {field: 'create_time', title: '创建时间', width: 180, align: 'center'}, - {field: 'update_time', title: '更新时间', width: 180, align: 'center'}, + {field: 'conversation_id', title: '会话ID', align: 'center'}, + {field: 'user_id', title: '用户ID', align: 'center'}, + {field: 'name', title: '会话名称', align: 'center'}, + {field: 'status', title: '状态', align: 'center' }, + {field: 'create_time', title: '创建时间', align: 'center'}, + {field: 'update_time', title: '更新时间', align: 'center'}, {fixed: 'right', title: '操作', width: 200, align: 'center', toolbar: '#barDemo'} ]], page: true, diff --git a/src/addon/aikefu/shop/view/kefu/message.html b/src/addon/aikefu/shop/view/kefu/message.html index 676e5dbc0..a1c5e3621 100644 --- a/src/addon/aikefu/shop/view/kefu/message.html +++ b/src/addon/aikefu/shop/view/kefu/message.html @@ -1,122 +1,232 @@
- +

消息记录

+

默认显示所有会话消息,可通过会话ID进行过滤

@@ -139,10 +249,10 @@ var total = 0; var conversation_id = $('#conversation_id').val(); - // 加载会话信息 + // 加载会话信息(当指定会话ID时显示) function loadConversationInfo() { if (!conversation_id) { - $('#conversationInfo').html('

会话详情

请输入会话ID进行搜索

'); + $('#conversationInfo').html('

消息记录

默认显示所有会话消息,可通过会话ID进行过滤

'); return; } @@ -165,7 +275,7 @@ html += '

更新时间:' + info.update_time + '

'; $('#conversationInfo').html(html); } else { - $('#conversationInfo').html('

会话详情

未找到会话信息

'); + $('#conversationInfo').html('

会话详情

未找到该会话的详细信息

'); } }, error: function() { @@ -176,19 +286,21 @@ // 加载消息列表 function loadMessageList() { - if (!conversation_id) { - $('#messageList').html('
请输入会话ID进行搜索
'); - return; + // 构建请求数据 + var requestData = { + page: page, + limit: limit + }; + + // 如果有会话ID,则添加到请求数据中 + if (conversation_id) { + requestData.conversation_id = conversation_id; } $.ajax({ url: ns.url("aikefu://shop/kefu/getMessageList"), type: 'POST', - data: { - page: page, - limit: limit, - conversation_id: conversation_id - }, + data: requestData, dataType: 'json', success: function(res) { if (res.code === 0) { @@ -217,7 +329,10 @@ html += '
'; }); } else { - html += '
暂无消息记录
'; + html += '
'; + html += ''; + html += '

暂无消息记录

'; + html += '
'; } $('#messageList').html(html); @@ -259,16 +374,23 @@ // 搜索按钮点击事件 $('#searchBtn').click(function() { - conversation_id = $('#conversation_id').val(); + conversation_id = $('#conversation_id').val().trim(); page = 1; loadConversationInfo(); loadMessageList(); }); - // 初始化加载 - if (conversation_id) { + // 重置按钮点击事件 + $('#resetBtn').click(function() { + $('#conversation_id').val(''); + conversation_id = ''; + page = 1; loadConversationInfo(); loadMessageList(); - } + }); + + // 初始化加载(默认显示所有消息) + loadConversationInfo(); + loadMessageList(); }); \ No newline at end of file