ソースを参照

优化登录提示

LinWuTai 18 時間 前
コミット
9f7a4db678
3 ファイル変更32 行追加25 行削除
  1. 4 2
      pages/chat/chat.vue
  2. 22 23
      pages/personalCenter/personalCenter.vue
  3. 6 0
      store/tabbarStore.js

+ 4 - 2
pages/chat/chat.vue

@@ -21,7 +21,7 @@
 		>
 		</u-empty>
 		<view class="list-box">
-			<view class="list-item-box" v-for="item in list" :key="item.id" @click="onChatClick(item)">
+			<view class="list-item-box" v-for="(item, index) in list" :key="item.id" @click="onChatClick(item, index)">
 				<view class="main-box">
 					<view class="content-box">
 						<view class="title">
@@ -109,7 +109,9 @@
 		})
 	}
 	
-	function onChatClick(chat) {
+	function onChatClick(chat, index) {
+		list.value[index].read = true
+		tabbarStore.setMessageCountRead()
 		uni.navigateTo({
 			url: `/pages/chatDetail/chatDetail?id=${chat.id}&title=${chat.title}`
 		})

+ 22 - 23
pages/personalCenter/personalCenter.vue

@@ -400,29 +400,28 @@
 	
 	onLoad(() => {
 		user.value = authStore.userInfo
-		if (isLogin.value) {
-			getCreditCard().then(res => {
-				if (res && res.message === 'success') {
-					creditCard.value = res.data
-					authStore.setCreditCard(res.data)
-				}
-			})
-			getZhongjie().then(res => {
-				if (res && res.message === 'success') {
-					zhongjie.value = res.data ?? {zsbh: null}
-				}
-			})
-			getAnjie().then(res => {
-				if (res && res.message === 'success') {
-					anjie.value = res.data ?? {zsbh: null}
-				}
-			})
-			getIconList().then(res => {
-				if (res && res.message === 'success') {
-					iconList.value = res.data
-				}
-			})
-		}
+		getCreditCard().then(res => {
+			if (res && res.message === 'success') {
+				creditCard.value = res.data
+				authStore.setCreditCard(res.data)
+				
+				getZhongjie().then(res => {
+					if (res && res.message === 'success') {
+						zhongjie.value = res.data ?? {zsbh: null}
+					}
+				})
+				getAnjie().then(res => {
+					if (res && res.message === 'success') {
+						anjie.value = res.data ?? {zsbh: null}
+					}
+				})
+				getIconList().then(res => {
+					if (res && res.message === 'success') {
+						iconList.value = res.data
+					}
+				})
+			}
+		})
 	})
 </script>
 

+ 6 - 0
store/tabbarStore.js

@@ -39,6 +39,12 @@ export const useTabbarStore = defineStore('tabbar', {
 		setMessageCount(count) {
 			this.list[1].count = count
 		},
+		setMessageCountRead() {
+			const count = this.list[1].count
+			if (count > 0) {
+				this.list[1].count = count - 1
+			}
+		},
 		setActiveColor(color) {
 			this.activeColor = color
 		},