top.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div id="top">
  3. <el-row>
  4. <el-col :span="24" class="top">
  5. <div class="w_1200">
  6. <el-col :span="22" class="date">
  7. {{ gettime }}
  8. </el-col>
  9. <el-col :span="2" class="btn" v-if="user && user.id"> {{ user.name }} | <el-link :underline="false" @click="toLogOut">注销</el-link> </el-col>
  10. <el-col :span="2" class="btn">
  11. <el-link :underline="false" @click="loginBtn()" target="_blank">注册</el-link>|<el-link :underline="false" @click="loginBtn()" target="_blank"
  12. >登录</el-link
  13. >
  14. </el-col>
  15. </div>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapActions, mapState, createNamespacedHelpers } from 'vuex';
  22. export default {
  23. name: 'top',
  24. props: {},
  25. components: {},
  26. data: () => ({
  27. gettime: '',
  28. }),
  29. created() {
  30. this.currentTime();
  31. },
  32. computed: {
  33. ...mapState(['user']),
  34. },
  35. methods: {
  36. currentTime() {
  37. setInterval(this.getTime, 500);
  38. },
  39. getTime: function() {
  40. var _this = this;
  41. let yy = new Date().getFullYear();
  42. let mm = new Date().getMonth() + 1;
  43. let dd = new Date().getDate();
  44. let day = new Date().getDay();
  45. var weekday = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
  46. _this.gettime = yy + '-' + mm + '-' + dd + ' ' + weekday[day];
  47. },
  48. loginBtn() {
  49. window.location.href = 'http://free.liaoningdoupo.com/platlogin/';
  50. },
  51. toLogOut() {
  52. localStorage.removeItem('token');
  53. this.logout();
  54. window.location.href = 'http://free.liaoningdoupo.com/platlogin/';
  55. },
  56. },
  57. };
  58. </script>
  59. <style lang="less" scoped>
  60. .w_1200 {
  61. width: 1200px;
  62. margin: 0 auto;
  63. }
  64. .date {
  65. height: 40px;
  66. line-height: 40px;
  67. color: #fff;
  68. font-size: 16px;
  69. }
  70. .btn {
  71. height: 40px;
  72. line-height: 40px;
  73. color: #fff;
  74. }
  75. .btn .el-link {
  76. color: #fff;
  77. margin: 0 5px;
  78. }
  79. </style>