liujq 3 years ago
parent
commit
5b8c540f56

File diff suppressed because it is too large
+ 0 - 0
dist/index.html


File diff suppressed because it is too large
+ 0 - 0
dist/static/css/app.6b220e8f.css


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.17436565.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/app.4c072cd5.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-3f16517a.ea9d5912.js


File diff suppressed because it is too large
+ 0 - 0
dist/static/js/chunk-43338aec.2d55f894.js


+ 3 - 0
src/api/base.js

@@ -86,4 +86,7 @@ export default {
   admtargetname: params => { // 目标名称 获取楼盘、学校名
     return getRequestNoSort('/adm/target/name', params, 'loading')
   },
+  admnotifycount: params => { // 后台通知数量
+    return getRequestNoSort('/adm/notify/count', params, 'loading')
+  },
 }

+ 37 - 24
src/layout/components/Navbar.vue

@@ -6,33 +6,12 @@
 
     <div class="right-menu">
       <div class="xl-form" style="padding-right: 20px;">
+        <span class="scoped-op3" v-if="notifyObj.obj.question > 0 || notifyObj.obj.answer > 0" @click="qaHandle">问答待审核{{notifyObj.obj.question}}/{{notifyObj.obj.answer}}</span>
         <span class="scoped-op" @click="cashUpdate">更新缓存</span>
         <span class="scoped-op2" @click="openPwdPopup">修改密码</span>
         <span class="scoped-user">{{sysUser.nickname}}</span>
         <el-button icon="el-icon-user" class="xl-form-btn t4 xs" @click="logout">退出</el-button>
       </div>
-      <!-- <el-dropdown class="avatar-container" trigger="click">
-        <div class="avatar-wrapper">
-          <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
-          <i class="el-icon-caret-bottom" />
-        </div>
-        <el-dropdown-menu slot="dropdown" class="user-dropdown">
-          <router-link to="/">
-            <el-dropdown-item>
-              Home
-            </el-dropdown-item>
-          </router-link>
-          <a target="_blank" href="https://github.com/PanJiaChen/vue-admin-template/">
-            <el-dropdown-item>Github</el-dropdown-item>
-          </a>
-          <a target="_blank" href="https://panjiachen.github.io/vue-element-admin-site/#/">
-            <el-dropdown-item>Docs</el-dropdown-item>
-          </a>
-          <el-dropdown-item divided @click.native="logout">
-            <span style="display:block;">退出</span>
-          </el-dropdown-item>
-        </el-dropdown-menu>
-      </el-dropdown> -->
     </div>
     <pwd-edit
       :isShow="isPwdShow"
@@ -57,14 +36,25 @@ export default {
       'sidebar',
       'avatar',
       'sysUser',
+      'sysUser',
+      'notifyObj',
     ])
   },
   data () {
     return {
-      isPwdShow: false
+      isPwdShow: false,
     }
   },
