| 
					
				 | 
			
			
				@@ -164,7 +164,7 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </template> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <script setup> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import { ref, onMounted, onUnmounted, nextTick, watch, onActivated, onDeactivated } from "vue"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { ref, onUnmounted, nextTick, watch, onActivated, onDeactivated } from "vue"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { useRouter } from "vue-router"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { base_img_url2 } from "@/api/config"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { getFileExt } from "@/utils/util"; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -223,7 +223,7 @@ const createSession = (targetUserId,callback) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // 先保存当前的对话样式消息  要注释 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const dialogMessages = messages.value.filter(msg => msg.messageType === 'dialog'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    VE_API.bbs.createSession({farmId:766,targetUserId}).then(({data,code}) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    VE_API.bbs.createSession({farmId:farmVal.value,targetUserId}).then(({data,code}) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if(code === 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             senderIcon.value = localUserInfoIcon 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             receiverIcon.value = data.session.targetUserAvatar 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -269,7 +269,7 @@ const createSession = (targetUserId,callback) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 //类型 text ,file,image 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const sendMsg = (messageType = 'text',content = '',image = {}) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     const params = { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        farmId:766, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        farmId:farmVal.value, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         senderId:curUserId, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         receiverId:userId.value, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         content, 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -281,8 +281,9 @@ const sendMsg = (messageType = 'text',content = '',image = {}) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const userId = ref(null) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-watch(()=>props.userId,(newValue) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+watch(()=>props.userId, async (newValue) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(newValue){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await getFarmList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         userId.value = newValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         createSession(newValue,()=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(props.text){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -346,7 +347,7 @@ const previewImage = ref(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 初始化 mqtt 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const initMqtt = () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const topics = [`user/chat/message/${766}/${curUserId}`]; // 订阅的主题数组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const topics = [`user/chat/message/${farmVal.value}/${curUserId}`]; // 订阅的主题数组 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     mqttClient.value = new MqttClient(topics, (topic, message) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         console.log(topic,'topic') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         console.log('接收推送信息:', message); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -579,20 +580,15 @@ const options = ref([]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 获取农场列表 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 function getFarmList() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    VE_API.farm.userFarmSelectOption().then(({data}) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return VE_API.farm.userFarmSelectOption().then(({data}) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         options.value = data || [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (data && data.length > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            farmVal.value = data[0].id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            const defaultOption = data.find(item => item.defaultOption === true) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            farmVal.value = defaultOption ? defaultOption.id : data[0].id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-// 生命周期钩子 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-onMounted(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    // scrollToBottom(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    getFarmList(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 onActivated(()=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if(props.userId){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				        scrollToBottom(); 
			 |