<template>
  <div class="shops bg-F5">
    <div class="banner">
      <img src="@assets/sccj-banner.png" alt="" />
    </div>
    <div class="container ">
      <load-more
        url="/company/list"
        :params="params"
        v-slot="{
          item: {
            id,
            companyName,
            primaryBusiness,
            propagandaImgUrl,
            defaultImgUrl,
            goodsCount
          }
        }"
      >
        <router-link class="shop" :to="`/shop/${id}`">
          <img class="logo fl" :src="`${$basePath}${defaultImgUrl}`" />
          <div class="details fl">
            <div class="name">{{ companyName }}</div>
            <div class="desc">主营:{{ primaryBusiness }}</div>
            <div class="total">共计{{ goodsCount }}件商品</div>
            <span class="in">进入店铺</span>
          </div>
          <div
            class="img"
            v-for="(img, index) in getImgs(propagandaImgUrl)"
            :key="`img${index}`"
          >
            <img :src="`${$basePath}${img}`" />
          </div>
        </router-link>
      </load-more>
    </div>
  </div>
</template>
<script lang="ts">
import { Component, Vue, Watch, Prop } from "vue-property-decorator";
@Component
export default class extends Vue {
  private params: IAny | null = null;
  @Prop(String) private kw!: string;
  @Watch("kw", { immediate: true })
  kwChange() {
    this.params = { companyName: this.kw };
  }
  getImgs(imgs: string) {
    return `${imgs}`.split(",");
  }
}
</script>
<style lang="scss" scoped>
.shops {
  .banner {
    width: 100%;
    height: 240px;
    line-height: 240px;
    color: #fff;
    font-size: 2rem;
    font-weight: bold;
    text-align: center;
    background: rgb(220, 220, 220);
    img {
      width: 100%;
      height: 100%;
    }
  }
  .shop {
    margin-top: 20px;
    background: #fff;
    overflow: hidden;
    height: 170px;
    box-sizing: border-box;
    padding: 30px 20px;
    display: block;
    .logo {
      width: 145px;
      margin-right: 40px;
      position: relative;
      top: 50%;
      transform: translateY(-50%);
    }
    .details {
      width: 330px;
      height: 114px;
      border-right: 1px solid #e5e5e5;
      font-size: 14px;
      .name {
        color: rgb(51, 51, 51);
        font-size: 16px;
        margin-bottom: 5px;
      }
      .desc {
        color: rgb(102, 102, 102);
        margin-bottom: 15px;
      }
      .total {
        color: #a5a5a5;
        margin-bottom: 5px;
      }
      .in {
        border: 1px solid #fd5522;
        color: #fd5522;
        display: inline-block;
        padding: 5px 10px;
        border-radius: 6px;
      }
    }
    .img {
      width: 114px;
      height: 114px;
      float: left;
      border: 1px #e5e5e5 solid;
      margin-left: 30px;
      position: relative;
      img {
        max-width: 80%;
        max-height: 80%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }
}
</style>