+  created () {
+    this.getNotify()
+  },
   methods: {
+    qaHandle () {
+      this.$router.push('/qa/index')
+    },
+    getNotify () {
+      this.$store.dispatch('user/getNotify')
+    },
     closePwdPopup () {
       this.isPwdShow = false
     },
@@ -201,5 +191,28 @@ export default {
   text-decoration: underline;
   cursor: pointer;
 }
-
+.scoped-op3 {
+  display: inline-block;
+  vertical-align: middle;
+  font-weight: bold;
+  color: #19be6b;
+  padding-right: 20px;
+  font-size: 14px;
+  cursor: pointer;
+  animation: animate 0.5s linear infinite;
+}
+@keyframes animate {
+  0%, 100% {
+    text-shadow: -1.5px -1.5px 0 #0ff, 1.5px 1.5px 0 #f00;
+  }
+  25% {
+    text-shadow: 1.5px 1.5px 0 #0ff, -1.5px -1.5px 0 #f00;
+  }
+  50% {
+    text-shadow: 1.5px -1.5px 0 #0ff, 1.5px -1.5px 0 #f00;
+  }
+  75% {
+    text-shadow: -1.5px 1.5px 0 #0ff, -1.5px 1.5px 0 #f00;
+  }
+} 
 </style>

+ 1 - 0
src/store/getters.js

@@ -7,5 +7,6 @@ const getters = {
   sysDomain: state => state.user.sysDomain,
   sysUser: state => state.user.sysUser,
   menuData: state => state.user.menuData,
+  notifyObj: state => state.user.notifyObj,
 }
 export default getters

+ 18 - 1
src/store/modules/user.js

@@ -8,6 +8,8 @@ import {
   setStorageUser,
   getStorageMenu,
   setStorageMenu,
+  getNotify,
+  setNotify,
 } from '@/utils/auth'
 
 const getDefaultState = () => {
@@ -17,6 +19,7 @@ const getDefaultState = () => {
     sysUser: getStorageUser(),
     dictData: getStorageDict(),
     menuData: getStorageMenu(),
+    notifyObj: getNotify(),
   }
 }
 
@@ -40,7 +43,10 @@ const mutations = {
   },
   MENU_DATA: (state, menuData) => {
     state.menuData = menuData
-  }
+  },
+  NOTIFY_OBJ: (state, notifyObj) => {
+    state.notifyObj = notifyObj
+  },
 }
 
 const actions = {
@@ -77,6 +83,17 @@ const actions = {
       })
     })
   },
+  getNotify({ commit }) {
+    return new Promise((resolve, reject) => {
+      Vue.$api.base.admnotifycount().then(res => {
+        setNotify({obj: res, t: +new Date()})
+        commit('NOTIFY_OBJ', {obj: res, t: +new Date()})
+        resolve()
+      }).catch(error => {
+        reject(error)
+      })
+    })
+  },
   getDict({ commit }) {
     return new Promise((resolve, reject) => {
       Vue.$api.base.admdicttree().then(res => {

+ 8 - 0
src/utils/auth.js

@@ -31,3 +31,11 @@ export function getStorageMenu() {
 export function setStorageMenu(data) {
   return window.sessionStorage.setItem('fp_menu', JSON.stringify(data))
 }
+
+
+export function getNotify() {
+  return window.sessionStorage.getItem('fp_notify') ? JSON.parse(window.sessionStorage.getItem('fp_notify')) : {}
+}
+export function setNotify(data) {
+  return window.sessionStorage.setItem('fp_notify', JSON.stringify(data))
+}

+ 8 - 1
src/utils/request.js

@@ -2,7 +2,8 @@ import axios from 'axios'
 import qs from 'qs'
 import { MessageBox, Message, Loading } from 'element-ui'
 import { noEmpty } from './index.js'
-// import store from '@/store'
+import store from '@/store'
+let notifyTimer = null
 // import { getToken } from '@/utils/auth'
 let loadingInit = null
 // create an axios instance
@@ -63,6 +64,12 @@ service.interceptors.response.use(
    * You can also judge the status by HTTP Status Code
    */
   response => {
+    const { notifyObj } = store.getters
+    if (notifyObj) {
+      if (+new Date() - notifyObj.t > 1000 * 60 * 2) {
+        store.dispatch('user/getNotify')
+      }
+    }
     const res = response.data
     if (loadingInit) loadingInit.close()
     if (res.errno !== 0) {

+ 1 - 0
src/views/qa/index.vue

@@ -106,6 +106,7 @@ export default {
         question_id: row.id
       }).then(data => {
         this.$msgs(`已显示!`)
+        this.$store.dispatch('user/getNotify')
         this.fetchData()
       })
     },

+ 1 - 0
src/views/qa/index2.vue

@@ -75,6 +75,7 @@ export default {
         answer_id: row.answer_id
       }).then(data => {
         this.$msgs(`已显示!`)
+        this.$store.dispatch('user/getNotify')
         this.fetchData()
       })
     },

Some files were not shown because too many files changed in this diff