You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.8 KiB

4 weeks ago
  1. <template>
  2. <!-- 公共头 -->
  3. <header id="header">
  4. <section class="container">
  5. <h1 id="logo">
  6. <a href="#" title="AI 小财神">
  7. <img src="~/assets/img/logo.png" width="80%" height="80%" alt="AI 小财神">
  8. </a>
  9. </h1>
  10. <div class="h-r-nsl">
  11. <ul class="nav">
  12. <router-link to="/home" tag="li" active-class="current" style="font-weight: bold;">
  13. <a>主页</a>
  14. </router-link>
  15. <router-link to="/club" tag="li" active-class="current" style="font-weight: bold;">
  16. <a>博股俱乐部</a>
  17. </router-link>
  18. <router-link to="/" tag="li" active-class="current" exact style="font-weight: bold;">
  19. <a>直播广场</a>
  20. </router-link>
  21. </ul>
  22. </div>
  23. <aside class="mw-nav-btn">
  24. <div class="mw-nav-icon"/>
  25. </aside>
  26. <div class="clear"/>
  27. </section>
  28. </header>
  29. <!-- / -->
  30. </template>
  31. <script>
  32. import loginApi from '~/api/login'
  33. import cookie from 'js-cookie'
  34. export default{
  35. data() {
  36. return {
  37. userInfo: null
  38. }
  39. },
  40. // 登录成功后获取用户信息
  41. created() {
  42. this.getUserInfo()
  43. },
  44. // 页面渲染之后执行
  45. mounted() {
  46. const token = this.$route.query.token
  47. if (token) {
  48. cookie.set('guli_jwt_token', token, { domain: 'localhost' })
  49. window.location.href = '/'
  50. }
  51. },
  52. methods: {
  53. getUserInfo() {
  54. // cookie中token值不存在
  55. if (!cookie.get('guli_jwt_token')) {
  56. return
  57. }
  58. loginApi.getLoginInfo().then(response => {
  59. this.userInfo = response.data.userInfo
  60. })
  61. },
  62. logout() {
  63. // 清除cookie
  64. cookie.set('guli_jwt_token', '', { domain: 'localhost' })
  65. window.location.href = '/'
  66. }
  67. }
  68. }
  69. </script>