Home.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <style lang="scss">
  2. @import '../style/home.scss';
  3. .siteTitle{
  4. width:300px;
  5. margin:0 auto;
  6. }
  7. .el-badge__content.is-fixed{
  8. top:10px;
  9. }
  10. .el-badge:hover{
  11. cursor: pointer;
  12. }
  13. .el-dropdown{
  14. font-size: 18px;
  15. }
  16. .notification-header-01 {
  17. width: 15px;
  18. height: 40px;
  19. line-height: 40px;
  20. text-align: center;
  21. background: rgba(31,93,234,1);
  22. cursor: pointer;
  23. i{
  24. color:white;
  25. }
  26. }
  27. .notificationTitle{
  28. position: absolute;
  29. top:16px;
  30. left:25px;
  31. }
  32. .item:first-child{
  33. border-top: 1px solid rgba(232,233,235,1);
  34. }
  35. .item{
  36. padding:15px;
  37. border-bottom: 1px solid rgba(232,233,235,1);
  38. h4{
  39. padding:5px 0px;
  40. }
  41. .desc{
  42. word-break: break-all;
  43. font-size: 12px;
  44. font-weight: 400;
  45. color: rgba(107,121,142,1);
  46. line-height: 20px;
  47. overflow: hidden;
  48. display: -webkit-box;
  49. -webkit-line-clamp: 2;
  50. -webkit-box-orient: vertical;
  51. }
  52. }
  53. .item:hover{
  54. cursor: pointer;
  55. }
  56. </style>
  57. <template>
  58. <el-container>
  59. <el-header>
  60. <div class="header">
  61. <img class="logo" src="../assets/logo.png" alt="">
  62. <div class="siteTitle">中科院期刊微信公众号集中管理平台</div>
  63. </div>
  64. <div class="nav">
  65. <router-link v-for='(item,index) in inDate' :key='index' :class="item.act?'active':''" :to="item.to" @click.native='active(index)'>
  66. {{item.name}}
  67. </router-link>
  68. <div class="setting">
  69. <div style="display:inline-block;" @click="drawer=true">
  70. <el-badge :value="notices.length">
  71. <i class="el-icon-message-solid" style="font-size:22px;"></i>
  72. </el-badge>
  73. </div>
  74. <el-dropdown>
  75. <span class="el-dropdown-link">
  76. {{info.name}}<i class="el-icon-arrow-down el-icon--right"></i>
  77. </span>
  78. <el-dropdown-menu slot="dropdown" >
  79. <el-dropdown-item>修改密码</el-dropdown-item>
  80. </el-dropdown-menu>
  81. </el-dropdown>
  82. <span class="logout" @click="logout">退出登陆</span>
  83. </div>
  84. </div>
  85. </el-header>
  86. <el-container class="main">
  87. <!-- 左侧菜单 -->
  88. <el-aside class="left-aside" width="210px">
  89. <el-menu background-color='#ffffff' text-color='#666666' :unique-opened='false' :default-active="'/'+ $route.path.split('/')[1]+'/'+ $route.path.split('/')[2]" router class="left-menue" active-text-color="#3895FE">
  90. <template v-for="(item, index) in $router.options.routes" >
  91. <el-menu-item v-if='item.show&&item.isLeaf' :index="item.path" :key='index'>
  92. <i :class="item.icon"></i>
  93. <span slot="title">{{item.name}}</span>
  94. </el-menu-item>
  95. <!-- <el-submenu v-if='item.show&&!item.isLeaf' :index="'index_'+index" :key='index'>
  96. <template slot="title" >
  97. <i :class="item.icon"></i>
  98. <span>{{item.name}}</span>
  99. </template>
  100. <el-menu-item-group>
  101. <el-menu-item class="child" v-for="(child,idx) in item.children" :key="index+'_'+idx" :index="child.path" v-show='!child.hide'>
  102. {{child.name}}
  103. </el-menu-item>
  104. </el-menu-item-group>
  105. </el-submenu> -->
  106. </template>
  107. </el-menu>
  108. </el-aside>
  109. <!-- 右侧内容 -->
  110. <el-container>
  111. <el-main>
  112. <transition name="fade" mode="out-in">
  113. <router-view :info='info' :community='community' v-if='isShow'></router-view>
  114. </transition>
  115. </el-main>
  116. <!-- <el-footer>Footer</el-footer> -->
  117. </el-container>
  118. </el-container>
  119. <!-- 消息弹窗 -->
  120. <el-drawer
  121. title="消息中心"
  122. :withHeader="false"
  123. :visible.sync="drawer"
  124. direction="rtl"
  125. size="15%"
  126. :wrapperClosable="true"
  127. >
  128. <div style="position:relative;padding:10px 0px;">
  129. <div class="notification-header notification-header-01" id="closeNotification" @click="drawer=false">
  130. <i class="el-icon-arrow-right"></i>
  131. </div>
  132. <h3 class="notificationTitle">消息中心</h3>
  133. </div>
  134. <div class="nitification-container">
  135. <div class="item" v-for="(item,index) in info.notices" :key="index" @click='$router.push({path:"/message/message/detail",query:{id:item.id}})'>
  136. <h4>{{item.name}}</h4>
  137. <p v-html="item.content" class="desc">{{item.content}}</p>
  138. <p style="font-size:12px;color: rgba(107,121,142,1);text-align:right;">{{item.ctime}}</p>
  139. </div>
  140. </div>
  141. </el-drawer>
  142. </el-container>
  143. </template>
  144. <script>
  145. import Router from 'vue-router'
  146. export default {
  147. name: 'home',
  148. watch:{
  149. $route(to,from){
  150. let mod = to.path.split("/")[1];
  151. this.$router.options.routes.forEach((element,i) => {
  152. if(element.path.indexOf(mod)==-1){
  153. element.show = 0
  154. }else{
  155. element.show = 1
  156. }
  157. });
  158. }
  159. },
  160. data() {
  161. return {
  162. inDate:"",
  163. checkedCompany:'',
  164. menuList:[],
  165. path:'',
  166. info:{notices:[]},
  167. community_list:[],
  168. community:{},
  169. menu:[],
  170. now:(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString(),
  171. isShow:true,
  172. drawer:false,
  173. notices:[]
  174. };
  175. },
  176. methods: {
  177. handleClose(){
  178. },
  179. getDate(){
  180. this.now=(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
  181. },
  182. logout(){
  183. this.$api.logout().then(res=>{
  184. // this.$router.push({path:'/login'})
  185. this.$router.push({path:'/'})
  186. })
  187. },
  188. permission(name){
  189. let permissions=this.info.permissions||[];
  190. if(permissions.indexOf(name)<0){
  191. return false;
  192. }else{
  193. return true;
  194. }
  195. },
  196. getData(){
  197. let _this = this
  198. this.$api.getAccountInfo().then(res=>{
  199. if(!res.code){
  200. localStorage.setItem('role',res.data.data.role_id)
  201. _this.info = res.data.data;
  202. _this.resetSetItem('watchStorage', JSON.stringify(res.data.data.notices));
  203. _this.initNav()
  204. }
  205. })
  206. },
  207. active(i){
  208. this.initNav()
  209. let that = this;
  210. that.inDate.forEach( (item,index,arr) => {
  211. if(i != index) return item.act = false;
  212. item.act = true;
  213. })
  214. },
  215. initNav(){
  216. let data = [
  217. { act: true, to: '/index/index', name: '首页' },
  218. { act: false, to: '/journal/journal', name: '群刊导览' },
  219. { act: false, to: '/learning/activity', name: '学术交流' },
  220. { act: false, to: '/article/article', name: '精品导读' },
  221. { act: false, to: '/conference/conference', name: '会议系统' },
  222. { act: false, to: '/message/message', name: '信息管理' },
  223. { act: false, to: '/system/account', name: '系统管理' },
  224. ];
  225. let mod = this.$route.path.split("/")[1];
  226. this.$router.options.routes.forEach((element,i) => {
  227. if(element.path.indexOf(mod)==-1){
  228. element.show = 0
  229. }else{
  230. if(this.permission(element.name)){
  231. element.show = 1
  232. }else{
  233. element.show = 0
  234. }
  235. }
  236. // if(this.permission(element.name)){
  237. // element.show = 1
  238. // }else{
  239. // element.show = 0
  240. // }
  241. });
  242. let navs = []
  243. data.forEach(item =>{
  244. // if(mod == item.to.split("/")[1]) return item.act = true;
  245. // item.act = false;
  246. if(this.permission(item.name)){
  247. navs.push(item)
  248. }
  249. })
  250. this.inDate = navs;
  251. },
  252. },
  253. created(){
  254. this.getData()
  255. },
  256. mounted(){
  257. window.addEventListener('setItem', ()=> {
  258. this.notices = JSON.parse(localStorage.getItem('watchStorage'))
  259. })
  260. }
  261. };
  262. </script>