<template>
  <div class="home">
    <div class="navigation-bar">
      <div class="nav-body">
        <router-link to="/" class="nav-logo">
          <img src="../assets/logo.png"/>
        </router-link>
        <div class="nav-search">
          <div class="nav-search-div">
            <input class="search-input" type="text" placeholder="搜索商品名称"/>
          </div>
          <!--          点击-->
          <button class="search-btn">
            <img src="../assets/nav_search-logo.svg" alt="搜索">
          </button>
        </div>
        <div class="nav-user">
          <div class="nav-user-icon" @click="login()">
            <div class="nav-user-icon-bg">
              <img src="../assets/nav_user_icon.svg" alt="登录">
            </div>
            <span>登录</span>
          </div>
          <div class="nav-user-menu">
            <div class="nav-user-icon-bg">
              <img src="../assets/nav_user_menu.svg" alt="菜单">
            </div>
          </div>
        </div>
      </div>

    </div>
    <!--    内容体-->
    <div class="main-content">
      <!--      首页广告内容-->
      <HomeConnect/>
      <!--      首页优惠礼包信息-->
      <GiftPackDiscounts/>
      <!--      <hr width="1170" style="margin-bottom: 40px;">-->
      <template v-for="item in goodsListArray">
        <GoodsTypeComponent :goods-type="item"/>
        <GoodsTypeComponent :goods-type="item"/>
      </template>

    </div>
    <!--    底部内容-->
    <div class="bottom-bar">
    </div>
    <!--    遮罩层-->
    <div class="home-shield " v-show="showLogin">
      <div class="login-form">
        <div class="login-form-body">
          <!-- 关闭登录界面 -->
          <div class="login-form-body-close" @click="login">
            X
          </div>
          <!-- 选择登录方式 -->
          <div class="login-form-select">
            <ul>
              <li v-for="(item,index) in loginType" @click="selectLoginType = index">
                {{ item.name }}登录
              </li>
            </ul>
          </div>
          <!--          登录内容体-->
          <div class="login-form-table-phone" v-show="selectLoginType === 0">
            <form>
              {{ loginType[selectLoginType].name }}
            </form>
          </div>
          <div class="login-form-table-email" v-show="selectLoginType === 1">
            <form>
              {{ loginType[selectLoginType].name }}
            </form>
          </div>
        </div>
      </div>
    </div>
    <!--      悬浮层  -->
    <!--    <div class="home-suspension">-->
    <!--      <div class="right-handler"></div>-->
    <!--      <div class="bottom-advertisement">-->
    <!--        <div class="advertisement-content">-->

    <!--        </div>-->
    <!--      </div>-->
    <!--    </div>-->
  </div>
</template>
<script setup lang="ts">
import HomeConnect from "./HomeConnent.vue";

import GoodsTypeComponent from "../components/GoodsTypeComponent.vue";

import {GoodsInfo, GoodsType} from "../entity/Entity.ts";
import {ref} from 'vue'
import GiftPackDiscounts from "./GiftPackDiscounts.vue";

let showLogin = ref(false)

class LoginType {
  type: string
  name: string

  constructor(type: string, name: string) {
    this.type = type;
    this.name = name;
  }

  //临时的数据信息
}

let loginType = ref([new LoginType('Phone', '手机号'), new LoginType('Email', '邮箱')])
let selectLoginType = ref(0)

function login() {
  console.log('login')
  showLogin.value = !showLogin.value;
}

