<template>
  <div :class="{ 'group-item': true, isRow, isFood }" @click="handleShop">
    <div :class="{ 'logo-wrapper': true, hasFood: isFood && shop.foodMaterialList.length }">
      <img loading="lazy" :src="config.sourceUrl + shop.logoUrl" alt="" class="shop-logo" />
    </div>
    <p class="name">
      <span class="shop-name">{{ switchLanguage(shop, 'shopName') }}</span>
      <span class="name-right" v-if="$route.path === '/guide'"> {{ shop.distance ? shop.distance + '米' : '' }}<img v-if="shop.dir" :src="shop.dir" /> </span>
      <span class="name-right" v-else>{{ shop.floor }}</span>
    </p>
  </div>
</template>

<script setup>
const props = defineProps({
  shop: Object,
  config: Object,
  isRow: Boolean,
  isFood: Boolean
})

const emits = defineEmits(['click'])
function handleShop() {
  emits('click', props.shop)
}
</script>

<style lang="scss" scoped>
.group-item {
  width: 230px;
  height: 200px;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  overflow: hidden;
}
.logo-wrapper {
  width: 230px;
  height: 160px;
  padding: 20px 55px;
  background-color: #fff;
}
.shop-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
}
.shop-name {
  font-weight: 700;
  font-size: 14px;
  line-height: 16px;
  color: rgba(0, 0, 0, 0.8);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.name-right {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 12px;
  line-height: 14px;
  font-family: 'font_bold';
  color: rgba(0, 0, 0, 0.4);
  img {
    width: 20px;
    height: 20px;
    margin-left: 7px;
  }
}
.format-icon {
  width: 14px;
  margin-right: 8px;
  height: 14px;
}
.group-item {
  &.isRow {
    display: flex;
    width: 460px;
    height: 76px;
    padding-left: 12px;
    align-items: center;
    .logo-wrapper {
      width: 64px;
      height: 64px;
      flex: 0 0 64px;
      padding: 7px;
    }
    .name {
      flex: 1;
      padding: 0 24px;
      .shop-name {
        font-weight: 700;
        font-size: 18px;
        line-height: 21px;
        color: rgba(0, 0, 0, 0.8);
      }
      .name-right {
        font-weight: 500;
        font-size: 18px;
        line-height: 21px;
        img {
          width: 32px;
          height: 32px;
        }
      }
    }
  }
  &.isFood {
    display: flex;
    flex-direction: column;
    width: 230px;
    height: 242px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.5) 100%);
    border-radius: 40px;
    align-items: center;
    .logo-wrapper {
      width: 180px;
      height: 180px;
      background: rgba(255, 255, 255, 0.8);
      border-radius: 200px;
      padding: 30px;
      &.hasFood {
        padding: 0;
      }
      .shop-logo {
        border-radius: 200px;
      }
    }
    .name {
      display: block;
      width: 100%;
      .shop-name {
        display: block;
        margin-top: 12px;
        text-align: center;
      }
      .name-right {
        display: block;
        text-align: center;
        font-family: 'Montserrat';
        font-style: normal;
        font-weight: 700;
        font-size: 14px;
        line-height: 17px;
        color: rgba(0, 0, 0, 0.6);
        margin-top: 6px;
      }
    }
  }
}
</style>
