Преглед на файлове

Merge branch 'pre' of http://git.bjzxtw.org.cn:3000/zxt/admin_home into pre

LiuJ преди 1 седмица
родител
ревизия
ac4c15a415

BIN
src/assets/public/nav/message-empty.png


BIN
src/assets/public/nav/message-goods.png


BIN
src/assets/public/nav/message-news.png


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

@@ -16,21 +16,101 @@
         </el-tooltip>
         <lang-select class="right-menu-item hover-effect" />
       </template> -->
-      <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
-        <div class="avatar-wrapper">
+      <div class="noticeIconBox">
+        <img src="@/assets/public/nav/notice1.png" class="noticeIconImg" @click="showTabs = !showTabs"/>
+        <span class="unreadCount">{{msg.count}}</span>
+        <!-- <img src="@/assets/public/nav/arrowDown.png" class="arrowDown" /> -->
+
+        <div class="noticeTabsBox" v-if="showTabs" ref="noticeTabsBox">
+          <div class="noticeTabsTitleBox">
+            <div :class="{'noticeTabs': true, 'active': tabsIndex == 1}" @click="changeTabs(1)">
+              <div class="noticeTabsItem">
+                资讯
+                <span class="noticeMessageNew" v-if="msg.apply_articale.length > 0"></span>
+              </div>
+            </div>
+            <div :class="{'noticeTabs': true, 'active': tabsIndex == 2}" @click="changeTabs(2)">
+              <div class="noticeTabsItem">
+                商品
+                <span class="noticeMessageNew" v-if="msg.good.length > 0"></span>
+              </div>
+            </div>
+            <!-- <div :class="{'noticeTabs': true, 'active': tabsIndex == 3}" @click="changeTabs(3)">
+              <div class="noticeTabsItem">
+                求职招聘
+                <span class="noticeMessageNew"></span>
+              </div>
+            </div> -->
+          </div>
+          <div class="noticeTabsLinkLine">
+            <div v-if="userType == 10000">
+              <div v-if="tabsIndex == 1" @click="goToPath(1,0)">待审核列表</div>
+              <div v-if="tabsIndex == 2" @click="goToPath(2,0)">待审核列表</div>
+              <div v-if="tabsIndex == 3" @click="goToPath(3,0)">待审核列表</div>
+            </div>
+            <div v-else>
+              <div v-if="tabsIndex == 1" @click="goToPath(1,-1)">资讯列表</div>
+              <div v-if="tabsIndex == 2" @click="goToPath(2,-1)">商品列表</div>
+              <div v-if="tabsIndex == 3" @click="goToPath(3,-1)">求职招聘列表</div>
+            </div>
+          </div>
+          <div class="noticeTabsDataBox" v-if="tabsIndex==1">
+            <div v-if="msg.apply_articale && msg.apply_articale.length > 0">
+              <div class="noticeTabsDataItem" v-for="item in msg.apply_articale" :key="item.id" @click="goToPath(1,item.id)">
+                <div class="noticeTabsDataItemImg newsIcon">
+                  <img src="@/assets/public/nav/message-news.png">
+                </div>
+                <div class="noticeTabsDataItemContent">
+                  <div class="noticeNewsTitle">{{item.title}}</div>
+                  <div class="noticeNewsTime">{{item.updated_at}}</div>
+                </div>
+              </div>
+            </div>
+            <div v-else class="noticeTabsDataItemEmpty">
+              <div class="noticeEmpty">
+                <img src="@/assets/public/nav/message-empty.png">
+              </div>
+              <div class="noticeEmptyText">
+                暂无消息
+              </div>
+            </div>
+          </div>
+          <div class="noticeTabsDataBox" v-if="tabsIndex==2">
+            <div v-if="msg.good && msg.good.length > 0">
+              <div class="noticeTabsDataItem" v-for="item in msg.good" :key="item.id" @click="goToPath(2,item.id)">
+                <div class="noticeTabsDataItemImg newsIcon">
+                  <img src="@/assets/public/nav/message-news.png">
+                </div>
+                <div class="noticeTabsDataItemContent">
+                  <div class="noticeNewsTitle">{{item.name}}</div>
+                  <div class="noticeNewsTime">{{item.updated_at}}</div>
+                </div>
+              </div>
+            </div>
+            <div v-else class="noticeTabsDataItemEmpty">
+              <div class="noticeEmpty">
+                <img src="@/assets/public/nav/message-empty.png">
+              </div>
+              <div class="noticeEmptyText">
+                暂无消息
+              </div>
+            </div>
+          </div>
+          <!-- <div class="noticeTabsDataBox" v-if="tabsIndex==3">
+            
+          </div> -->
+        </div>
+      </div>
 
