|
@@ -4,8 +4,11 @@
|
|
|
<img class="logclass" src="@/assets/images/logo.png" />
|
|
|
</div>
|
|
|
<div class="loginUser" v-if="userStore.userInfo">
|
|
|
- <div style="margin-right: 10px;display: inline-block">
|
|
|
- <van-icon name="envelop-o" size="28" />
|
|
|
+ <div style="margin-right: 10px;display: inline-block" @click="showMessage = true">
|
|
|
+ <van-badge dot v-if="hasNotReadMes">
|
|
|
+ <van-icon name="envelop-o" size="28" />
|
|
|
+ </van-badge>
|
|
|
+ <van-icon name="envelop-o" size="28" v-else />
|
|
|
</div>
|
|
|
<span class="nameSpan">{{ userStore.userInfo.name }}</span>
|
|
|
<svg @click="logout()" t="1748245580960" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5746" width="28" height="28">
|
|
@@ -21,6 +24,23 @@
|
|
|
/>
|
|
|
</svg>
|
|
|
</div>
|
|
|
+ <van-popup v-model:show="showMessage" round position="bottom" :style="{ height: '80%' }">
|
|
|
+ <div class="control">
|
|
|
+ <div class="button-read" @click="setAllRead()">全部已读</div>
|
|
|
+ <div class="button-close" @click="showMessage = false">关闭窗口</div>
|
|
|
+ </div>
|
|
|
+ <van-empty v-if="!hasNotReadMes" image="search" description="还没有新消息" />
|
|
|
+ <div class="messageDiv" v-else>
|
|
|
+ <div v-for="item in messages" :key="item.id">
|
|
|
+ <div style="height: 25px">
|
|
|
+ <div class="messageTitle">{{ item.title }}</div>
|
|
|
+ <div class="messageTime">{{ item.created }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="messageContent">{{ item.message }}</div>
|
|
|
+ <van-divider />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </van-popup>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -28,12 +48,19 @@
|
|
|
import { mapStores } from 'pinia';
|
|
|
import { useUserStore } from '@/stores/useUserStore';
|
|
|
import { removeToken } from '@/utils/auth';
|
|
|
+import { showNotify } from 'vant';
|
|
|
+import { notRead, updateRead, allRead } from '@/api/message';
|
|
|
|
|
|
export default {
|
|
|
props: {},
|
|
|
data() {
|
|
|
return {
|
|
|
navBarFixed: false,
|
|
|
+ showMessage: false,
|
|
|
+ // 消息
|
|
|
+ messages: [],
|
|
|
+ // 是否有未读消息
|
|
|
+ hasNotReadMes: false,
|
|
|
};
|
|
|
},
|
|
|
mounted() {
|
|
@@ -43,6 +70,9 @@ export default {
|
|
|
computed: {
|
|
|
...mapStores(useUserStore),
|
|
|
},
|
|
|
+ created() {
|
|
|
+ this.getNotRead();
|
|
|
+ },
|
|
|
methods: {
|
|
|
async logout() {
|
|
|
// 移除token
|
|
@@ -60,6 +90,28 @@ export default {
|
|
|
this.navBarFixed = false;
|
|
|
}
|
|
|
},
|
|
|
+ // 获取未读消息
|
|
|
+ getNotRead() {
|
|
|
+ notRead().then((res) => {
|
|
|
+ this.messages = res.data;
|
|
|
+ if (this.messages.length > 0) {
|
|
|
+ this.hasNotReadMes = true;
|
|
|
+ } else {
|
|
|
+ this.hasNotReadMes = false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 全部已读
|
|
|
+ setAllRead() {
|
|
|
+ if (this.hasNotReadMes) {
|
|
|
+ allRead().then((res) => {
|
|
|
+ if (res.code === 200) {
|
|
|
+ this.getNotRead();
|
|
|
+ showNotify({ type: 'success', message: '请求成功' });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -68,15 +120,15 @@ export default {
|
|
|
.navbarRelative {
|
|
|
width: 100%;
|
|
|
height: 60px;
|
|
|
- position: relative;
|
|
|
- background-color: #F7F8FA;
|
|
|
+ position: relative;
|
|
|
+ background-color: #f7f8fa;
|
|
|
border-bottom: 1px #d7d7d7 solid;
|
|
|
}
|
|
|
|
|
|
.navbarFixed {
|
|
|
width: 100%;
|
|
|
height: 60px;
|
|
|
- background-color: #F7F8FA;
|
|
|
+ background-color: #f7f8fa;
|
|
|
border-bottom: 1px #d7d7d7 solid;
|
|
|
position: fixed;
|
|
|
top: 0;
|
|
@@ -107,4 +159,55 @@ export default {
|
|
|
.nameSpan {
|
|
|
padding-right: 5px;
|
|
|
}
|
|
|
+
|
|
|
+.messageDiv {
|
|
|
+ margin: 10px;
|
|
|
+ max-height: 92.4%;
|
|
|
+ overflow: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.control {
|
|
|
+ margin-top: 10px;
|
|
|
+ margin-bottom: 35px;
|
|
|
+}
|
|
|
+
|
|
|
+.button-read {
|
|
|
+ margin-left: 12px;
|
|
|
+ font-size: 14px;
|
|
|
+ display: inline-block;
|
|
|
+ float: left;
|
|
|
+ color: #1989fa;
|
|
|
+}
|
|
|
+
|
|
|
+.button-close {
|
|
|
+ margin-right: 12px;
|
|
|
+ font-size: 14px;
|
|
|
+ display: inline-block;
|
|
|
+ float: right;
|
|
|
+ color: #1989fa;
|
|
|
+}
|
|
|
+
|
|
|
+.messageTitle {
|
|
|
+ font-weight: bold;
|
|
|
+ margin-bottom: 5px;
|
|
|
+ display: inline-block;
|
|
|
+ float: left;
|
|
|
+ font-size: 14px;
|
|
|
+}
|
|
|
+
|
|
|
+.messageTime {
|
|
|
+ margin-bottom: 5px;
|
|
|
+ display: inline-block;
|
|
|
+ float: right;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #c8c9cc;
|
|
|
+}
|
|
|
+
|
|
|
+.messageContent {
|
|
|
+ width: 100%;
|
|
|
+ margin-bottom: 5px;
|
|
|
+ display: flex;
|
|
|
+ font-size: 13px;
|
|
|
+ color: #ed6a0c;
|
|
|
+}
|
|
|
</style>
|