index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div class="fx-row fx-bet-cen pl12 pr12 relative" style="line-height: 40px;">
  3. <div v-if="$route.path=='/login'" class="fx-row fx-sta-cen">
  4. <img class="icon16" src="../../assets/images/icon_tel2.png"/>
  5. <span class="pl8">服务热线:400-1797-985</span>
  6. <img class="icon16 ml20" src="../../assets/images/icon_phone.png"/>
  7. <div class="relative" id="app_download" @mouseover="app=true" @mouseleave="app=false">
  8. <a href="javascript:void(0);">APP下载</a>
  9. <div id="appQrcode" v-show="app">
  10. <img style="width:110px;height:110px;" src="../../assets/images/app.png"/>
  11. <p style="width:110px;color:#000;font-size:12px;margin-top:5px;">扫描下载APP</p>
  12. </div>
  13. </div>
  14. <el-link v-if="showPay()" href="/pay" type="warning" class="ml20" underline style="font-size: 16px;">
  15. 在线购卡
  16. </el-link>
  17. </div>
  18. <div v-else class="fx-row fx-sta-cen">
  19. <span @click="$router.push('/')" class="mr20 pointer">首页</span>
  20. <span v-for="(item, index) in visibleMenus" :key="index" class="mr20 pointer"
  21. :class="{'f-primary':item.path == activeMenu}" @click="handleMenuClick(item)">{{ item.meta.title }}</span>
  22. </div>
  23. <div v-if="isLogin" class="fx-row fx-end-cen">
  24. <!--您好!-->
  25. <span style="color:#FFA400;">{{ currentUser.nickName }}{{ currentUser.userName }}
  26. [{{ currentUser.provinceName }} {{ currentUser.schoolName }}]</span>
  27. <!--,欢迎登录铭学百优-->
  28. <el-dropdown v-if="roleList.length > 1" @command="handleRoleExchange">
  29. <span class="el-dropdown-link pointer">[{{ currentRole.roleName }}]</span>
  30. <el-dropdown-menu slot="dropdown">
  31. <el-dropdown-item disabled class="role-change-title">
  32. 角色切换
  33. <i class="el-icon-refresh"></i>
  34. </el-dropdown-item>
  35. <el-dropdown-item v-for="(r,i) in roleList" :key="i" :disabled="r==currentRole" :command="r.roleId"
  36. :divided="i==0">{{ r.roleName }}
  37. </el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. <img class="icon16" :src="currentUser.avatar"/>
  41. <a href="javascript:void(0)" @click="handleGoUserCenter">个人中心</a>
  42. <a style="padding-left:30px;color:#FB731F;" @click="LogOut">退出登录</a>
  43. </div>
  44. </div>
  45. </template>
  46. <script>
  47. import { mapActions, mapGetters } from 'vuex'
  48. import { changeRole } from '@/api/login.js'
  49. import loginCheckMixin from '@/views/index/blocks/index-login-interceptor-mixin'
  50. export default {
  51. mixins: [loginCheckMixin],
  52. data() {
  53. return {
  54. app: false
  55. }
  56. },
  57. computed: {
  58. ...mapGetters(['isLogin', 'currentUser', 'currentRole', 'roleList', 'topbarRouters']),
  59. // 过滤默认不显示的路由当顶部菜单
  60. visibleMenus() {
  61. return this.topbarRouters.filter((m) => !m.hidden)
  62. },
  63. activeMenu() {
  64. return this.$store.getters.activeTopPath
  65. }
  66. },
  67. methods: {
  68. ...mapActions(['LogOut', 'AccessDeepMenu']),
  69. showPay() {
  70. return false // 22.11.21 暂不开放
  71. // return !this.isLogin
  72. },
  73. handleMenuClick(item) {
  74. this.AccessDeepMenu(item)
  75. },
  76. handleRoleExchange(roleId) {
  77. changeRole(roleId).then((_) => {
  78. // IMPORTANT: 此处会触发GetInfo/GetRouters
  79. //window.location.reload();
  80. window.location.href = '/login'
  81. })
  82. },
  83. async handleGoUserCenter() {
  84. await this.loginCheck()
  85. this.$router.push('/user/info/userinfo')
  86. }
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. .page-header-box > .layui-row {
  92. width: 1184px;
  93. margin: 0 auto;
  94. padding: 8px 0;
  95. font-size: 14px;
  96. }
  97. .page-header-box .header-icon {
  98. height: 16px;
  99. vertical-align: middle;
  100. }
  101. img {
  102. border: none;
  103. }
  104. .p-l-small {
  105. padding-left: 8px;
  106. }
  107. .page-header-box .header-left > span {
  108. display: inline-block;
  109. vertical-align: middle;
  110. }
  111. #appQrcode {
  112. background: #fff;
  113. border: 1px solid #cdcdcd;
  114. box-shadow: 0 0 8px #cdcdcd;
  115. border-radius: 3px;
  116. padding: 10px;
  117. position: absolute;
  118. left: 0;
  119. top: 40px;
  120. z-index: 9999;
  121. text-align: center;
  122. }
  123. .pos-r {
  124. position: relative;
  125. }
  126. .m-l {
  127. margin-left: 16px;
  128. }
  129. .color-orange {
  130. color: #47c6a2;
  131. }
  132. .role-change-title {
  133. color: #666666;
  134. font-size: 12px;
  135. font-weight: bold;
  136. }
  137. </style>