+      <!--刘剑 --> 
+      <!--<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
+        <div class="avatar-wrapper">
           <div class="avatar-wrapper">
-            <img src="@/assets/public/nav/notice1.png" class="user-notice" style="width: 40px; height: 40px;" />
-            <span class="unread-count">{{ msg.count }}</span>
+            <img src="@/assets/public/nav/notice1.png" class="user-notice" style="width:40px;height:40px;" />
+            <span class="unread-count">{{msg.count}}</span>
             <img src="@/assets/public/nav/arrowDown.png" class="arrowDown" />
           </div>
-          <!-- <span
-            style="display: inline-block; width: 40px; height: 40px; border-radius: 50%; background-color: red; color: white; text-align: center; line-height: 40px; font-size: 12px;"></span> -->
-          <!-- <img src="@/assets/public/nav/arrowDown.png" class="arrowDown"> -->
-          <!--向下按钮-->
-          <!-- <i class="el-icon-caret-bottom" /> -->
         </div>
-
         <el-dropdown-menu slot="dropdown" style="width: 200px;">
           <router-link to="/examine" v-if="msg.apply_articale && msg.apply_articale.length > 0">
             <div class="userMenuDownItem">
@@ -48,7 +128,6 @@
               </el-dropdown-item>
             </div>
           </router-link>
-
           <router-link to="/hall" v-if="msg.chat && msg.chat.length > 0">
             <div class="userMenuDownItem">
               <el-dropdown-item>
@@ -56,7 +135,6 @@
               </el-dropdown-item>
             </div>
           </router-link>
-
           <router-link to="/hall" v-for="item in msg.chat" :key="item.id">
             <div class="userMenuDownItem" style="width: 200px;">
               <el-dropdown-item divided style="width: 200px;">
@@ -67,9 +145,6 @@
               </el-dropdown-item>
             </div>
           </router-link>
-
-
-
           <router-link to="/hall" v-if="msg.chat_group && msg.chat_group.length > 0">
             <div class="userMenuDownItem">
               <el-dropdown-item>
@@ -77,8 +152,6 @@
               </el-dropdown-item>
             </div>
           </router-link>
-
-
           <router-link to="/hall" v-for="item in msg.chat_group" :key="item.id">
             <div class="userMenuDownItem" style="width: 200px;">
               <el-dropdown-item divided style="width: 200px;">
@@ -89,9 +162,10 @@
               </el-dropdown-item>
             </div>
           </router-link>
-
         </el-dropdown-menu>
-      </el-dropdown>
+      </el-dropdown> -->
+
+      <!-- 用户头像和菜单 --> 
       <el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
         <div class="avatar-wrapper">
           <!-- <img src="@/assets/public/nav/notice.png" class="user-notice"> -->
@@ -131,6 +205,7 @@
           </el-dropdown-item>
         </el-dropdown-menu>
       </el-dropdown>
+
     </div>
   </div>
 </template>
@@ -147,6 +222,7 @@ import Search from '@/components/HeaderSearch'
 import axios from 'axios';
 import router, { resetRouter } from '@/router'
 import BASEURL from '@/utils/baseUrl'
