xiaobin.zhang 2 tahun lalu
induk
melakukan
72f236dc26

+ 176 - 186
chat/components/chat/inputbar/suit/main/main.vue

@@ -1,193 +1,183 @@
 <template>
-  <!-- <chat-suit-emoji id="chat-suit-emoji" bind:newEmojiStr="emojiAction"></chat-suit-emoji> -->
-  <form class="text-input">
-    <view :class="isIPX ?'f-row-x' :'f-row'">
-      <!-- 发送语音 -->
-      <view>
-        <image class="icon-mic" src="../../../../../static/voice.png" @tap="openRecordModal"></image>
-      </view>
-      <!-- 输入框 -->
-      <textarea
-        class="f news"
-        type="text"
-        cursor-spacing="65"
-        confirm-type='done'
-        v-model="inputMessage"
-        @confirm="sendMessage"
-        @input="bindMessage"
-        @tap="focus"
-        @focus="focus"
-        @blur="blur"
-        :confirm-hold="isIPX ? true : false"
-        auto-height
-        :show-confirm-bar='false'
-        maxlength="300"
-      />
-      <view>
-        <image class="icon-mic" src="../../../../../static/Emoji.png" @tap="openEmoji"></image>
-      </view>
-      <view v-show="!inputMessage" @tap="openFunModal">
-        <image class="icon-mic" src="../../../../../static/ad.png"></image>
-      </view>
-       <button 
-        class="send-btn-style" 
-        hover-class='hover'
-        @tap="sendMessage"
-        v-show="inputMessage" 
-      >发送</button>
-    </view>
-  </form>
+	<!-- <chat-suit-emoji id="chat-suit-emoji" bind:newEmojiStr="emojiAction"></chat-suit-emoji> -->
+	<form class="text-input">
+		<view :class="isIPX ?'f-row-x' :'f-row'">
+			<!-- 发送语音 -->
+			<view>
+				<image class="icon-mic" src="../../../../../static/voice.png" @tap="openRecordModal"></image>
+			</view>
+			<!-- 输入框 -->
+			<textarea class="f news" type="text" cursor-spacing="65" confirm-type='done' v-model="inputMessage"
+				@confirm="sendMessage" @input="bindMessage" @tap="focus" @focus="focus" @blur="blur"
+				:confirm-hold="isIPX ? true : false" auto-height :show-confirm-bar='false' maxlength="300" />
+			<view>
+				<image class="icon-mic" src="../../../../../static/Emoji.png" @tap="openEmoji"></image>
+			</view>
+			<view v-show="!inputMessage" @tap="openFunModal">
+				<image class="icon-mic" src="../../../../../static/ad.png"></image>
+			</view>
+			<button class="send-btn-style" hover-class='hover' @tap="sendMessage" v-show="inputMessage">发送</button>
+		</view>
+	</form>
 </template>
 
 <script>
