<template>
  <div class="home-layout-container">
    <!-- 左侧导航栏 -->
    <div class="left-nav">
      <ul class="nav-list">
        <router-link
          :to="'/productList?id=' + item.id"
          tag="li"
          v-for="item in tagList"
          :key="item.id"
          class="nav-item"
        >
          <img :src="util.showImg(item.image)" alt="" />{{ item.name }}
        </router-link>
      </ul>
    </div>

    <!-- 轮播图 -->
    <div class="main-content">
      <el-carousel style="height: 100%">
        <el-carousel-item v-for="item in topBanner" :key="item.id">
          <img :src="item.head_img" class="carousel-img" />
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- 右侧用户信息栏 -->
    <div class="right-info">
      <div class="avatar-container" v-if="$store.getters.isUserLogin">
        <img
          :src="$store.getters.getUserInfo.avatar"
          alt="用户头像"
          class="user-avatar"
        />
        <div class="welcome-text">Hi-欢迎您</div>
      </div>

      <div class="btn-group" v-if="false">
        <el-button type="danger" size="mini" @click="gotoPath('/Login')"
          >登录</el-button
        >
        <el-button type="warning" size="mini" @click="gotoPath('/Register')"
          >注册</el-button
        >
        <el-button type="primary" size="mini">客服</el-button>
      </div>

      <div class="func-icons" v-if="$store.getters.isUserLogin">
        <router-link to="/User/UserCenter" class="icon-item">
          <i class="icon el-icon-user"></i>
          <span>个人中心</span>
        </router-link>
        <router-link to="/User/OrderList" class="icon-item">
          <i class="icon el-icon-goods"></i>
          <span>我的订单</span>
        </router-link>
        <router-link to="/User/ViewHistory" class="icon-item">
          <i class="icon el-icon-star-off"></i>
          <span>我的收藏</span>
        </router-link>
        <router-link to="/User/UserCenter" class="icon-item">
          <i class="icon el-icon-pie-chart"></i>
          <span>议价单</span>
        </router-link>
      </div>

      <!-- <div class="announcement">
        <el-tag type="danger" size="mini">公告</el-tag>
        <span>2099年12月平台重要新规速递</span>
      </div> -->
    </div>
  </div>
</template>

<script>
export default {
  name: "HomeLayout",
  props: {
    topBanner: {
      type: Array,
      default: () => [],
    },
    tagList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {};
  },
};
</script>

<style scoped lang="scss">
.home-layout-container {
  display: flex;
  width: 100%;
  height: auto;
}

/* 左侧导航栏样式 */
.left-nav {
  width: 200px;
  background-color: #f8f9fa;
  padding: 20px 0;
  box-sizing: border-box;
}
.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-item {
  padding: 12px 20px;
  cursor: pointer;
  color: #333;
  transition: all 0.3s ease;
  display: flex;

  img {
    width: 20px;
    margin-right: 5px;
  }
}
.nav-item:hover {
  background-color: #e9ecef;
  padding-left: 25px;
}

/* 中间主内容样式 */
.main-content {
  flex: 1;
  height: auto;
  overflow: hidden;
}
.carousel-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.main-content ::v-deep .el-carousel__container {
  height: 100% !important;
}

/* 右侧用户信息栏样式 */
.right-info {
  width: 280px;
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-left: 1px solid #eee;
}
.avatar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}
.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-bottom: 10px;
  border: 2px solid #f0f0f0;
}
.welcome-text {
  font-size: 14px;
  color: #333;
}
.btn-group {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  width: 100%;
}
.func-icons {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-bottom: 30px;
  padding: 10px 0;
  border-top: 1px dashed #eee;
  border-bottom: 1px dashed #eee;
}
.icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  color: #666;
  transition: color 0.3s ease;
  width: 50px;
}
.icon-item:hover {
  color: #1890ff;
}
.icon {
  font-size: 24px;
  margin-bottom: 5px;
}
.icon-item span {
  font-size: 12px;
}
.announcement {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: #666;
  width: 100%;
  padding-top: 10px;

  span {
    margin-left: 10px;
  }
}
</style>
    