+import { getUseType } from '@/utils/auth'
 
 export default {
   components: {
@@ -160,7 +236,10 @@ export default {
   },
   data() {
     return {
-      msg: {}
+      msg: {},
+      userType: '', //用户类型
+      tabsIndex: 1, //显示哪个选项卡
+      showTabs: false //是否显示悬浮菜单
     }
   },
   computed: {
@@ -172,28 +251,27 @@ export default {
   },
   mounted() {
     this.getMsg();
+    //获得用户类型
+    this.userType = getUseType();
+
+    // 添加点击事件监听器
+    document.addEventListener('click', this.handleClickOutside);
+  },
+  beforeDestroy() {
+    // 组件销毁前移除事件监听器
+    document.removeEventListener('click', this.handleClickOutside);
   },
   methods: {
-    getMsg() {
-      this.$store.dispatch('news/getMSG').then(response => {
-        console.log(response);
-        this.msg = response.data;
-        console.log(this.msg);
-      }).catch(error => {
-        console.log(error);
-      });
-    },
+    //0.收缩菜单 start---------------------------------------->
     toggleSideBar() {
       this.$store.dispatch('app/toggleSideBar')
     },
-    // async logout() {
-    //   await this.$store.dispatch('user/logout')
-    //   this.$router.push(`/login?redirect=${this.$route.fullPath}`)
-    // },
+    //0.收缩菜单 end---------------------------------------->
+
+    //1.退出登录 start---------------------------------------->
     logout() {
       //获取 token
       const token = this.getTokenFromCookie();
-
       // 新做的,待替换
       // this.$store.dispatch('user/logoutapi', {token: token}).then(response => {
       //   //重置访问过的路由
@@ -206,7 +284,6 @@ export default {
       //   this.$store.commit("user/LOGOUT");
       //   this.$router.push(`/login`);
       // });
-
       axios.get(BASEURL.WebCLogoutUrl, { params: { token: token } }).then(response => {
         console.log(response);
         this.$store.commit("user/LOGOUT");
@@ -218,6 +295,10 @@ export default {
         this.$message.error(response.message);
       });
     },
+    // async logout() {
+    //   await this.$store.dispatch('user/logout')
+    //   this.$router.push(`/login?redirect=${this.$route.fullPath}`)
+    // },
     getTokenFromCookie() {
       const name = "Admin-Token=";
       const decodedCookie = decodeURIComponent(document.cookie);
@@ -229,7 +310,65 @@ export default {
         }
       }
       return ""; // 如果没有找到 token,返回空字符串
-    }
+    },
+    //1.退出登录 end---------------------------------------->
+
+    //2.通知消息 start---------------------------------------->
+    //2.1 获取通知消息列表
+    getMsg() {
+      this.$store.dispatch('news/getMSG').then(response => {
+        console.log(response);
+        this.msg = response.data;
+        console.log(this.msg);
+      }).catch(error => {
+        console.log(error);
+      });
+    },
+    //2.2 切换
+    changeTabs(index) {
+      this.tabsIndex = index;
+    },
+    //2.3跳转方法
+    goToPath(type,id){
+      //如果id是0 跳转到列表
+      if(id==0){
+        if(type == 1){
+          this.$router.push(`/examine`);
+        }else if(type == 2){
+          this.$router.push(`/goodListApply`);
+        }else if(type == 3){
+          this.$router.push(`/jobHuntingList`);
+        }
+      }else if(id==-1){
+        if(type == 1){
+          this.$router.push(`/articleList`);
+        }else if(type == 2){
+          this.$router.push(`/goodList`);
+        }else if(type == 3){
+          this.$router.push(`/jobHuntingList`);
+        }
+      }else{
+        if(type == 1){
+          this.$router.push(`/creatNews?id=${id}`);
+        }else if(type == 2){
+          this.$router.push(`/addGood?id=${id}`);
+        }else if(type == 3){
+          this.$router.push(`/addJobHunting?id=${id}`);
+        }
+      }
+      this.showTabs = false;
+    },
+    // 添加处理点击外部的方法
+    handleClickOutside(event) {
+      const noticeTabsBox = this.$refs.noticeTabsBox;
+      const noticeIconImg = event.target.closest('.noticeIconImg');
+      
+      // 如果点击的不是通知图标,并且点击的区域不在通知框内,则关闭通知框
+      if (!noticeIconImg && noticeTabsBox && !noticeTabsBox.contains(event.target)) {
+        this.showTabs = false;
+      }
+    },
+    //2.通知消息 end---------------------------------------->
   }
 }
 </script>
@@ -237,7 +376,6 @@ export default {
 <style lang="scss" scoped>
 .navbar {
   height: 60px;
-  overflow: hidden;
   position: relative;
   display: flex;
   align-items: center;
@@ -287,6 +425,9 @@ export default {
     float: right;
     height: 100%;
     line-height: 50px;
+    display: flex;
+    align-items: center;
+    position: relative;
 
     &:focus {
       outline: none;
@@ -345,6 +486,149 @@ export default {
         }
       }
     }
+
+    //通知消息 图标
+    .noticeIconBox {
+      width: 45px;
+      height: 50px;
+      box-sizing: border-box;
+      padding-top: 8px;
+      position: relative;
+      .noticeIconImg {
+        width: 34px;
+        height: 34px;
+        cursor: pointer;
+      }
+      .unreadCount{
+        position: absolute;
+        top: 5px;
+        right: 10px;
+        width: 16px;
+        height: 16px;
+        background: #FF4E4E;
+        font-size: 12px;
+        line-height: 16px;
+        text-align: center;
+        color: #fff;
+        border-radius: 50%;
+      }
+      //通知消息 悬浮菜单
+      .noticeTabsBox {
+        position: absolute;
+        width: 380px;
+        height: 640px;
+        border-radius: 8px;
+        background: #fff;
+        z-index: 999;
+        right: 20px;
+        top: 50px;
+        box-shadow: 0 0 10px 0 rgba(0, 0, 0, 0.15);
+        padding:25px 20px;
+        box-sizing: border-box;
+        .noticeTabsTitleBox {
+          display: flex;
+          align-items: center;
+          border-bottom: 1px solid #E9EDF7;
+          .noticeTabs {
+            height: 41px;
+            border-bottom: 2px solid #fff;
+            margin-right: 40px;
+            display: flex;
+            cursor: pointer;
+            .noticeTabsItem {
+              height: 20px;
+              line-height: 20px;
+              font-size: 16px;
+              position: relative;
+              .noticeMessageNew {
+                width: 5px;
+                height: 5px;
+                border-radius: 50%;
+                background: #FF4E4E;
+                position: absolute;
+                right: -5px;
+                top: 0;
+              }
+            }
+          }
+          .active {
+            border-bottom: 2px solid #5570F1;
+          }
+        }
+        .noticeTabsLinkLine {
+          height: 38px;
+          box-sizing: border-box;
+          font-size: 14px;
+          cursor: pointer;
+          background: #F5F7FB;
+          border:1px solid #E3E8FA;
+          text-align: center;
+          line-height: 38px;
+          border-radius: 8px;
+          margin: 20px 0;
+        }
+        .noticeTabsDataBox {
+          .noticeTabsDataItem {
+            display: flex;
+            align-items: flex-start;
+            cursor: pointer;
+            border-radius: 8px;
+            box-sizing: border-box;
+            padding: 5px 10px;
+            &:hover {
+              background: #F5F7FB;
+            }
+            height: 95px;
+            .noticeTabsDataItemImg {
+              border-radius: 50%;
+              width: 26px;
+              height: 26px;
+              display: flex;
+              align-items: center;
+              justify-content: center;
+              margin-right: 15px;
+              margin-top: 6px;
+            }
+            .newsIcon{
+              background: #BAC5F8;
+            }
+            .noticeTabsDataItemContent{
+              flex: 1;
+              .noticeNewsTitle {
+                font-size: 14px;
+                line-height: 28px;
+                height: 56px;
+                color: #333;
+                overflow: hidden;
+                text-overflow: ellipsis;
+                display: -webkit-box;
+                -webkit-line-clamp: 2;
+                -webkit-box-orient: vertical;
+              }
+              .noticeNewsTime {
+                height: 30px;
+                line-height:30px;
+                font-size: 14px;
+                color:#999;
+              }
+            }
+          }
+          .noticeTabsDataItemEmpty {
+            .noticeEmpty {
+              text-align: center;
+              padding-top: 150px;
+              box-sizing: border-box;
+            }
+            .noticeEmptyText {
+              text-align: center;
+              color: #999;
+              font-size: 14px;
+            }
+          }
+        }
+      }
+    }
+
   }
 }
 

+ 3 - 1
src/permission.js

@@ -3,8 +3,9 @@ import store from './store'
 import { Message } from 'element-ui'
 import NProgress from 'nprogress' // progress bar
 import 'nprogress/nprogress.css' // progress bar style
-import { getToken } from '@/utils/auth' // get token from cookie
+import { getToken,setUserUrl } from '@/utils/auth' // get token from cookie
 import getPageTitle from '@/utils/get-page-title'
+import URL from '@/utils/baseUrl';
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
@@ -66,6 +67,7 @@ router.beforeEach(async(to, from, next) => {
       // other pages that do not have permission to access are redirected to the login page.
       next(`/login?redirect=${to.path}`)
       NProgress.done()
+      setUserUrl(URL.webUrl, 86400)
     }
   }
 })

