top.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. this.$router.push({ path: '/login' });
  50. },
  51. toLogOut() {},
  52. },
  53. };
  54. </script>
  55. <style lang="less" scoped>
  56. .w_1200 {
  57. width: 1200px;
  58. margin: 0 auto;
  59. }
  60. .date {
  61. height: 40px;
  62. line-height: 40px;
  63. color: #fff;
  64. font-size: 16px;
  65. }
  66. .btn {
  67. height: 40px;
  68. line-height: 40px;
  69. color: #fff;
  70. }
  71. .btn .el-link {
  72. color: #fff;
  73. margin: 0 5px;
  74. }
  75. </style>