|
@@ -1,22 +1,112 @@
|
|
|
-<script setup lang="ts"></script>
|
|
|
+<script setup lang="ts">
|
|
|
+import { ref, onMounted, computed, onUnmounted } from 'vue'
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
+import { GlobalStore } from '@/stores/index'
|
|
|
+import type { TabsPaneContext } from 'element-plus'
|
|
|
+import { User_News_See } from '@/api/user/index'
|
|
|
+
|
|
|
+interface NoticeType {
|
|
|
+ CreateTime: string
|
|
|
+ Id: number
|
|
|
+ T_Tag: number
|
|
|
+ T_Title: string
|
|
|
+ T_Url: string
|
|
|
+ T_uuid: string
|
|
|
+}
|
|
|
+
|
|
|
+let tabs__content: HTMLDivElement
|
|
|
+const router = useRouter()
|
|
|
+const globalStore = GlobalStore()
|
|
|
+const activeName = ref('first')
|
|
|
+const newsList = computed<NoticeType[]>(() => {
|
|
|
+ return globalStore.noticeList
|
|
|
+})
|
|
|
+console.log(newsList.value)
|
|
|
+const handleClick = (tab: TabsPaneContext) => {
|
|
|
+ const { props } = tab
|
|
|
+ globalStore.SET_NoticeList([], true)
|
|
|
+ globalStore.SET_NoticePage(1)
|
|
|
+ switch (props.name) {
|
|
|
+ case 'first':
|
|
|
+ globalStore.SET_User_News_List()
|
|
|
+ break
|
|
|
+ case 'second':
|
|
|
+ globalStore.SET_User_News_List(1)
|
|
|
+ break
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 查看通知消息
|
|
|
+ */
|
|
|
+const previewNotice = async (item: NoticeType) => {
|
|
|
+ router.push(item.T_Url)
|
|
|
+ const res: any = await User_News_See({ User_tokey: globalStore.GET_User_tokey, Id: item.Id })
|
|
|
+ if (res.Code) {
|
|
|
+ ElMessage({
|
|
|
+ type: 'success',
|
|
|
+ message: '确认查看消息!'
|
|
|
+ })
|
|
|
+ newsList.value.filter((notice: NoticeType) => item.Id !== notice.Id)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const ScrollHandle = (e: any) => {
|
|
|
+ const { target } = e
|
|
|
+ if (
|
|
|
+ target.scrollHeight - target.scrollTop === target.clientHeight &&
|
|
|
+ globalStore.noticeTotal !== newsList.value.length
|
|
|
+ ) {
|
|
|
+ console.log('/home')
|
|
|
+ globalStore.SET_NoticePage()
|
|
|
+ globalStore.SET_User_News_List()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ tabs__content = document.querySelector('#home')?.getElementsByClassName('el-tabs__content')[0] as HTMLDivElement
|
|
|
+
|
|
|
+ tabs__content?.addEventListener('scroll', ScrollHandle)
|
|
|
+
|
|
|
+ if (globalStore.noticeList.length <= 0) {
|
|
|
+ globalStore.SET_User_News_List()
|
|
|
+ }
|
|
|
+})
|
|
|
+onUnmounted(() => {
|
|
|
+ console.log('组件销毁')
|
|
|
+ tabs__content.removeEventListener('scroll', ScrollHandle)
|
|
|
+})
|
|
|
+</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="home">
|
|
|
- <!-- <img class="img" src="@/assets/images/1.jpg" /> -->
|
|
|
- <h1>welcome</h1>
|
|
|
- <div class="wrap">
|
|
|
- <ul>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- <li></li>
|
|
|
- </ul>
|
|
|
+ <div class="notice">
|
|
|
+ <h1>消息通知</h1>
|
|
|
+ <el-tabs v-model="activeName" @tab-click="handleClick" id="home">
|
|
|
+ <transition-group
|
|
|
+ appear
|
|
|
+ leave-active-class="animate__animated animate__fadeInLeft"
|
|
|
+ enter-active-class="animate__animated animate__fadeInLeft"
|
|
|
+ >
|
|
|
+ <el-tab-pane label="未读" name="first" key="first">
|
|
|
+ <div class="item" v-for="item in newsList" :key="item.T_uuid" @click="previewNotice(item)">
|
|
|
+ <div class="item-box">
|
|
|
+ <el-badge :value="item.T_Tag === 0 ? 'new' : ''">{{ item.T_Title }}</el-badge>
|
|
|
+ </div>
|
|
|
+ <span>{{ item.CreateTime.split(' ')[0] }}</span>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="全部" name="second" key="second">
|
|
|
+ <div class="item" v-for="item in newsList" :key="item.T_uuid" @click="previewNotice(item)">
|
|
|
+ <div class="item-box">
|
|
|
+ <el-badge :value="item.T_Tag === 0 ? 'new' : ''">{{ item.T_Title }}</el-badge>
|
|
|
+ </div>
|
|
|
+ <span>{{ item.CreateTime.split(' ')[0] }}</span>
|
|
|
+ </div>
|
|
|
+ </el-tab-pane>
|
|
|
+ </transition-group>
|
|
|
+ </el-tabs>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -25,172 +115,58 @@
|
|
|
.home {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
+ padding-top: 50px;
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
- align-items: center;
|
|
|
- h1 {
|
|
|
- z-index: 10;
|
|
|
- font-size: 4rem;
|
|
|
- position: absolute;
|
|
|
- text-shadow: 0px 0px 2px #000;
|
|
|
- }
|
|
|
- .wrap {
|
|
|
- width: 100%;
|
|
|
- height: 20%;
|
|
|
- padding: 40px 0;
|
|
|
- // position: fixed;
|
|
|
- position: relative;
|
|
|
- // top: 50%;
|
|
|
- opacity: 0.8;
|
|
|
- background: linear-gradient(to bottom right, #50a3a2, #53e3a6);
|
|
|
- background: -webkit-linear-gradient(to bottom right, #50a3a2, #53e3a6);
|
|
|
- }
|
|
|
- .wrap ul {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- z-index: -10;
|
|
|
- }
|
|
|
- .wrap ul li {
|
|
|
- list-style-type: none;
|
|
|
- display: block;
|
|
|
- position: absolute;
|
|
|
- bottom: -120px;
|
|
|
- width: 15px;
|
|
|
- height: 15px;
|
|
|
- z-index: -8;
|
|
|
- background-color: rgba(255, 255, 255, 0.15);
|
|
|
- // background: linear-gradient(to bottom right, #50a3a2, #53e3a6);
|
|
|
- // background: -webkit-linear-gradient(to bottom right, #50a3a2, #53e3a6);
|
|
|
- animotion: square 25s infinite;
|
|
|
- -webkit-animation: square 25s infinite;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(1) {
|
|
|
- left: 0;
|
|
|
- animation-duration: 10s;
|
|
|
- -moz-animation-duration: 10s;
|
|
|
- -o-animation-duration: 10s;
|
|
|
- -webkit-animation-duration: 10s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(2) {
|
|
|
- width: 40px;
|
|
|
- height: 40px;
|
|
|
- left: 10%;
|
|
|
- animation-duration: 15s;
|
|
|
- -moz-animation-duration: 15s;
|
|
|
- -o-animation-duration: 15s;
|
|
|
- -webkit-animation-duration: 15s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(3) {
|
|
|
- left: 20%;
|
|
|
- width: 25px;
|
|
|
- height: 25px;
|
|
|
- animation-duration: 12s;
|
|
|
- -moz-animation-duration: 12s;
|
|
|
- -o-animation-duration: 12s;
|
|
|
- -webkit-animation-duration: 12s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(4) {
|
|
|
- width: 50px;
|
|
|
- height: 50px;
|
|
|
- left: 30%;
|
|
|
- -webkit-animation-delay: 3s;
|
|
|
- -moz-animation-delay: 3s;
|
|
|
- -o-animation-delay: 3s;
|
|
|
- animation-delay: 3s;
|
|
|
- animation-duration: 12s;
|
|
|
- -moz-animation-duration: 12s;
|
|
|
- -o-animation-duration: 12s;
|
|
|
- -webkit-animation-duration: 12s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(5) {
|
|
|
- width: 60px;
|
|
|
- height: 60px;
|
|
|
- left: 40%;
|
|
|
- animation-duration: 10s;
|
|
|
- -moz-animation-duration: 10s;
|
|
|
- -o-animation-duration: 10s;
|
|
|
- -webkit-animation-duration: 10s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(6) {
|
|
|
- width: 75px;
|
|
|
- height: 75px;
|
|
|
- left: 50%;
|
|
|
- -webkit-animation-delay: 7s;
|
|
|
- -moz-animation-delay: 7s;
|
|
|
- -o-animation-delay: 7s;
|
|
|
- animation-delay: 7s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(7) {
|
|
|
- left: 60%;
|
|
|
- animation-duration: 8s;
|
|
|
- -moz-animation-duration: 8s;
|
|
|
- -o-animation-duration: 8s;
|
|
|
- -webkit-animation-duration: 8s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(8) {
|
|
|
- width: 90px;
|
|
|
- height: 90px;
|
|
|
- left: 70%;
|
|
|
- -webkit-animation-delay: 4s;
|
|
|
- -moz-animation-delay: 4s;
|
|
|
- -o-animation-delay: 4s;
|
|
|
- animation-delay: 4s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(9) {
|
|
|
- width: 100px;
|
|
|
- height: 100px;
|
|
|
- left: 80%;
|
|
|
- animation-duration: 20s;
|
|
|
- -moz-animation-duration: 20s;
|
|
|
- -o-animation-duration: 20s;
|
|
|
- -webkit-animation-duration: 20s;
|
|
|
- }
|
|
|
- .wrap ul li:nth-child(10) {
|
|
|
- width: 120px;
|
|
|
- height: 120px;
|
|
|
- left: 90%;
|
|
|
- -webkit-animation-delay: 6s;
|
|
|
- -moz-animation-delay: 6s;
|
|
|
- -o-animation-delay: 6s;
|
|
|
- animation-delay: 6s;
|
|
|
- animation-duration: 30s;
|
|
|
- -moz-animation-duration: 30s;
|
|
|
- -o-animation-duration: 30s;
|
|
|
- -webkit-animation-duration: 30s;
|
|
|
- }
|
|
|
-
|
|
|
- @keyframes square {
|
|
|
- 0% {
|
|
|
- -webkit-transform: translateY(0);
|
|
|
- transform: translateY(0);
|
|
|
+ // align-items: center;
|
|
|
+ .notice {
|
|
|
+ width: 50%;
|
|
|
+ height: 50%;
|
|
|
+ padding: 15px;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ box-shadow: 0px 0px 6px #ccc;
|
|
|
+ .el-tabs {
|
|
|
+ width: 100%;
|
|
|
+ height: calc(100% - 25px);
|
|
|
+ :deep(.el-tabs__content) {
|
|
|
+ padding-top: 10px;
|
|
|
+ height: calc(100% - 80px);
|
|
|
+ overflow-y: scroll;
|
|
|
+ }
|
|
|
}
|
|
|
- 100% {
|
|
|
- bottom: 400px;
|
|
|
- transform: rotate(600deg);
|
|
|
- -webit-transform: rotate(600deg);
|
|
|
- -webkit-transform: translateY(-800);
|
|
|
- transform: translateY(-800);
|
|
|
+ .item {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ padding: 5px 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ justify-content: space-between;
|
|
|
+ &:hover {
|
|
|
+ background-color: #ecf5ff;
|
|
|
+ color: #409eff;
|
|
|
+ }
|
|
|
+ .item-box {
|
|
|
+ width: 80%;
|
|
|
+ .el-badge {
|
|
|
+ max-width: 100%;
|
|
|
+ .item-content {
|
|
|
+ overflow: hidden;
|
|
|
+ white-space: nowrap;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ max-width: 100%;
|
|
|
+ display: inline-block;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ span {
|
|
|
+ white-space: nowrap;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- @-webkit-keyframes square {
|
|
|
- 0% {
|
|
|
- -webkit-transform: translateY(0);
|
|
|
- transform: translateY(0);
|
|
|
- }
|
|
|
- 100% {
|
|
|
- bottom: 400px;
|
|
|
- transform: rotate(600deg);
|
|
|
- -webit-transform: rotate(600deg);
|
|
|
- -webkit-transform: translateY(-800);
|
|
|
- transform: translateY(-800);
|
|
|
- }
|
|
|
+ h1 {
|
|
|
+ font-size: 2rem;
|
|
|
+ margin-bottom: 20px;
|
|
|
}
|
|
|
}
|
|
|
-.img {
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
-}
|
|
|
</style>
|