+ 3 - 3
src/store/modules/user.js

@@ -61,10 +61,10 @@ const mutations = {
     state.avatar = '';
     state.introduction = '';
     removeToken();
-    removUserUrl();
-    resetRouter();
-    removUseType();
     removeExp();
+    //removUserUrl();
+    resetRouter();
+    //removUseType();
     //退出登录跳转回原网站
     window.location.href = "http://" + state.userurl
   }

+ 2 - 1
src/utils/baseUrl.js

@@ -5,10 +5,11 @@ const URL = {
   //baseUrl: 'http://admindev.bjzxtw.org.cn:9501',//测试域名
   //baseUrl: 'http://116.131.8.26:9501',//pre环境ip
   //baseUrl: 'http://adminpre.bjzxtw.org.cn:9501',//pre环境域名
+  webUrl:'adminpre.bjzxtw.org.cn',//管理系统地址,如果用户因为某种原因以外退出,需要一个userurl用于请求接口
   baseUrl: 'http://apipre1.bjzxtw.org.cn:29501',//pre环境域名2
   //baseUrl: 'http://192.168.1.201:9501',//刘佳伟本地环境
   //baseUrl:'http://192.168.1.115:9501',//冯蕊的本地环境
-  // baseUrl: 'http://192.168.1.127:9501',//刘剑的本地环境
+  //baseUrl: 'http://192.168.1.125:9501',//刘剑的本地环境
   //WebsocketUrl: 'ws://192.168.1.201:9506',//刘佳伟 -- websocket地址
   // WebsocketUrl: 'ws://192.168.1.127:9506'//刘剑 -- websocket地址
   //WebsocketUrl: 'ws://183.131.25.186:9506',//测试环境ip -- websocket地址

+ 5 - 2
src/views/login/index.vue

@@ -419,9 +419,12 @@ export default {
                   console.log(res.data.token)
                   this.sendUrlServ()
 
-                  //下面还有一个
+                  //王鹏
                   //window.location.href = 'http://admindev.bjzxtw.org.cn/auth/back_login.php?backurl=' + backurlValue + '&token=' + res.data.token; //dev返回链接
-                  window.location.href = BASEURL.webClogBackUrL + '?backurl=' + backurlValue + '&token=' + res.data.token; //pre返回地址
+                  //刘佳伟
+                  //window.location.href = BASEURL.webClogBackUrL + '?backurl=' + backurlValue + '&token=' + res.data.token; //pre返回地址
+                  //我
+                  window.location.href = backurlValue + '?backurl=' + backurlValue + '&admintoken=' + res.data.token; //pre返回地址
 
                 }else if(res.code!=0&&res.code!=200){
                   this.$message({