-let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
-let msgType = require("../../../msgtype");
-let disp = require("../../../../../../hxChatSDK/utils/broadcast");
-let msgStorage = require("../../../msgstorage");
-
-export default {
-  data() {
-    return {
-      inputMessage: "",
-      // render input 的值
-      userMessage: "", // input 的实时值
-      isIPX: false,
-    };
-  },
-
-  components: {},
-  props: {
-    username: {
-      type: Object,
-      default: () => ({}),
-    },
-    chatType: {
-      type: String,
-      default: msgType.chatType.SINGLE_CHAT,
-    },
-  },
-
-  // lifetimes
-  created() {
-    this.setData({
-      isIPX: getApp().globalData.isIPX,
-    });
-  },
-
-  beforeMount() {},
-
-  moved() {},
-
-  destroyed() {},
-
-  mounted() {},
-
-  methods: {
-    focus() {
-      this.$emit("inputFocused", null, {
-        bubbles: true,
-      });
-    },
-    blur() {
-      this.$emit("inputBlured", null, {
-        bubbles: true,
-      });
-    },
-
-    isGroupChat() {
-      return this.chatType == msgType.chatType.CHAT_ROOM;
-    },
-
-    getSendToParam() {
-      return this.isGroupChat() ? this.username.groupId : this.username.your;
-    },
-
-    bindMessage(e) {
-      this.setData({
-        userMessage: e.detail.value,
-      });
-    },
-
-    emojiAction(emoji) {
-      var str;
-      var msglen = this.userMessage.length - 1;
-
-      if (emoji && emoji != "[del]") {
-        str = this.userMessage + emoji;
-      } else if (emoji == "[del]") {
-        let start = this.userMessage.lastIndexOf("[");
-        let end = this.userMessage.lastIndexOf("]");
-        let len = end - start;
-
-        if (end != -1 && end == msglen && len >= 3 && len <= 4) {
-          str = this.userMessage.slice(0, start);
-        } else {
-          str = this.userMessage.slice(0, msglen);
-        }
-      }
-      this.userMessage = str;
-      this.inputMessage = str;
-    },
-
-    sendMessage() {
-      let me = this;
-      String.prototype.trim = function () {
-        return this.replace(/(^\s*)|(\s*$)/g, "");
-      };
-      if (!this.userMessage.trim()) {
-        return;
-      }
-      let id = WebIM.conn.getUniqueId();
-      let msg = new WebIM.message(msgType.TEXT, id);
-      msg.set({
-        msg: this.userMessage,
-        from: this.username.myName,
-        to: this.getSendToParam(),
-        // roomType: false,
-        chatType: this.chatType,
-        success(id, serverMsgId) {
-          console.log("成功了");
-          // 关闭表情弹窗
-          me.$parent.cancelEmoji()
-          me.$parent.closeFunModal()
-          disp.fire("em.chat.sendSuccess", id, me.userMessage);
-        },
-        fail(id, serverMsgId) {
-          console.log("失败了");
-        },
-      });
-	  
-      if (this.chatType == msgType.chatType.CHAT_ROOM) {
-        // msg.setGroup("groupchat");
-		msg.setChatType("groupchat");
-      }
-        WebIM.conn.send(msg.body);
-        let obj = {
-          msg: msg,
-          type: msgType.TEXT,
-        };
-        this.saveSendMsg(obj);
-      this.userMessage = "";
-      this.inputMessage = "";
-      uni.hideKeyboard();
-    },
-
-    saveSendMsg(evt) {
-      msgStorage.saveMsg(evt.msg, evt.type);
-    },
-
-    openEmoji(){
-      this.$emit('openEmoji')
-    },
-    openRecordModal(){
-      this.$emit('openRecordModal')
-    },
-    openFunModal(){
-      this.$emit('openFunModal')
-    }
-  },
-};
+	let WebIM = require("../../../../../../hxChatSDK/utils/WebIM")["default"];
+	let msgType = require("../../../msgtype");
+	let disp = require("../../../../../../hxChatSDK/utils/broadcast");
+	let msgStorage = require("../../../msgstorage");
+    const req = require('../../../../../../utils/request.js');
+		
+	export default {
+		data() {
+			return {
+				inputMessage: "",
+				// render input 的值
+				userMessage: "", // input 的实时值
+				isIPX: false,
+				userInfo:'',
+			};
+		},
+
+		components: {},
+		props: {
+			username: {
+				type: Object,
+				default: () => ({}),
+			},
+			chatType: {
+				type: String,
+				default: msgType.chatType.SINGLE_CHAT,
+			},
+		},
+
+		// lifetimes
+		created() {
+			this.userInfo = req.getStorage('userInfo');
+			this.setData({
+				isIPX: getApp().globalData.isIPX,
+			});
+		},
+
+		beforeMount() {},
+
+		moved() {},
+
+		destroyed() {},
+
+		mounted() {},
+
+		methods: {
+			focus() {
+				this.$emit("inputFocused", null, {
+					bubbles: true,
+				});
+			},
+			blur() {
+				this.$emit("inputBlured", null, {
+					bubbles: true,
+				});
+			},
+
+			isGroupChat() {
+				return this.chatType == msgType.chatType.CHAT_ROOM;
+			},
+
+			getSendToParam() {
+				return this.isGroupChat() ? this.username.groupId : this.username.your;
+			},
+
+			bindMessage(e) {
+				this.setData({
+					userMessage: e.detail.value,
+				});
+			},
+
+			emojiAction(emoji) {
+				var str;
+				var msglen = this.userMessage.length - 1;
+
+				if (emoji && emoji != "[del]") {
+					str = this.userMessage + emoji;
+				} else if (emoji == "[del]") {
+					let start = this.userMessage.lastIndexOf("[");
+					let end = this.userMessage.lastIndexOf("]");
+					let len = end - start;
+
+					if (end != -1 && end == msglen && len >= 3 && len <= 4) {
+						str = this.userMessage.slice(0, start);
+					} else {
+						str = this.userMessage.slice(0, msglen);
+					}
+				}
+				this.userMessage = str;
+				this.inputMessage = str;
+			},
+
+			sendMessage() {
+				let me = this;
+				String.prototype.trim = function() {
+					return this.replace(/(^\s*)|(\s*$)/g, "");
+				};
+				if (!this.userMessage.trim()) {
+					return;
+				}
+				let id = WebIM.conn.getUniqueId();
+				let msg = new WebIM.message(msgType.TEXT, id);
+				msg.set({
+					msg: this.userMessage,
+					from: this.username.myName,
+					to: this.getSendToParam(),
+					// roomType: false,
+					chatType: this.chatType,
+					ext: {
+						nickName: this.userInfo.nickName,
+						avatar: this.userInfo.avatar,
+						id: this.userInfo.id,
+					},
+					success(id, serverMsgId) {
+						console.log("成功了");
+						// 关闭表情弹窗
+						me.$parent.cancelEmoji()
+						me.$parent.closeFunModal()
+						disp.fire("em.chat.sendSuccess", id, me.userMessage);
+					},
+					fail(id, serverMsgId) {
+						console.log("失败了");
+					},
+				});
+
+				if (this.chatType == msgType.chatType.CHAT_ROOM) {
+					// msg.setGroup("groupchat");
+					msg.setChatType("groupchat");
+				}
+				WebIM.conn.send(msg.body);
+				let obj = {
+					msg: msg,
+					type: msgType.TEXT,
+				};
+				this.saveSendMsg(obj);
+				this.userMessage = "";
+				this.inputMessage = "";
+				uni.hideKeyboard();
+			},
+
+			saveSendMsg(evt) {
+				msgStorage.saveMsg(evt.msg, evt.type);
+			},
+
+			openEmoji() {
+				this.$emit('openEmoji')
+			},
+			openRecordModal() {
+				this.$emit('openRecordModal')
+			},
+			openFunModal() {
+				this.$emit('openFunModal')
+			}
+		},
+	};
 </script>
 <style>
