瀏覽代碼

feat: MessageCard beta

Damon 4 年之前
父節點
當前提交
ada201cfe0

二進制
src/assets/taskPage.png


+ 3 - 1
src/global/register-element.js

@@ -35,7 +35,7 @@ import {
   ElBacktop,
   ElMenu,
   ElMenuItem,
-  ElSubmenu,
+  ElSubmenu, ElCollapse, ElCollapseItem,
 } from "element-plus";
 
 // NOTE 使用到的组件列表,请确保 import 和 component 的一致性
@@ -77,6 +77,8 @@ const components = [
   ElMenu,
   ElMenuItem,
   ElSubmenu,
+  ElCollapse,
+  ElCollapseItem,
 ];
 
 export default function (app) {

+ 1 - 3
src/views/HomePage/HomePage.vue

@@ -28,18 +28,16 @@
       <CertificationCard v-else/>
     </el-col>
   </el-row>
-  <GlobalFooter/>
 </template>
 
 <script>
-import GlobalFooter from "@/components/GlobalFooter";
 import { Back, Medal, User } from "@element-plus/icons-vue";
 import InformationCard from "@/views/HomePage/components/InformationCard";
 import CertificationCard from "@/views/HomePage/components/CertificationCard";
 
 export default {
   name: "HomePage",
-  components: { Back, CertificationCard, InformationCard, Medal, User, GlobalFooter, },
+  components: { Back, CertificationCard, InformationCard, Medal, User, },
   data() {
     return {
       activeIndex: "1",

+ 67 - 4
src/views/MessagePage/MessagePage.vue

@@ -1,27 +1,90 @@
 <template>
-  <p style="text-align: center; font-weight: bolder; font-size: xxx-large">消息中心</p>
-  {{ myUnReadAnnouncement }}
-  <img alt="err" src="@/assets/messagePage.png" style="width: 100%;">
+  <el-row id="message-page-body">
+    <el-col :span="4">
+      <el-menu background-color="#f8f9fb" default-active="1" @select="handleSelect">
+        <el-menu-item index="0">
+          <el-icon>
+            <Back/>
+          </el-icon>
+          <span style="padding-left: 20px">返回首页</span>
+        </el-menu-item>
+        <el-menu-item index="1">
+          <el-icon>
+            <Bell/>
+          </el-icon>
+          <span style="padding-left: 20px">通知列表</span>
+        </el-menu-item>
+        <el-menu-item index="2">
+          <el-icon>
+            <ChatDotRound/>
+          </el-icon>
+          <span style="padding-left: 20px">消息列表</span>
+        </el-menu-item>
+      </el-menu>
+    </el-col>
+    <el-col :span="1"/>
+    <el-col :span="18">
+      <el-card>
+        <template #header>
+          <span style="font-weight: bold; font-size: larger">
+            {{ title }}
+          </span>
+        </template>
+        <div v-if="this.activeIndex==='1'" class="message-page-main">
+          <MessageCard v-for="i in myUnReadAnnouncement" :key="i.id" :messageVO="i"/>
+        </div>
+        <div v-else>
+
+        </div>
+      </el-card>
+    </el-col>
+  </el-row>
 </template>
 
 <script>
+import { Back, Bell, ChatDotRound } from "@element-plus/icons-vue";
+import MessageCard from "@/views/MessagePage/components/MessageCard";
+
 export default {
   name: "MessagePage",
+  components: { MessageCard, ChatDotRound, Bell, Back },
   data() {
     return {
+      activeIndex: "1",
       myUnReadAnnouncement: [],
     };
   },
-
+  computed: {
+    title() {
+      return this.activeIndex === "1" ? "通知列表" : "消息列表";
+    },
+  },
   created() {
     this.$apis.getUnreadAnnouncements()
       .then(res => {
         this.myUnReadAnnouncement = res.data.data;
       });
   },
+  methods: {
+    handleSelect(index) {
+      this.activeIndex = index;
+      if (index === "0") {
+        this.$router.push("portal");
+      }
+    },
+  },
 };
 </script>
 
 <style scoped>
+#message-page-body {
+  margin: 40px 160px 80px 160px;
+  min-height: calc(100vh - 160px);
+}
 
+.message-page-main {
+  display: grid;
+  grid-template-columns: 1fr;
+  grid-gap: 10px;
+}
 </style>

+ 108 - 0
src/views/MessagePage/components/MessageCard.vue

@@ -0,0 +1,108 @@
+<template>
+  <el-row class="body" @click="this.$router.push('/course/' + jumpLink)">
+    <el-col :span="6" style="display: flex; flex-direction:column; justify-content: space-between">
+      <el-row>
+        <el-tag size="large" type="" v-if="type === 'ANNOUNCEMENT'" class="tag">公告</el-tag>
+        <el-tag size="large" type="success" v-else-if="type === 'HOMEWORK'" class="tag">作业</el-tag>
+        <el-tag size="large" type="warning" v-else-if="type === 'EXAM'" class="tag">考试</el-tag>
+      </el-row>
+      <el-row class="time">
+        {{ time }}
+      </el-row>
+    </el-col>
+    <el-col :span="16" style="display: flex; flex-direction:column; justify-content: space-between">
+      <el-row class="title">
+        {{ title }}
+      </el-row>
+      <el-row class="sender">
+        发布者: {{ sender }}
+      </el-row>
+      <el-row class="content">
+        {{ content }}
+      </el-row>
+    </el-col>
+    <el-col :span="2" style="display: flex; flex-direction:column; justify-content: center">
+      <el-icon :size="20">
+        <ArrowRightBold/>
+      </el-icon>
+    </el-col>
+  </el-row>
+</template>
+
+<script>
+import { ArrowRightBold } from "@element-plus/icons-vue";
+
+export default {
+  name: "MessageCard",
+  components: { ArrowRightBold },
+  props: {
+    messageVO: {
+      type: Object
+    }
+  },
+  data() {
+    return {};
+  },
+  computed: {
+    type() {
+      return this.messageVO.type;
+    },
+    time() {
+      const date = new Date(this.messageVO.createdAt);
+      const Y = date.getFullYear() + "-";
+      const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
+      const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
+      return Y + M + D;
+    },
+    title() {
+      return this.messageVO.title;
+    },
+    sender() {
+      return this.messageVO.sender.name;
+    },
+    content() {
+      return this.messageVO.content.length > 30 ? this.messageVO.content.substring(0, 30) + "..." : this.messageVO.content;
+    },
+    jumpLink() {
+      return this.messageVO.courseId;
+    }
+  },
+};
+</script>
+
+<style scoped>
+.body {
+  height: 90px;
+  border: 1px solid #cccccc;
+  border-radius: 10px;
+  padding: 10px;
+}
+
+.body:hover {
+  background: #e4e7ed;
+  cursor: pointer;
+}
+
+.tag {
+  width: 80px;
+  text-align: center
+}
+
+.time {
+  font-weight: lighter;
+}
+
+.title {
+  font-weight: bold;
+}
+
+.sender {
+  font-size: small;
+  color: #999999;
+}
+
+.content {
+  font-size: small;
+  color: #999999;
+}
+</style>