let goodsListArray = ref([
      new GoodsType(0, "标题内容", "/router", "买了吃亏，买了上当", [
        new GoodsInfo(0, "../assets/goodsInfo.jpg", "商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品商品0", 3.14, 98.0),
        new GoodsInfo(1, "../assets/goodsInfo.jpg", "商品1", 98, 98.0),
        new GoodsInfo(2, "../assets/goodsInfo.jpg", "商品2", 98, 98.0),
        new GoodsInfo(3, "../assets/goodsInfo.jpg", "商品3", 98, 98.0),
        new GoodsInfo(4, "../assets/goodsInfo.jpg", "商品4", 98, 98.0),
        new GoodsInfo(5, "../assets/goodsInfo.jpg", "商品5", 98, 98.0),
        new GoodsInfo(6, "../assets/goodsInfo.jpg", "商品6", 3.14, 98.0),
        new GoodsInfo(7, "../assets/goodsInfo.jpg", "商品7", 3.14, 98.0),
        new GoodsInfo(8, "../assets/goodsInfo.jpg", "商品8", 3.14, 98.0),
        new GoodsInfo(9, "../assets/goodsInfo.jpg", "商品9", 3.14, 98.0),
        new GoodsInfo(10, "../assets/goodsInfo.jpg", "商品10", 3.14, 98.0),
        new GoodsInfo(11, "../assets/goodsInfo.jpg", "商品11", 3.14, 98.0),
        new GoodsInfo(12, "../assets/goodsInfo.jpg", "商品12", 3.14, 98.0),
        // new GoodsInfo(13, "../assets/goodsInfo.jpg", "商品13", 3.14, 98.0),
      ])
    ]
)

// login-form-select
</script>

<style scoped lang="scss">
.home-suspension {
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  position: absolute;
  z-index: 998;

  .bottom-advertisement {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 130px;
    background: #8a65d9;

    .advertisement-content {
      width: 1180px;
      height: 130px;
      margin: auto auto;
      //左右渐变
      background: linear-gradient(to right, #8a65d9, #6ac5a9, #6ac5a9, #8a65d9);
    }
  }

  .right-handler {
    position: fixed;
    bottom: 50px;
    right: 0;
    width: 100px;
    height: 300px;
    background-image: linear-gradient(#4466FF, #a028d3);
    z-index: 1;
  }


}


.home-shield {
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  position: absolute;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;

  .login-form {
    width: 400px;
    height: 0;
    margin: auto;
    position: fixed;
    top: 25%;
    left: calc(50% - 200px);
    color: black;

    .login-form-body {
      align-items: center;
      display: inline-block;
      margin: auto;
      background: white;
      width: 400px;
      height: 450px;

      .login-form-body-close {

      }
    }
  }


}

.navigation-bar {
  display: flex;
  place-items: center;
  height: 80px;

  background: #000000;

  .nav-body {
    height: 100%;
    width: 1170px;
    margin: auto auto;
    display: grid;
    grid-template-columns: 135px 1fr 150px;

    .nav-logo {
      grid-area: 1 / 1 / 2 / 2;
      margin: auto auto;
    }

    .nav-search {
      width: 450px;
      height: 40px;
      margin: auto auto;
      display: flex;
      border: none;

      .nav-search-div {

        .search-input {
          width: 370px;
          height: 40px;
          //padding-left: 15px;
          padding: 0 0 0 15px;
          font-size: 14px;
          border: none;
          outline: none;
          border-radius: 5px 0 0 5px;
        }
      }

      .search-btn {
        width: 70px;
        height: 40px;
        outline: none;
        margin: 0;
        border: none;
        background: #1475fa;
        border-radius: 0 5px 5px 0;

        &:hover {
          border: none;
          cursor: pointer;
        }

        &:active {
          border: none;
          background: #1470da;
          cursor: pointer;
        }

      }
    }

    .nav-user {
      display: grid;
      grid-template-columns: 70px 48px;
      margin: auto auto;
      width: 150px;
      height: 70px;
      color: white;

      .nav-user-icon {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 72px;
        cursor: pointer;
      }

      .nav-user-menu {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 48px;
        margin-left: 30px;

      }

      .nav-user-icon-bg {
        width: 35px;
        height: 35px;
        border-radius: 50%;
        background: #1d1d1d;
        margin-right: 5px;
        display: flex;
        justify-content: center;
        align-items: center;

        img {
          cursor: pointer;
          margin: 0;
        }
      }


      //div {
      //  margin: auto auto;
      //}

    }


  }
}


</style>