NavBarNoSearch.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <el-row class="el-menu-demo">
  3. <el-col :md="2">
  4. <ul role="menubar" class="el-menu--horizontal el-menu">
  5. <li role="menuitem" class="el-menu-item">
  6. <a href="/" style="color: #007bff;text-decoration-line: none">
  7. <img src="@/assets/img/icon/logo.png" class="logo" alt="img">
  8. tfapp
  9. </a>
  10. </li>
  11. </ul>
  12. </el-col>
  13. <el-col :md="8">
  14. <ul class="el-menu--horizontal el-menu">
  15. <li class="el-menu-item">
  16. <el-dropdown v-if="user">
  17. <img
  18. :src="user.avatarUrl"
  19. class="el-avatar--circle el-avatar--medium"
  20. alt=""
  21. >
  22. <el-dropdown-menu v-if="user" slot="dropdown" class="iconsize">
  23. <el-dropdown-item
  24. icon="el-icon-s-home"
  25. class="size"
  26. @click.native="goToUserHome"
  27. >我的主页</el-dropdown-item>
  28. <el-dropdown-item
  29. icon="el-icon-collection"
  30. class="size"
  31. @click.native="goToPlaylist"
  32. >播放列表</el-dropdown-item>
  33. <el-dropdown-item
  34. icon="el-icon-s-data"
  35. class="size"
  36. @click.native="goToHistory"
  37. >历史记录
  38. </el-dropdown-item>
  39. <el-dropdown-item
  40. icon="el-icon-menu"
  41. class="size"
  42. @click.native="goToBackground"
  43. >进入后台</el-dropdown-item>
  44. <el-dropdown-item
  45. icon="el-icon-error"
  46. class="size"
  47. @click.native="goToLogout"
  48. >登出</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. <span
  52. v-else
  53. style="color: #007bff"
  54. @click="login"
  55. >登入</span>
  56. </li>
  57. <li class="el-menu-item" @click="goToTimeline">
  58. <el-badge class="item" :value="statusCount" :max="99">
  59. <span class="el-icon-view" style="color: #007bff">状态</span>
  60. </el-badge>
  61. </li>
  62. <li class="el-menu-item" @click="goToMessage">
  63. <el-badge class="item" :value="msgCount" :max="99">
  64. <span class="el-icon-bell" style="color: #007bff">消息</span>
  65. </el-badge>
  66. </li>
  67. </ul>
  68. </el-col>
  69. </el-row>
  70. </template>
  71. <script>
  72. import { userMixin } from 'assets/js/mixin'
  73. import { getAuthedUser } from '@/utils/auth'
  74. import { getUnreadCount } from '@/api/user'
  75. export default {
  76. name: 'NavBar',
  77. mixins: [userMixin],
  78. data() {
  79. return {
  80. user: null,
  81. activeIndex: '1',
  82. restaurants: [],
  83. searchType: '1',
  84. keyword: '',
  85. statusCount: 0,
  86. msgCount: 0
  87. }
  88. },
  89. created() {
  90. /* const userdata = Vue.$cookies.get('USERDATA')
  91. const userId = userdata.split(':')[0]*/
  92. const userInfo = getAuthedUser()
  93. if (userInfo !== null) {
  94. this.user = userInfo
  95. getUnreadCount().then(resp => {
  96. if (resp.code === 0) {
  97. this.msgCount = resp.data.total
  98. }
  99. })
  100. }
  101. },
  102. methods: {
  103. login() {
  104. const path = '/login'
  105. if (this.$route.path === path) {
  106. this.$router.go(0)
  107. return
  108. }
  109. this.$router.push(path)
  110. },
  111. register() {
  112. console.log('帐号注册')
  113. },
  114. // ****************************************************************************************************************
  115. goToUserHome() {
  116. const path = '/user/' + this.user.userIdStr
  117. if (this.$route.path === path) {
  118. this.$router.go(0)
  119. return
  120. }
  121. this.$router.push(path)
  122. },
  123. goToPlaylist() {
  124. const path = '/background/my/album'
  125. if (this.$route.path === path) {
  126. this.$router.go(0)
  127. return
  128. }
  129. this.$router.push(path)
  130. },
  131. goToHistory() {
  132. const path = '/background/my/history'
  133. if (this.$route.path === path) {
  134. this.$router.go(0)
  135. return
  136. }
  137. this.$router.push(path)
  138. },
  139. goToBackground() {
  140. const path = '/background'
  141. if (this.$route.path === path) {
  142. this.$router.go(0)
  143. return
  144. }
  145. this.$router.push(path)
  146. },
  147. goToTimeline() {
  148. const path = '/vod/timeline'
  149. if (this.$route.path === path) {
  150. this.$router.go(0)
  151. return
  152. }
  153. this.$router.push(path)
  154. },
  155. goToMessage() {
  156. const path = '/background/my/message'
  157. if (this.$route.path === path) {
  158. this.$router.go(0)
  159. return
  160. }
  161. this.$router.push(path)
  162. },
  163. goToPublish() {
  164. const path = '/background/post/video'
  165. if (this.$route.path === path) {
  166. this.$router.go(0)
  167. return
  168. }
  169. this.$router.push(path)
  170. }
  171. }
  172. }
  173. </script>
  174. <style scoped>
  175. @media screen and (max-width: 768px) {
  176. }
  177. .logo {
  178. width: 30px;
  179. position: relative;
  180. }
  181. .size {
  182. font-size: 16px;
  183. }
  184. .item {
  185. margin-top: 10px;
  186. margin-right: 10px;
  187. }
  188. </style>