-@import "./main.css";
+	@import "./main.css";
 </style>

+ 26 - 36
chat/components/chat/msglist/msglist.vue

@@ -19,7 +19,7 @@
 				<view class="user">
 					<!-- yourname:就是消息的 from -->
 					<text v-if="!item.style"
-						class="user-text">{{ showMessageListNickname(item.yourname) + ' ' + handleTime(item)}}</text>
+						class="user-text">{{ showMessageListNickname(item) + ' ' + handleTime(item)}}</text>
 				</view>
 				<image class="avatar" :src="showMessageListAvatar(item)" />
 				<view class="msg">
@@ -59,8 +59,8 @@
 	let msgStorage = require("../msgstorage");
 	let disp = require("../../../../hxChatSDK/utils/broadcast");
 	let timeFormats = require("../../../../hxChatSDK/utils/timeFormat");
-	
-	
+
+
 	let LIST_STATUS = {
 		SHORT: "scroll_view_change",
 		NORMAL: "scroll_view"
@@ -185,39 +185,7 @@
 			msgStorage.on("newChatMsg", this.dispMsg);
 		},
 		computed: {
-			//消息列表头像展示
-			showMessageListAvatar() {
-				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
-				const myUserInfos = getApp().globalData.userInfoFromServer;
-				return (item) => {
-					if (!item.style) {
-						if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.avatarurl) {
-							return friendUserInfoMap.get(item.username).avatarurl
-						} else {
-							return this.defaultAvatar
-						}
-					} else {
-						if (myUserInfos?.avatarurl) {
-							return myUserInfos.avatarurl
-						} else {
-							return this.defaultAvatar
-						}
-					}
-
-				}
-			},
-			//消息列表昵称显示
-			showMessageListNickname() {
-				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
-				return (hxId) => {
-					if (friendUserInfoMap.has(hxId) && friendUserInfoMap.get(hxId)?.nickname) {
-						return friendUserInfoMap.get(hxId).nickname
-					} else {
-						return hxId
-					}
-
-				}
-			},
+			
 			//处理时间显示
 			handleTime() {
 				return (item) => {
@@ -231,6 +199,28 @@
 					view: LIST_STATUS.NORMAL
 				});
 			},
