Explorar o código

增加初始化状态显示

xsx hai 1 ano
pai
achega
7bc22c0cc2

+ 2 - 0
im-uniapp/App.vue

@@ -9,6 +9,7 @@ import UNI_APP from '@/.env.js'
 export default {
 	data() {
 		return {
+			isInit: false, // 是否已经初始化
 			isExit: false, // 是否已退出
 			audioTip: null,
 			reconnecting: false // 正在重连标志
@@ -21,6 +22,7 @@ export default {
 			this.loadStore().then(() => {
 				// 初始化websocket
 				this.initWebSocket();
+				this.isInit = true;
 			}).catch((e) => {
 				console.log(e);
 				this.exit();

+ 10 - 6
im-uniapp/components/chat-item/chat-item.vue

@@ -42,8 +42,15 @@ export default {
 		}
 	},
 	methods: {
-
 		showChatBox() {
+			// 初始化期间进入会话会导致消息不刷新
+			if(!getApp().$vm.isInit || this.chatStore.isLoading()){
+				uni.showToast({
+					title: "正在初始化页面,请稍后...",
+					icon: 'none'
+				})
+				return;
+			}
 			uni.navigateTo({
 				url: "/pages/chat/chat-box?chatIdx=" + this.index
 			})
@@ -155,7 +162,8 @@ export default {
 			font-size: $im-font-size-smaller;
 			color: $im-text-color-lighter;
 			padding-top: 8rpx;
-
+			align-items: center;  
+			
 			.chat-at-text {
 				color: $im-color-danger;
 			}
@@ -170,10 +178,6 @@ export default {
 				overflow: hidden;
 				text-overflow: ellipsis;
 
-				img {
-					width: 40rpx !important;
-					height: 40rpx !important;
-				}
 			}
 
 		}

+ 19 - 8
im-uniapp/pages/chat/chat.vue

@@ -1,14 +1,20 @@
 <template>
 	<view class="tab-page">
-		<nav-bar search @search="showSearch = !showSearch">消息</nav-bar>
+		<nav-bar search @search="onSearch()">消息</nav-bar>
 		<view v-if="loading" class="chat-loading">
 			<loading :size="50" :mask="false">
 				<view>消息接收中...</view>
 			</loading>
 		</view>
+		<view v-if="initializing" class="chat-loading">
+			<loading :size="50" :mask="false">
+				<view>正在初始化...</view>
+			</loading>
+		</view>
 		<view class="nav-bar" v-if="showSearch">
 			<view class="nav-search">
-				<uni-search-bar radius="100" v-model="searchText" cancelButton="none" placeholder="搜索"></uni-search-bar>
+				<uni-search-bar focus="true" radius="100" v-model="searchText" cancelButton="none"
+					placeholder="搜索"></uni-search-bar>
 			</view>
 		</view>
 		<view class="chat-tip" v-if="!loading && chatStore.chats.length == 0">
@@ -77,6 +83,10 @@ export default {
 			}
 			return !this.searchText || chat.showName.includes(this.searchText)
 		},
+		onSearch() {
+			this.showSearch = !this.showSearch;
+			this.searchText = "";
+		},
 		refreshUnreadBadge() {
 			if (this.unreadCount > 0) {
 				uni.setTabBarBadge({
@@ -86,7 +96,7 @@ export default {
 			} else {
 				uni.removeTabBarBadge({
 					index: 0,
-					complete: () => { }
+					complete: () => {}
 				})
 			}
 		}
@@ -102,7 +112,10 @@ export default {
 			return count;
 		},
 		loading() {
-			return this.chatStore.loadingGroupMsg || this.chatStore.loadingPrivateMsg
+			return this.chatStore.isLoading();
+		},
+		initializing(){
+			return !getApp().$vm.isInit;
 		}
 	},
 	watch: {
@@ -116,7 +129,7 @@ export default {
 }
 </script>
 
-<style scoped lang="scss">
+<style  lang="scss">
 .tab-page {
 	position: relative;
 	display: flex;
@@ -136,9 +149,7 @@ export default {
 		width: 100%;
 		height: 120rpx;
 		background: white;
-		position: fixed;
-		top: 0;
-		z-index: 999;
+
 		color: $im-text-color-lighter;
 
 		.loading-box {