reghao vor 1 Jahr
Ursprung
Commit
2dfb63bbcf

+ 16 - 1
src/api/user.js

@@ -7,7 +7,10 @@ const userApi = {
   unfollowUserApi: '/api/user/relation/unfollow',
   checkRelationApi: '/api/user/relation/check',
   userFollowerApi: '/api/user/relation/follower',
-  userFollowingApi: '/api/user/relation/following'
+  userFollowingApi: '/api/user/relation/following',
+  unreadMessageApi: '/api/user/message/unread',
+  unreadMessagesApi: '/api/user/message/unread/list',
+  setReadMessageApi: '/api/user/message/read',
 }
 
 export function getUserInfo(userId) {
@@ -39,3 +42,15 @@ export function getUserFollower(userId) {
 export function getUserFollowing(userId) {
   return get(userApi.userFollowingApi + '/' + userId)
 }
+
+export function getUnreadCount() {
+  return get(userApi.unreadMessageApi)
+}
+
+export function getUnreadMessages(page) {
+  return get(userApi.unreadMessagesApi + '?pageNumber=' + page)
+}
+
+export function setReadMessages(messageId) {
+  return post(userApi.setReadMessageApi + '/' + messageId)
+}

+ 4 - 4
src/assets/js/mixin.js

@@ -132,7 +132,7 @@ export const userMixin = {
           this.$message.warning(resp.msg)
         }
       }).catch(error => {
-        this.$message.error(error)
+        this.$message.error(error.message)
       })
     },
     // 昵称校验
@@ -190,7 +190,7 @@ export const userMixin = {
         }
       }).catch(error => {
         // 登录请求错误
-        this.$message.error(error)
+        this.$message.error(error.message)
       }).finally(() => {
         this.isLoading = false
       })
@@ -225,7 +225,7 @@ export const userMixin = {
           this.$message.warning(resp.msg)
         }
       }).catch(error => {
-        this.$message.error(error)
+        this.$message.error(error.message)
       }).finally(() => {
         this.isLoading = false
         this.userRegistry = {
@@ -267,7 +267,7 @@ export const userMixin = {
           this.$message.warning(resp.msg)
         }
       }).catch(error => {
-        this.$message.error(error)
+        this.$message.error(error.message)
       }).finally(() => {
         this.isLoading = false
         this.userForgot = {

+ 2 - 2
src/components/card/SiteNotice.vue

@@ -15,7 +15,7 @@
 </template>
 
 <script>
-import { getSiteNotice } from '@/api/admin'
+import { getSiteNotice } from '@/api/content'
 
 export default {
   name: 'SiteNotice',
@@ -30,7 +30,7 @@ export default {
         this.content = resp.data
       }
     }).catch(error => {
-      this.$message.error(error)
+      this.$message.error(error.message)
     }).finally(() => {
     })
   },

+ 6 - 0
src/components/layout/NavBar.vue

@@ -170,6 +170,7 @@
 import { userMixin } from 'assets/js/mixin'
 import { keywordSuggest } from '@/api/search'
 import { getAuthedUser } from '@/utils/auth'
+import {getUnreadCount} from "@/api/user";
 
 export default {
   name: 'NavBar',
@@ -191,6 +192,11 @@ export default {
     const userInfo = getAuthedUser()
     if (userInfo !== null) {
       this.user = userInfo
+      getUnreadCount().then(resp => {
+        if (resp.code === 0) {
+          this.msgCount = resp.data.total
+        }
+      })
     }
   },
   methods: {

+ 1 - 19
src/router/index.js

@@ -115,16 +115,10 @@ const routes = [
     path: '/my',
     name: 'My',
     component: My,
-    meta: { needAuth: true }
-  },
-  {
-    path: '/my/account',
-    name: 'MyAccount',
-    component: My,
     meta: { needAuth: true },
     children: [
       {
-        path: '/my/account/profile',
+        path: '',
         name: '个人资料',
         component: MyProfile,
         meta: { needAuth: true }
@@ -265,23 +259,11 @@ const routes = [
     component: My,
     meta: { needAuth: true },
     children: [
-      {
-        path: '/my/message/send',
-        name: '发出的消息',
-        component: MessageIndex,
-        meta: { needAuth: true }
-      },
       {
         path: '/my/message/receive',
         name: '收到的消息',
         component: MessageIndex,
         meta: { needAuth: true }
-      },
-      {
-        path: '/my/message/private',
-        name: '私信',
-        component: MessageIndex,
-        meta: { needAuth: true }
       }
     ]
   },

+ 1 - 1
src/views/admin/SiteConfig.vue

@@ -82,7 +82,7 @@ export default {
           this.$message.error(resp.msg)
         }
       }).catch(error => {
-        this.$message.error(error)
+        this.$message.error(error.message)
       }).finally(() => {
       })
     }

+ 2 - 2
src/views/home/Index.vue

@@ -116,7 +116,7 @@ export default {
           )
         }
       }).catch(error => {
-        this.$message.error(error)
+        this.$message.error(error.message)
       }).finally(() => {
       })
     },
