top.vue 1.7 KB

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