Kaynağa Gözat

更新聊天记录功能

udream-cxs 4 yıl önce
ebeveyn
işleme
4b2e82d40b

+ 9 - 0
src/apps/mobile/api/monitoring-center/index.js

@@ -74,4 +74,13 @@ export function updateCustomerServiceId(data) {
         url: '/api/liftCases/updateCustomerServiceId',
         data
     })
+}
+
+// 查询历史聊天记录
+export function queryMsgHistoryList(data) {
+    return request({
+        method: 'post',
+        url: '/api/chatMsgs/msgHistoryList',
+        data
+    })
 }

+ 2 - 2
src/apps/mobile/components/ViewChat/chat.vue

@@ -53,7 +53,7 @@
     </el-dialog>
 </template>
 <script>
-import { messageHistory } from '@/apps/mobile/api/chatMsgs/index';
+import { queryChatHistoryList } from '@/apps/mobile/api/monitoring-center/index';
 export default {
     data() {
         return {
@@ -88,7 +88,7 @@ export default {
                 ...this.page,
                 sessionid: this.sessionId,
             };
-            messageHistory(obj)
+            queryChatHistoryList(obj)
                 .then(res => {
                     console.log(res);
                     this.chatRecords = res.data.records;

+ 54 - 21
src/apps/mobile/views/monitoring-center-bank/chat-room/chat-room.vue

@@ -29,6 +29,9 @@
                     <div class="centre-top-title">{{name}}-<span v-if="dataTable == 1">问诊</span><span v-else>出诊</span></div>
                     <el-scrollbar style="background-color:#fff; height: 400px;" ref="scrollbar">
                         <div class="centre-top-content clearfix">
+                            <div>
+                                <button type="button" class="btn-history" v-if="isShowHistory" id="btnhistory" @click="showHistoryDesc($event)">查看历史记录</button>
+                            </div>
                             <div
                                 class="chat-records"
                                 v-for="(item,index) in chatList"
@@ -177,7 +180,7 @@
 </template>
 <script>
 import { webSocketUrl } from '../../../../../config';
-import { queryLiftCasesList, queryChatHistoryList, invitationExpert } from '@/apps/mobile/api/monitoring-center/index';
+import { queryLiftCasesList, queryChatHistoryList, invitationExpert, queryMsgHistoryList } from '@/apps/mobile/api/monitoring-center/index';
 import { queryAllExpert } from '@/apps/mobile/api/expert/index';
 import { isArray, chatUnique, chatUnique2 } from '@/apps//mobile/utils/util';
 export default {
@@ -211,6 +214,7 @@ export default {
             dataTable: null,
             $ws: null,
             timer: '',
+            isShowHistory: true
         };
     },
     created() {
@@ -219,7 +223,7 @@ export default {
         this.sessionId = this.$route.query.sessionId;
         this.customerServiceId = this.$route.query.customerServiceId;
         this.dataTable = this.$route.query.dataTable;
-        this.queryChatHistoryData();
+        // this.queryChatHistoryData();
         this.queryExpertData();
         if (!this.id) {
             this.queryLiftCaseData();
@@ -347,25 +351,25 @@ export default {
             this.$ws.send(JSON.stringify(obj));
         },
         // 聊天结束-------------------------------------------------------
-        queryChatHistoryData() {
-            let obj = {
-                ...this.chatPage,
-                sessionid: this.sessionId,
-            };
-            queryChatHistoryList(obj)
-                .then(res => {
-                    // console.log('聊天历史记录', res);
-                    if (res.data && res.data.records && res.data.records.length > 0) {
-                        this.chatList = res.data.records;
-                        let chatData = [...res.data.records];
-                        this.chatList = chatData.reverse();
-                        if (this.chatList && this.chatList.length > 0) {
-                            this.keepChattingTop();
-                        }
-                    }
-                })
-                .catch();
-        },
+        // queryChatHistoryData() {
+        //     let obj = {
+        //         ...this.chatPage,
+        //         sessionid: this.sessionId,
+        //     };
+        //     queryChatHistoryList(obj)
+        //         .then(res => {
+        //             // console.log('聊天历史记录', res);
+        //             if (res.data && res.data.records && res.data.records.length > 0) {
+        //                 this.chatList = res.data.records;
+        //                 let chatData = [...res.data.records];
+        //                 this.chatList = chatData.reverse();
+        //                 if (this.chatList && this.chatList.length > 0) {
+        //                     this.keepChattingTop();
+        //                 }
+        //             }
+        //         })
+        //         .catch();
+        // },
         // 专家 -------------------------------------------------
         queryExpertData() {
             let obj = {
@@ -454,6 +458,24 @@ export default {
                 }
             });
         },
+        showHistoryDesc(e){
+            let el = e.currentTarget;
+            console.warn(el);
+            let obj = {
+                ...this.chatPage,
+                sessionid: this.sessionId,
+            };
+            queryMsgHistoryList(obj)
+                .then(res => {
+                    console.log('聊天历史记录', res);
+                    if (res.data && res.data.length > 0) {
+                        this.chatList = this.chatList.concat(res.data);
+                    }
+                })
+                .catch();
+
+            this.isShowHistory = false;
+        }
     },
     destroyed() {
         this.$ws.onclose();
@@ -825,4 +847,15 @@ export default {
 ::v-deep .el-textarea__inner {
     height: 130px;
 }
+
+.btn-history {
+	border:0;
+	outline:none;
+	background-color: transparent;
+    cursor: pointer;
+    color: #5383E7;
+    margin-top: 5px;
+    margin-left: 300px;
+    font-size: 12px;
+}
 </style>