xiaobin.zhang %!s(int64=2) %!d(string=hai) anos
pai
achega
5877656344
Modificáronse 2 ficheiros con 68 adicións e 58 borrados
  1. 9 5
      App.vue
  2. 59 53
      chat/chatroom/chatroom.vue

+ 9 - 5
App.vue

@@ -56,8 +56,8 @@
 			});
 			});
 			WebIM.conn.listen({
 			WebIM.conn.listen({
 				onOpened(message) {
 				onOpened(message) {
-					console.log('监听onOpened>>>>>',message);
-					
+					console.log('监听onOpened>>>>>', message);
+
 					if (
 					if (
 						getCurrentRoute() == "pages/user/user" ||
 						getCurrentRoute() == "pages/user/user" ||
 						getCurrentRoute() == "pages/login_token/login_token"
 						getCurrentRoute() == "pages/login_token/login_token"
@@ -341,7 +341,7 @@
 					url: "/chat/conversation/conversation?myName=" + myName,
 					url: "/chat/conversation/conversation?myName=" + myName,
 				});
 				});
 			},
 			},
-			
+
 			getUserInfo(cb) {
 			getUserInfo(cb) {
 				var me = this;
 				var me = this;
 
 
@@ -636,15 +636,19 @@
 				let newChatMsgKeys = [];
 				let newChatMsgKeys = [];
 				let historyChatMsgKeys = [];
 				let historyChatMsgKeys = [];
 				storageKeys.forEach((item) => {
 				storageKeys.forEach((item) => {
-					if (item.indexOf(myName) > -1 && item.indexOf("rendered_") == -1) {
+					if (item.indexOf(myName) > -1 && item.indexOf("rendered_") == -1 && item.indexOf(
+							"imUserInfo_") == -1) {
 						newChatMsgKeys.push(item);
 						newChatMsgKeys.push(item);
 					}
 					}
 				});
 				});
+
+				console.log('newChatMsgKeys》》》》》', newChatMsgKeys);
+
 				let count = newChatMsgKeys.reduce(function(result, curMember, idx) {
 				let count = newChatMsgKeys.reduce(function(result, curMember, idx) {
 					let newName = curMember.split(myName)[0]
 					let newName = curMember.split(myName)[0]
 					let chatMsgs;
 					let chatMsgs;
 					chatMsgs = uni.getStorageSync(curMember) || [];
 					chatMsgs = uni.getStorageSync(curMember) || [];
-					console.log('chatMsgs>>>>>',chatMsgs);
+					console.log('chatMsgs>>>>>', chatMsgs);
 					//过滤消息来源与当前登录ID一致的消息,不计入总数中。
 					//过滤消息来源与当前登录ID一致的消息,不计入总数中。
 					chatMsgs = chatMsgs.filter((msg) => msg.yourname !== myName);
 					chatMsgs = chatMsgs.filter((msg) => msg.yourname !== myName);
 					if (pushAry.includes(newName)) return result
 					if (pushAry.includes(newName)) return result

+ 59 - 53
chat/chatroom/chatroom.vue

@@ -1,64 +1,70 @@
 <template>
 <template>
-<chat id="chat" :username="username" ref="chat" chatType="singleChat" @onClickInviteMsg="onClickMsg"></chat>
+	<chat id="chat" :username="username" ref="chat" chatType="singleChat" @onClickInviteMsg="onClickMsg"></chat>
 </template>
 </template>
 
 
 <script>
 <script>
-let disp = require("../../hxChatSDK/utils/broadcast");
-import chat from "../../chat/components/chat/chat.vue";
+	let disp = require("../../hxChatSDK/utils/broadcast");
+	import chat from "../../chat/components/chat/chat.vue";
 
 
-export default {
-  data() {
-    return {
-      username: {
-        your: ""
-      }
-    };
-  },
+	export default {
+		data() {
+			return {
+				username: {
+					your: ""
+				}
+			};
+		},
 
 
-  components: {
-    chat
-  },
-  props: {},
-  // options = 系统传入的 url 参数
-  onLoad(options) {
-	  console.log('options>>>',options)
-    let username = JSON.parse(options.username);
-    this.setData({
-      username: username
-    });
-	// 生成的支付宝小程序在onLoad里获取不到,这里放到全局变量下
-	uni.username = username;
-    uni.setNavigationBarTitle({
-      title: username?.yourNickName || username?.your
-    });
-  },
+		components: {
+			chat
+		},
+		props: {},
+		// options = 系统传入的 url 参数
+		onLoad(options) {
+			console.log('options>>>', options)
+			let username = JSON.parse(options.username);
+			this.setData({
+				username: username
+			});
+			// 生成的支付宝小程序在onLoad里获取不到,这里放到全局变量下
+			uni.username = username;
 
 
-  onUnload(options) {
-    disp.fire("em.chatroom.leave");
-  },
+			var userNameText = username.your;
+			const imUserInfo = uni.getStorageSync("imUserInfo_" + username.your);
+			if (imUserInfo && imUserInfo.nickName) {
+				userNameText = imUserInfo.nickName;
+			}
+			uni.setNavigationBarTitle({
+				title: userNameText
+			});
+		},
 
 
-  onPullDownRefresh: function () {
-    uni.showNavigationBarLoading();
-    this.$refs.chat.getMore();
-    // 停止下拉动作
-    uni.hideNavigationBarLoading();
-    uni.stopPullDownRefresh();
-  },
-  methods: {
-	  onClickMsg(msg){
-		msg.action = 'join'
-		uni.navigateTo({
-			url: "../emedia/index?srcData="+JSON.stringify(msg)
-		});
-	  },
-    onNavigationBarButtonTap(e) {
-      uni.navigateTo({
-          url: `/pages/moreMenu/moreMenu?username=${this.username.your}&type=singleChat`
-      })
-  },
-  }
-};
+		onUnload(options) {
+			disp.fire("em.chatroom.leave");
+		},
+
+		onPullDownRefresh: function() {
+			uni.showNavigationBarLoading();
+			this.$refs.chat.getMore();
+			// 停止下拉动作
+			uni.hideNavigationBarLoading();
+			uni.stopPullDownRefresh();
+		},
+		methods: {
+			onClickMsg(msg) {
+				msg.action = 'join'
+				uni.navigateTo({
+					url: "../emedia/index?srcData=" + JSON.stringify(msg)
+				});
+			},
+			onNavigationBarButtonTap(e) {
+				uni.navigateTo({
+					url: `/pages/moreMenu/moreMenu?username=${this.username.your}&type=singleChat`
+				})
+			},
+		}
+	};
 </script>
 </script>
 <style>
 <style>
-@import "./chatroom.css";
+	@import "./chatroom.css";
 </style>
 </style>