@@ -132,7 +132,7 @@ export default {
           this.carouselList = resp.data
         }
       }).catch(error => {
-        this.$message.error(error)
+        this.$message.error(error.message)
       }).finally(() => {
       })
     },

+ 2 - 1
src/views/home/VideoPage.vue

@@ -542,7 +542,8 @@ export default {
           resolve({ newComment, parent })
         }, 300)
       })
-      add(Object.assign(res.newComment, { _id: new Date().getTime() }))
+
+      add(Object.assign(res.newComment, { postId: this.video.videoId }))
       if (res.parent !== null) {
         // console.log('parent: ', res.parent)
       } else {

+ 70 - 0
src/views/my/Calendar.vue

@@ -0,0 +1,70 @@
+<template>
+  <div>
+    <el-row>
+      <el-col :md="20">
+        <el-row>
+          <h2>我的日历</h2>
+        </el-row>
+        <el-row>
+          <calendar-heatmap :max="10" :values="values" :end-date="endDate" />
+        </el-row>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import Vue from 'vue'
+import { CalendarHeatmap } from 'vue-calendar-heatmap'
+import { getHeatmap } from '@/api/im'
+
+Vue.component('calendarHeatmap', CalendarHeatmap)
+export default {
+  name: 'Calendar',
+  data() {
+    return {
+      values: [
+        { date: '2018-9-22', count: 6 },
+        { date: '2018-9-23', count: 5 },
+        { date: '2018-9-24', count: 4 },
+        { date: '2018-9-25', count: 3 },
+        { date: '2018-9-26', count: 2 },
+        { date: '2018-9-27', count: 1 },
+        { date: '2018-9-28', count: 7 },
+        { date: '2018-9-29', count: 8 },
+        { date: '2018-9-30', count: 9 }
+      ],
+      endDate: '2019-10-22'
+    }
+  },
+  created() {
+    const path = this.$route.path
+    var title = '我的消息'
+    if (path.endsWith('/send')) {
+      title = '发出的消息'
+    } else if (path.endsWith('/receive')) {
+      title = '收到的消息'
+    } else if (path.endsWith('/private')) {
+      title = '私信'
+    }
+
+    document.title = title
+    console.log(new Date())
+    getHeatmap().then(resp => {
+      if (resp.code === 0) {
+        this.values = resp.data
+        this.endDate = this.getYearMonthDay()
+      }
+    })
+  },
+  methods: {
+    getYearMonthDay() {
+      const date = new Date()
+      const year = date.getFullYear().toString().padStart(4, '0')
+      const month = (date.getMonth() + 1).toString().padStart(2, '0')
+      const day = date.getDate().toString().padStart(2, '0')
+      return year + '-' + month + '-' + day
+    }
+  }
+}
+</script>

+ 57 - 40
src/views/my/Message.vue

@@ -1,70 +1,87 @@
 <template>
   <div>
-    <el-row>
+    <el-row class="movie-list">
       <el-col :md="20">
         <el-row>
           <h2>我的消息</h2>
         </el-row>
-        <el-row>
-          <calendar-heatmap :max="10" :values="values" :end-date="endDate" />
-        </el-row>
+        <el-card>
+          <el-table
+            :data="dataList"
+            :show-header="true"
+            border
+            style="width: 100%"
+          >
+            <el-table-column
+              prop="title"
+              label="title"
+            />
+            <el-table-column
+              prop="content"
+              label="content"
+            />
+            <el-table-column
+              label="操作"
+            >
+              <template slot-scope="scope">
+                <el-button
+                  size="mini"
+                  @click="cache(scope.row)"
+                >删除</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-card>
       </el-col>
     </el-row>
   </div>
 </template>
 
 <script>
-import Vue from 'vue'
-import { CalendarHeatmap } from 'vue-calendar-heatmap'
-import { getHeatmap } from '@/api/im'
+import {getUnreadMessages, setReadMessages} from "@/api/user";
 
-Vue.component('calendarHeatmap', CalendarHeatmap)
 export default {
   name: 'Message',
   data() {
     return {
-      values: [
-        { date: '2018-9-22', count: 6 },
-        { date: '2018-9-23', count: 5 },
-        { date: '2018-9-24', count: 4 },
-        { date: '2018-9-25', count: 3 },
-        { date: '2018-9-26', count: 2 },
-        { date: '2018-9-27', count: 1 },
-        { date: '2018-9-28', count: 7 },
-        { date: '2018-9-29', count: 8 },
-        { date: '2018-9-30', count: 9 }
-      ],
-      endDate: '2019-10-22'
+      dataList: []
     }
   },
   created() {
-    const path = this.$route.path
-    var title = '我的消息'
-    if (path.endsWith('/send')) {
-      title = '发出的消息'
-    } else if (path.endsWith('/receive')) {
-      title = '收到的消息'
-    } else if (path.endsWith('/private')) {
-      title = '私信'
-    }
+    document.title = '我的消息'
 
-    document.title = title
-    console.log(new Date())
-    getHeatmap().then(resp => {
+    getUnreadMessages(1).then(resp => {
       if (resp.code === 0) {
-        this.values = resp.data
-        this.endDate = this.getYearMonthDay()
+        this.dataList = resp.data
       }
     })
   },
   methods: {
-    getYearMonthDay() {
-      const date = new Date()
-      const year = date.getFullYear().toString().padStart(4, '0')
-      const month = (date.getMonth() + 1).toString().padStart(2, '0')
-      const day = date.getDate().toString().padStart(2, '0')
-      return year + '-' + month + '-' + day
+    cache(row) {
+      setReadMessages(row.messageId).then(resp => {
+        if (resp.code === 0) {
+          this.$message('已处理')
+          this.dataList.pop()
+        }
+      })
     }
   }
 }
 </script>
+
+<style scoped>
+/*处于手机屏幕时*/
+@media screen and (max-width: 768px) {
+  .movie-list {
+    padding-top: 8px;
+    padding-left: 0.5%;
+    padding-right: 0.5%;
+  }
+}
+
+.movie-list {
+  padding-top: 15px;
+  padding-left: 6%;
+  padding-right: 6%;
+}
+</style>

+ 0 - 12
src/views/my/My.vue

@@ -46,10 +46,6 @@
               <span slot="title">帐号管理</span>
             </template>
             <el-menu-item-group>
-              <el-menu-item index="/my/account/profile">
-                <i class="el-icon-film" />
-                <span slot="title">个人资料</span>
-              </el-menu-item>
               <el-menu-item index="/my/account/contact">
                 <i class="el-icon-film" />
                 <span slot="title">联系人</span>
@@ -152,18 +148,10 @@
               <span slot="title">我的消息</span>
             </template>
             <el-menu-item-group>
-              <el-menu-item index="/my/message/send">
-                <i class="el-icon-right" />
-                <span slot="title">发出的消息</span>
-              </el-menu-item>
               <el-menu-item index="/my/message/receive">
                 <i class="el-icon-back" />
                 <span slot="title">收到的消息</span>
               </el-menu-item>
-              <el-menu-item index="/my/message/private">
-                <i class="el-icon-bell" />
-                <span slot="title">私信</span>
-              </el-menu-item>
             </el-menu-item-group>
           </el-submenu>
           <el-submenu index="/my/cam">