Home.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <style lang="scss">
  2. @import '../style/home.scss';
  3. </style>
  4. <template>
  5. <el-container>
  6. <el-header>
  7. <div class="header">
  8. <!-- <img class="logo" src="../assets/logo.png" alt=""> -->
  9. 期刊微信公众号管理系统
  10. </div>
  11. <div class="nav">
  12. <!-- <router-link :class="act?'active':''" to="/index/index" @click.native='active(1)'>首页</router-link>
  13. <router-link to="/journal/journal" @click.native='active(2)'>刊群导览</router-link>
  14. <router-link to="/learning/activity" @click.native='active(3)'>学术交流</router-link>
  15. <router-link to="/article/article" @click.native='active(4)'>精品导读</router-link>
  16. <router-link to="/conference/conference" @click.native='active(5)'>会议系统</router-link>
  17. <router-link to="/message/message" @click.native='active(6)'>信息管理</router-link>
  18. <router-link to="/system/account" @click.native='active(7)'>系统管理</router-link> -->
  19. <router-link v-for='(item,index) in inDate' :key='index' :class="item.act?'active':''" :to="item.to" @click.native='active(index)'>
  20. {{item.name}}
  21. </router-link>
  22. <div class="setting">
  23. <i class="el-icon-message-solid"></i>
  24. <el-dropdown>
  25. <span class="el-dropdown-link">
  26. {{info.name}}<i class="el-icon-arrow-down el-icon--right"></i>
  27. </span>
  28. <el-dropdown-menu slot="dropdown">
  29. <el-dropdown-item>修改密码</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. <span class="logout" @click="logout">退出登陆</span>
  33. </div>
  34. </div>
  35. </el-header>
  36. <el-container class="main">
  37. <!-- 左侧菜单 -->
  38. <el-aside class="left-aside" width="210px">
  39. <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">
  40. <template v-for="(item, index) in $router.options.routes" >
  41. <el-menu-item v-if='item.show&&item.isLeaf' :index="item.path" :key='index'>
  42. <i :class="item.icon"></i>
  43. <span slot="title">{{item.name}}</span>
  44. </el-menu-item>
  45. <!-- <el-submenu v-if='item.show&&!item.isLeaf' :index="'index_'+index" :key='index'>
  46. <template slot="title" >
  47. <i :class="item.icon"></i>
  48. <span>{{item.name}}</span>
  49. </template>
  50. <el-menu-item-group>
  51. <el-menu-item class="child" v-for="(child,idx) in item.children" :key="index+'_'+idx" :index="child.path" v-show='!child.hide'>
  52. {{child.name}}
  53. </el-menu-item>
  54. </el-menu-item-group>
  55. </el-submenu> -->
  56. </template>
  57. </el-menu>
  58. </el-aside>
  59. <!-- 右侧内容 -->
  60. <el-container>
  61. <el-main>
  62. <transition name="fade" mode="out-in">
  63. <router-view :info='info' :community='community' v-if='isShow'></router-view>
  64. </transition>
  65. </el-main>
  66. <!-- <el-footer>Footer</el-footer> -->
  67. </el-container>
  68. </el-container>
  69. </el-container>
  70. </template>
  71. <script>
  72. import Router from 'vue-router'
  73. export default {
  74. name: 'home',
  75. watch:{
  76. $route(to,from){
  77. let mod = to.path.split("/")[1];
  78. this.$router.options.routes.forEach((element,i) => {
  79. if(element.path.indexOf(mod)==-1){
  80. element.show = 0
  81. }else{
  82. element.show = 1
  83. }
  84. });
  85. }
  86. },
  87. data() {
  88. return {
  89. inDate:"",
  90. checkedCompany:'',
  91. menuList:[],
  92. path:'',
  93. info:{},
  94. community_list:[],
  95. community:{},
  96. menu:[],
  97. now:(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString(),
  98. isShow:true
  99. };
  100. },
  101. methods: {
  102. getDate(){
  103. this.now=(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
  104. },
  105. logout(){
  106. this.$api.logout().then(res=>{
  107. // this.$router.push({path:'/login'})
  108. this.$router.push({path:'/'})
  109. })
  110. },
  111. // permission(name){
  112. // let permissions=this.info.permissions||[];
  113. // let list=[];
  114. // for(let i=0;i<permissions.length;i++){
  115. // list.push(permissions[i].name)
  116. // }
  117. // if(list.indexOf(name)<0){
  118. // return false;
  119. // }else{
  120. // return true;
  121. // }
  122. // },
  123. getData(){
  124. this.$api.getAccountInfo().then(res=>{
  125. if(!res.code){
  126. this.info = res.data.data
  127. }
  128. })
  129. },
  130. active(i){
  131. let that = this;
  132. that.inDate.forEach( (item,index,arr) => {
  133. if(i != index) return item.act = false;
  134. item.act = true;
  135. })
  136. },
  137. initNav(){
  138. let data = [
  139. { act: true, to: '/index/index', name: '首页' },
  140. { act: false, to: '/journal/journal', name: '刊群导览' },
  141. { act: false, to: '/learning/activity', name: '学术交流' },
  142. { act: false, to: '/article/article', name: '精品导读' },
  143. { act: false, to: '/conference/conference', name: '会议系统' },
  144. { act: false, to: '/message/message', name: '信息管理' },
  145. { act: false, to: '/system/account', name: '系统管理' },
  146. ];
  147. let mod = this.$route.path.split("/")[1];
  148. this.$router.options.routes.forEach((element,i) => {
  149. if(element.path.indexOf(mod)==-1){
  150. element.show = 0
  151. }else{
  152. element.show = 1
  153. }
  154. });
  155. data.forEach(item =>{
  156. if(mod == item.to.split("/")[1]) return item.act = true;
  157. item.act = false;
  158. })
  159. this.inDate = data;
  160. },
  161. },
  162. created(){
  163. this.initNav()
  164. this.getData()
  165. }
  166. };
  167. </script>