+			
+			//消息列表头像展示
+			showMessageListAvatar(item) {
+				// console.log('item>>>>>',item);
+				const imUserInfo = uni.getStorageSync("imUserInfo_" + item.info.from);
+				if (imUserInfo && imUserInfo.avatar) {
+					return imUserInfo.avatar;
+				} else {
+					return this.defaultAvatar;
+				}
+			},
+			//消息列表昵称显示
+			showMessageListNickname(item) {
+				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				const imUserInfo = uni.getStorageSync("imUserInfo_" + item.info.from);
+				if (imUserInfo && imUserInfo.nickName) {
+					return imUserInfo.nickName;
+				} else {
+					return item.yourname;
+				}
+			},
+			
 			dispMsg(renderableMsg, type, curChatMsg, sesskey) {
 				let me = this;
 				let username = this.username;

+ 191 - 186
chat/components/chat/msgstorage.js

@@ -8,194 +8,199 @@ let msgStorage = new Disp();
 
 let disp = require("../../../hxChatSDK/utils/broadcast.js");
 
-msgStorage.saveReceiveMsg = function (receiveMsg, type) {
-  console.log(receiveMsg, 'receiveMsg')
-  let sendableMsg;
-
-  if (type == msgType.IMAGE) {
-    sendableMsg = {
-      id: receiveMsg.id,
-      type: type,
-      body: {
-        id: receiveMsg.id,
-        from: receiveMsg.from,
-        to: receiveMsg.to,
-        type: receiveMsg.type,
-        ext: receiveMsg.ext,
-        chatType: receiveMsg.type,
-        toJid: "",
-        body: {
-          type: type,
-          url: receiveMsg.url,
-          filename: receiveMsg.filename,
-          filetype: receiveMsg.filetype,
-          size: {
-            width: receiveMsg.width,
-            height: receiveMsg.height
-          }
-        }
-      },
-      time:receiveMsg.time
-    };
-  } else if (type == msgType.TEXT || type == msgType.EMOJI) {
-    sendableMsg = {
-      id: receiveMsg.id,
-      type: type,
-      body: {
-        id: receiveMsg.id,
-        from: receiveMsg.from,
-        to: receiveMsg.to,
-        type: receiveMsg.type,
-        ext: receiveMsg.ext,
-        chatType: receiveMsg.type,
-        toJid: "",
-        body: {
-          type: type,
-          msg: receiveMsg.data
-        }
-      },
-      value: receiveMsg.data,
-      time:receiveMsg.time
-    };
-  } 
-  else if (type == 'INFORM') { // 通知消息
-    sendableMsg = {
-      body: {
-        from: receiveMsg.from,
-        to: receiveMsg.to,
-        chatType: 'INFORM',
-        gid:receiveMsg.gid ? receiveMsg.gid:'',
-        type:receiveMsg.type
-      },
-    };
-  } else if (type == msgType.FILE) {
-    sendableMsg = {
-      id: receiveMsg.id,
-      type: type,
-      body: {
-        id: receiveMsg.id,
-        length: receiveMsg.file_length,
-        from: receiveMsg.from,
-        to: receiveMsg.to,
-        type: receiveMsg.type,
-        ext: receiveMsg.ext,
-        chatType: receiveMsg.type,
-        toJid: "",
-        body: {
-          type: type,
-          url: receiveMsg.url,
-          filename: receiveMsg.filename,
-          file_length: receiveMsg.file_length
-        }
-      },
-      value: receiveMsg.data,
-      time:receiveMsg.time
-    };
-  } else if (type == msgType.AUDIO) {
-    sendableMsg = {
-      id: receiveMsg.id,
-      type: type,
-      accessToken: receiveMsg.token || receiveMsg.accessToken,
-      body: {
-        id: receiveMsg.id,
-        length: receiveMsg.length,
-        from: receiveMsg.from,
-        to: receiveMsg.to,
-        type: receiveMsg.type,
-        ext: receiveMsg.ext,
-        chatType: receiveMsg.type,
-        toJid: "",
-        body: {
-          type: type,
-          url: receiveMsg.url,
-          filename: receiveMsg.filename,
-          filetype: receiveMsg.filetype,
-          from: receiveMsg.from,
-          to: receiveMsg.to
-        }
-      },
-      time:receiveMsg.time
-    };
-  } else if (type == msgType.VIDEO) {
-    sendableMsg = {
-      id: receiveMsg.id,
-      type: type,
-      accessToken: receiveMsg.token || receiveMsg.accessToken,
-      body: {
-        id: receiveMsg.id,
-        length: receiveMsg.length,
-        from: receiveMsg.from,
-        to: receiveMsg.to,
-        type: receiveMsg.type,
-        ext: receiveMsg.ext,
-        chatType: receiveMsg.type,
-        toJid: "",
-        body: {
-          type: type,
-          url: receiveMsg.url,
-          filename: receiveMsg.filename,
-          filetype: receiveMsg.filetype,
-          from: receiveMsg.from,
-          to: receiveMsg.to
-        },
-      },
-      time:receiveMsg.time
-    };
-  } else {
-    return;
-  }
-
-  this.saveMsg(sendableMsg, type, receiveMsg);
+msgStorage.saveReceiveMsg = function(receiveMsg, type) {
+	console.log(receiveMsg, 'receiveMsg')
+	let sendableMsg;
+
+	if (type == msgType.IMAGE) {
+		sendableMsg = {
+			id: receiveMsg.id,
+			type: type,
+			body: {
+				id: receiveMsg.id,
+				from: receiveMsg.from,
+				to: receiveMsg.to,
+				type: receiveMsg.type,
+				ext: receiveMsg.ext,
+				chatType: receiveMsg.type,
+				toJid: "",
+				body: {
+					type: type,
+					url: receiveMsg.url,
+					filename: receiveMsg.filename,
+					filetype: receiveMsg.filetype,
+					size: {
+						width: receiveMsg.width,
+						height: receiveMsg.height
+					}
+				}
+			},
+			time: receiveMsg.time
+		};
+	} else if (type == msgType.TEXT || type == msgType.EMOJI) {
+		sendableMsg = {
+			id: receiveMsg.id,
+			type: type,
+			body: {
+				id: receiveMsg.id,
+				from: receiveMsg.from,
+				to: receiveMsg.to,
+				type: receiveMsg.type,
+				ext: receiveMsg.ext,
+				chatType: receiveMsg.type,
+				toJid: "",
+				body: {
+					type: type,
+					msg: receiveMsg.data
+				}
+			},
+			value: receiveMsg.data,
+			time: receiveMsg.time
+		};
+	} else if (type == 'INFORM') { // 通知消息
+		sendableMsg = {
+			body: {
+				from: receiveMsg.from,
+				to: receiveMsg.to,
+				chatType: 'INFORM',
+				gid: receiveMsg.gid ? receiveMsg.gid : '',
+				type: receiveMsg.type
+			},
+		};
+	} else if (type == msgType.FILE) {
+		sendableMsg = {
+			id: receiveMsg.id,
+			type: type,
+			body: {
+				id: receiveMsg.id,
+				length: receiveMsg.file_length,
+				from: receiveMsg.from,
+				to: receiveMsg.to,
+				type: receiveMsg.type,
+				ext: receiveMsg.ext,
+				chatType: receiveMsg.type,
+				toJid: "",
+				body: {
+					type: type,
+					url: receiveMsg.url,
+					filename: receiveMsg.filename,
+					file_length: receiveMsg.file_length
+				}
+			},
+			value: receiveMsg.data,
+			time: receiveMsg.time
+		};
+	} else if (type == msgType.AUDIO) {
+		sendableMsg = {
+			id: receiveMsg.id,
+			type: type,
+			accessToken: receiveMsg.token || receiveMsg.accessToken,
+			body: {
+				id: receiveMsg.id,
+				length: receiveMsg.length,
+				from: receiveMsg.from,
+				to: receiveMsg.to,
+				type: receiveMsg.type,
+				ext: receiveMsg.ext,
+				chatType: receiveMsg.type,
+				toJid: "",
+				body: {
+					type: type,
+					url: receiveMsg.url,
+					filename: receiveMsg.filename,
+					filetype: receiveMsg.filetype,
+					from: receiveMsg.from,
+					to: receiveMsg.to
+				}
+			},
+			time: receiveMsg.time
+		};
+	} else if (type == msgType.VIDEO) {
+		sendableMsg = {
+			id: receiveMsg.id,
+			type: type,
+			accessToken: receiveMsg.token || receiveMsg.accessToken,
+			body: {
+				id: receiveMsg.id,
+				length: receiveMsg.length,
+				from: receiveMsg.from,
+				to: receiveMsg.to,
+				type: receiveMsg.type,
+				ext: receiveMsg.ext,
+				chatType: receiveMsg.type,
+				toJid: "",
+				body: {
+					type: type,
+					url: receiveMsg.url,
+					filename: receiveMsg.filename,
+					filetype: receiveMsg.filetype,
+					from: receiveMsg.from,
+					to: receiveMsg.to
+				},
+			},
+			time: receiveMsg.time
+		};
+	} else {
+		return;
+	}
+
+	this.saveMsg(sendableMsg, type, receiveMsg);
 };
 
-msgStorage.saveMsg = function (sendableMsg, type, receiveMsg) {
-  let me = this;
-  let myName = uni.getStorageSync("myUsername");
-  let sessionKey; // 仅用作群聊收消息,发消息没有 receiveMsg
-
-  if (receiveMsg && receiveMsg.type == "groupchat") {
-    sessionKey = receiveMsg.to + myName;
-  } else if (sendableMsg.body.chatType === 'INFORM'){
-    sessionKey = 'INFORM'
-  }
-  
-  // 群聊发 & 单发 & 单收
-  else {
-    sessionKey = sendableMsg.body.from == myName ? sendableMsg.body.to + myName : sendableMsg.body.from + myName;
-  }
-
-  let curChatMsg = uni.getStorageSync(sessionKey) || [];
-  let renderableMsg = msgPackager(sendableMsg, type, myName);
-
-  if (type == msgType.AUDIO) {
-    renderableMsg.msg.length = sendableMsg.body.length;
-    renderableMsg.msg.token = sendableMsg.accessToken;
-  }
-
-  curChatMsg.push(renderableMsg); //console.log('renderableMsgrenderableMsg', renderableMsg)
-
-  if (type == msgType.VIDEO) {
-    renderableMsg.msg.token = sendableMsg.accessToken; //如果是音频则请求服务器转码
-  }
-
-
-  save();
-
-  function save() {
-    uni.setStorage({
-      key: sessionKey,
-      data: curChatMsg,
-
-      success() {
-        if (type == msgType.AUDIO || type == msgType.VIDEO) {
-          disp.fire('em.chat.audio.fileLoaded');
-        }
-
-        me.fire("newChatMsg", renderableMsg, type, curChatMsg, sessionKey);
-      }
-
-    });
-  }
+msgStorage.saveMsg = function(sendableMsg, type, receiveMsg) {
+	let me = this;
+	let myName = uni.getStorageSync("myUsername");
+	let sessionKey; // 仅用作群聊收消息,发消息没有 receiveMsg
+
+	if (receiveMsg && receiveMsg.type == "groupchat") {
+		sessionKey = receiveMsg.to + myName;
+	} else if (sendableMsg.body.chatType === 'INFORM') {
+		sessionKey = 'INFORM'
+	}
+
+	// 群聊发 & 单发 & 单收
+	else {
+		sessionKey = sendableMsg.body.from == myName ? sendableMsg.body.to + myName : sendableMsg.body.from +
+			myName;
+	}
+
+	let curChatMsg = uni.getStorageSync(sessionKey) || [];
+	let renderableMsg = msgPackager(sendableMsg, type, myName);
+
+	if (type == msgType.AUDIO) {
+		renderableMsg.msg.length = sendableMsg.body.length;
+		renderableMsg.msg.token = sendableMsg.accessToken;
+	}
+
+	curChatMsg.push(renderableMsg); //console.log('renderableMsgrenderableMsg', renderableMsg)
+
+	if (type == msgType.VIDEO) {
+		renderableMsg.msg.token = sendableMsg.accessToken; //如果是音频则请求服务器转码
+	}
+
+	//保存头像和昵称
+	uni.setStorage({
+		key: 'imUserInfo_' + sendableMsg.body.from,
+		data: sendableMsg.body.ext
+	});
+	console.log('消息中抓取发送用户的头像昵称信息,并缓存' + sendableMsg.body.from + '>>>', sendableMsg.body.ext);
+	save();
+
+	function save() {
+		uni.setStorage({
+			key: sessionKey,
+			data: curChatMsg,
+
+			success() {
+				if (type == msgType.AUDIO || type == msgType.VIDEO) {
+					disp.fire('em.chat.audio.fileLoaded');
+				}
+
+				me.fire("newChatMsg", renderableMsg, type, curChatMsg, sessionKey);
+			}
+
+		});
+	}
 };
 
 module.exports = msgStorage;

+ 34 - 15
chat/conversation/conversation.vue

@@ -192,14 +192,22 @@
 		computed: {
 			//会话头像展示
 			showConversationAvatar() {
-				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
 				return (item) => {
 					if (item.chatType === 'singleChat' || item.chatType === 'chat') {
-						if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.avatarurl) {
-							return friendUserInfoMap.get(item.username).avatarurl
+
+						// if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.avatarurl) {
+						// 	return friendUserInfoMap.get(item.username).avatarurl
+						// } else {
+						// 	return this.defaultAvatar
+						// }
+						const imUserInfo = uni.getStorageSync("imUserInfo_" + item.username);
+						if (imUserInfo && imUserInfo.avatar) {
+							return imUserInfo.avatar;
 						} else {
-							return this.defaultAvatar
+							return this.defaultAvatar;
 						}
+						
 					} else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
 						return this.defaultGroupAvatar
 					}
@@ -207,13 +215,19 @@
 			},
 			//会话name展示
 			showConversationName() {
-				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
+				// const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
 				return (item) => {
 					if (item.chatType === 'singleChat' || item.chatType === 'chat') {
-						if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.nickname) {
-							return friendUserInfoMap.get(item.username).nickname
+						// if (friendUserInfoMap.has(item.username) && friendUserInfoMap.get(item.username)?.nickname) {
+						// 	return friendUserInfoMap.get(item.username).nickname
+						// } else {
+						// 	return item.username
+						// }
+						const imUserInfo = uni.getStorageSync("imUserInfo_" + item.username);
+						if (imUserInfo && imUserInfo.nickName) {
+							return imUserInfo.nickName;
 						} else {
-							return item.username
+							return item.username;
 						}
 					} else if (item.chatType === 'groupchat' || item.chatType === 'chatRoom') {
 						return item.groupName
@@ -373,13 +387,18 @@
 				this.setData({
 					conversationList: conversationList,
 				});
+				console.log('消息》》》》', this.conversationList);
 			},
 			openSearch: function() {
-				this.setData({
-					search_btn: false,
-					search_chats: true,
-					gotop: true,
-				});
+				// this.setData({
+				// 	search_btn: false,
+				// 	search_chats: true,
+				// 	gotop: true,
+				// });
+
+				this.into_singleChatRoom();
+
+
 			},
 
 			onSearch: function(val) {
@@ -472,8 +491,8 @@
 				var my = uni.getStorageSync("myUsername");
 				var nameList = {
 					myName: my,
-					// your: detail.username,
-					your: '测试号'
+					your: detail.username,
+					// your: 'RS_316923182326'
 				};
 				const friendUserInfoMap = getApp().globalData.friendUserInfoMap;
 				if (friendUserInfoMap.has(nameList.your) && friendUserInfoMap.get(nameList.your)?.nickname) {

+ 2 - 2
utils/request.js

@@ -13,10 +13,10 @@ const env = {
 		// apiUrl: 'http://192.168.110.98:8098'   
 		// apiUrl: 'http://192.168.110.180:8098' ,//f
 		// apiUrl: 'http://192.168.110.182:8098' ,//z
-		apiUrl: 'http://192.168.110.176:8098' //y
+		// apiUrl: 'http://192.168.110.176:8098' //y
 		// apiUrl: 'http://192.168.110.117:8098'//l
 		// apiUrl: 'http://192.168.110.216:8098'
-		// apiUrl: 'http://192.168.110.180:8098' //wjg
+		apiUrl: 'http://192.168.110.180:8098' //wjg
 	}
 }