index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="main-box">
  3. <div class="scroll-box">
  4. <div v-permission="'dashboard.head'" class="main-card">
  5. <div class="hello-text">{{ getTimeWord() }},{{ user.nickname }}!</div>
  6. <div class="card-content">
  7. <div class="expo-text">
  8. <span v-if="currentExpo">距离{{ currentExpo.expo_name }}结束还有{{ getEndDay(currentExpo.end_date) }}天</span>
  9. <span v-else>没有进行中的展会</span>
  10. </div>
  11. <div class="quick-nav">
  12. <router-link class="nav-item" to="audience">
  13. <span class="icon el-icon-user" />
  14. <span class="text">观众管理</span>
  15. </router-link>
  16. <router-link class="nav-item" to="preRegister">
  17. <span class="icon el-icon-tickets" />
  18. <span class="text">表单管理</span>
  19. </router-link>
  20. <router-link class="nav-item" to="exhibitor">
  21. <span class="icon el-icon-office-building" />
  22. <span class="text">展商管理</span>
  23. </router-link>
  24. <router-link class="nav-item" to="invitation">
  25. <span class="icon el-icon-files" />
  26. <span class="text">模板管理</span>
  27. </router-link>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { getExpoList } from '@/api/expo'
  36. export default {
  37. name: 'Dashboard',
  38. data() {
  39. return {
  40. currentExpo: {}
  41. }
  42. },
  43. computed: {
  44. user() { return this.$store.state.user.user }
  45. },
  46. mounted() {
  47. this.init()
  48. },
  49. methods: {
  50. init() {
  51. getExpoList(1, 20).then(res => {
  52. const expoList = res.data.data
  53. for (const item of expoList) {
  54. if (item.status === 0 && this.getEndDay(item.end_date) >= 0) {
  55. this.currentExpo = item
  56. return
  57. }
  58. }
  59. this.currentExpo = false
  60. }).catch(err => {
  61. })
  62. },
  63. getEndDay(date) {
  64. const endTime = new Date(date)
  65. return Math.ceil((endTime.getTime() - new Date().getTime()) / 86400000)
  66. },
  67. getTimeWord() {
  68. const time = new Date().getHours()
  69. if (time >= 0 && time < 6) return '凌晨好'
  70. if (time >= 6 && time < 9) return '早上好'
  71. if (time >= 9 && time < 12) return '上午好'
  72. if (time >= 12 && time < 14) return '中午好'
  73. if (time >= 14 && time < 17) return '下午好'
  74. if (time >= 17 && time < 19) return '傍晚好'
  75. if (time >= 19 && time < 21) return '晚上好'
  76. return '夜深了'
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped lang="scss">
  82. @use '@/styles/variables.scss' as *;
  83. .main-box {
  84. height: 100%;
  85. width: 100%;
  86. .scroll-box {
  87. padding: 2px;
  88. position: absolute;
  89. width: calc(100% - 32px);
  90. height: calc(100% - 32px);
  91. overflow: hidden;
  92. overflow-y: auto;
  93. .main-card{
  94. background: $menuActiveBg;
  95. padding: 36px 36px 18px;
  96. border-radius: 8px;
  97. .hello-text{
  98. color: $menuActiveText;
  99. font-size: 28px;
  100. font-weight: bold;
  101. }
  102. .card-content{
  103. margin-top: 16px;
  104. display: grid;
  105. grid-template-columns: 1fr 2fr;
  106. .expo-text{
  107. }
  108. .quick-nav{
  109. display: flex;
  110. justify-content: flex-end;
  111. .nav-item{
  112. transition-duration: 300ms;
  113. padding: 16px 32px;
  114. border-radius: 16px;
  115. text-decoration: unset;
  116. color: $menuActiveText;
  117. display: flex;
  118. flex-direction: column;
  119. .icon{
  120. margin-bottom: 4px;
  121. font-size: 32px;
  122. }
  123. .text{
  124. font-size: 16px;
  125. }
  126. &:hover{
  127. background: #004DFF11;
  128. }
  129. }
  130. }
  131. }
  132. }
  133. }
  134. }
  135. </style>