welcome-banner.vue 3.07 KB
<template>
  <workbench-card variant="banner">
    <div class="welcome">
      <div class="welcome__glow" aria-hidden="true" />
      <div class="welcome__avatar">
        <i class="el-icon-user-solid" />
      </div>
      <div class="welcome__content">
        <div class="welcome__hello">{{ greeting }},{{ userName }}</div>
        <div class="welcome__meta">
          <span><i class="el-icon-office-building" />{{ storeName || '未绑定门店' }}</span>
          <span class="welcome__sep">·</span>
          <span><i class="el-icon-date" />{{ todayText }}</span>
        </div>
      </div>
      <div class="welcome__chip">今日工作台</div>
    </div>
  </workbench-card>
</template>

<script>
import { mapGetters } from 'vuex'
import WorkbenchCard from '../workbench-card.vue'

export default {
  name: 'WidgetWelcomeBanner',
  components: { WorkbenchCard },
  computed: {
    ...mapGetters(['userInfo']),
    userName() {
      return (this.userInfo && (this.userInfo.realName || this.userInfo.userName)) || '用户'
    },
    storeName() {
      return (this.userInfo && (this.userInfo.organizeName || this.userInfo.departmentName)) || ''
    },
    todayText() {
      const d = new Date()
      const week = ['日', '一', '二', '三', '四', '五', '六'][d.getDay()]
      return `${d.getFullYear()}年${d.getMonth() + 1}月${d.getDate()}日 周${week}`
    },
    greeting() {
      const h = new Date().getHours()
      if (h < 12) return '上午好'
      if (h < 18) return '下午好'
      return '晚上好'
    }
  }
}
</script>

<style lang="scss" scoped>
.welcome {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  min-height: 72px;
  padding: 16px 20px;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(120deg, #2f7fd4 0%, #409eff 48%, #79bbff 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(64, 158, 255, 0.22);
}

.welcome__glow {
  position: absolute;
  right: -40px;
  top: -50px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.welcome__avatar {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-right: 14px;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.welcome__content {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.welcome__hello {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.welcome__meta {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;

  i { margin-right: 4px; opacity: 0.9; }
}

.welcome__sep { opacity: 0.55; margin: 0 2px; }

.welcome__chip {
  position: relative;
  z-index: 1;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}
</style>