<template>
  <div class="view-container">
    <div class="header-left">
      <h1 class="title">{{ title }}</h1>
      <h2 class="sub">{{ subTitle }}</h2>
    </div>
    <div class="align-right" v-if="showInput && isUseSpeech">
      <div class="top-right">
        <img src="../assets/images/index/index_search.png" class="index-search-icon" alt="" />
        <div class="mock-input" @click="handleSearch">
          <p class="search">搜索</p>
          <p class="search-en">search</p>
        </div>
        <img @click="handleVoice" src="../assets/images/guide/voice_white.png" class="index-voice-icon" alt="" />
      </div>
    </div>

    <img src="@/assets/images/mall_logo.png" class="mall-logo" alt="" />

    <slot />
  </div>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { useStore } from '@/store/root'

defineProps({
  showInput: {
    type: Boolean,
    default: true
  },
  title: {
    type: String,
    default: ''
  },
  subTitle: {
    type: String,
    default: ''
  }
})

const store = useStore()
const { isUseSpeech } = storeToRefs(store)

function handleSearch() {
  store.SET_SHOW_SEARCH(true)
}

function handleVoice() {
  store.SET_SHOW_SEARCH(true)
  store.SET_SHOW_VOICE(true)
}
</script>

<style lang="scss" scoped>
.view-container {
  width: 1080px;
  height: 1920px;
}
.mall-logo {
  position: absolute;
  top: 56px;
  right: 40px;
  width: 108px;
  z-index: 51;
}
.header-left {
  position: relative;
  display: flex;
  align-items: center;
  padding-left: 170px;
  padding-right: 40px;
  padding-top: 56px;
  z-index: 51;
  margin-bottom: 102px;
  .title {
    font-weight: 700;
    font-family: 'font_bold';
    font-size: 48px;
    color: var(--color-black-opacity-8);
    margin-right: 32px;
  }
  .sub {
    width: 100px;
    font-weight: 700;
    font-size: 24px;
    line-height: 28px;
    font-family: 'font_bold';
    text-transform: uppercase;
    color: var(--color-black-opacity-6);
  }
}
.align-right {
  display: flex;
  justify-content: flex-end;
}
.top-right {
  position: relative;
  display: flex;
  align-items: center;
  width: 365px;
  height: 88px;
  background: var(--color-black-opacity-05);
  box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.3), inset 0px 4px 30px rgba(0, 0, 0, 0.02);
  border-radius: 51px;
  margin-right: 40px;
  &::before {
    position: absolute;
    content: '';
    width: 2px;
    height: 30px;
    left: 76px;
    top: 29px;
    background: var(--color-black-opacity-2);
  }
  .index-search-icon {
    width: 32px;
    height: 32px;
    margin-right: 42px;
    margin-left: 24px;
  }
  .mock-input {
    width: 298px;
  }
  .search {
    font-weight: 700;
    font-size: 16px;
    line-height: 28px;
    font-family: 'font_bold';
    color: var(--color-black-opacity-6);
  }
  .search-en {
    font-size: 12px;
    font-weight: 700;
    font-family: 'font_bold';
    text-transform: uppercase;
    color: var(--color-black-opacity-4);
  }
  .index-voice-icon {
    width: 132px;
    height: 78px;
    margin-right: 5px;
  }
}
</style>
