chenjj 1 day ago
parent
commit
3ec1b30f65
3 changed files with 33 additions and 7 deletions
  1. 10 0
      api/conversation.js
  2. 2 2
      config.js
  3. 21 5
      pages_orderuser/pages/talk/pages/index/index.vue

+ 10 - 0
api/conversation.js

@@ -61,4 +61,14 @@ export function conversationRemove(data) {
         method: 'post',
         method: 'post',
         data
         data
     })
     })
+}
+
+
+//获取历史聊天记录,目前设置为获取10条
+export function getHistoryMsg(data) {
+    return request({
+        url: `/core/conversation/getHistoryMsg`,
+        method: 'post',
+        data
+    })
 }
 }

+ 2 - 2
config.js

@@ -2,8 +2,8 @@
 const config = {
 const config = {
 	// baseUrl: 'https://vue.ruoyi.vip/prod-api',
 	// baseUrl: 'https://vue.ruoyi.vip/prod-api',
 	//cloud后台网关地址
 	//cloud后台网关地址
-	baseUrl: 'http://192.168.100.95:9527',//嵘哥
-	// baseUrl: 'http://192.168.100.101:9527',//龙哥
+	// baseUrl: 'http://192.168.100.110:9527',//嵘哥
+	baseUrl: 'http://192.168.100.127:9527',//龙哥
 	// baseUrl: 'https://zybooks.tech/prod-api',
 	// baseUrl: 'https://zybooks.tech/prod-api',
 	mapKey:'KFEBZ-P2GKZ-A5PX4-7Q6Y7-KXOBF-XCB4C',
 	mapKey:'KFEBZ-P2GKZ-A5PX4-7Q6Y7-KXOBF-XCB4C',
 	appName: '金邻助家',
 	appName: '金邻助家',

+ 21 - 5
pages_orderuser/pages/talk/pages/index/index.vue

@@ -45,7 +45,7 @@
 
 
 <script>
 <script>
 import { wxUploadFile, wxMakePhoneCall } from '@/utils/wxRequest.js'
 import { wxUploadFile, wxMakePhoneCall } from '@/utils/wxRequest.js'
-import { sendMsg, getOrderConversationInfo, getListConversationInfo, setRead } from '@/api/conversation.js';
+import { sendMsg, getOrderConversationInfo, getListConversationInfo, setRead,getHistoryMsg } from '@/api/conversation.js';
 import { onMounted } from "vue";
 import { onMounted } from "vue";
 import store from "@/store"
 import store from "@/store"
 export default {
 export default {
@@ -131,9 +131,25 @@ export default {
 			console.log("TCL: 下拉刷新 -> e", e)
 			console.log("TCL: 下拉刷新 -> e", e)
 			this.scrollView.refresherTriggered = true;
 			this.scrollView.refresherTriggered = true;
 			// this.getMessage();
 			// this.getMessage();
-			setTimeout(()=>{
-				this.scrollView.refresherTriggered = false;
-			},500)
+			const conversationMsgRecordId = this.talkList[this.talkList.length-1].conversationMsgRecordId;
+			console.log("TCL: refresherrefresh -> conversationMsgRecordId", conversationMsgRecordId,this.talkList[this.talkList.length-1])
+			const msgSendTime =  this.talkList[this.talkList.length-1].msgSendTime
+			getHistoryMsg({conversationMsgRecordId,conversationRecordId:this.conversationRecordId}).then(res => {
+				console.log("TCL: refresherrefresh -> res", res)
+				if(res.code === 200){
+					if(res.data.length === 0) {
+						uni.showToast({
+							title: '没有更多消息了',
+							icon: 'none'
+						})
+						this.scrollView.refresherTriggered = false;
+						return
+					}
+					this.talkList = [...this.talkList,...res.data];
+					this.scrollView.refresherTriggered = false;
+					this.scrollView.intoView = `msg-${msgSendTime}`;
+				}
+			})
 		},
 		},
 		listsMessage(){
 		listsMessage(){
 			console.log('-----listsMessage---->', this.storeUser,this.storeUser.wsManager);
 			console.log('-----listsMessage---->', this.storeUser,this.storeUser.wsManager);
@@ -190,7 +206,7 @@ export default {
 					// 		title: userType === 1? res.data. :  // 根据业务逻辑调整 
 					// 		title: userType === 1? res.data. :  // 根据业务逻辑调整 
 					// 	});
 					// 	});
 					// 将获取到的消息数据合并到消息数组中
 					// 将获取到的消息数据合并到消息数组中
-					this.talkList = [...this.talkList, ...data];
+					this.talkList = data;
 					console.log("TCL: getOrder -> talkList", this.talkList)
 					console.log("TCL: getOrder -> talkList", this.talkList)
 					this.orderInfo = res.data;
 					this.orderInfo = res.data;