<!--
  @description: 首页商品列表
  @Modifier：杨胜国
  @routerPath:shopHomePageProductComp
  @date：  2021/05/17-18:00
-->
<template>
  <div class="middle_width1190 tab_container">
    <!--电脑设备-->
    <div class="index_goods">
      <section class="section clearfix">
        <div
          v-for="(item,index) in productList"
          :key="index"
          class="floor-item pointer"
          @click="goToGoodsDetail(item)"
        >
          <div class="more2_img">
            <el-image :src="item.productPicture" lazy />
          </div>
          <div class="more2_info">
            <div class="name goods_item_title_two more2_info_name" :title="item.productName">
              {{ item.productName }}
            </div>
            <div class="mod_price">
              <i v-if="isLogin">¥</i>
              <span v-if="isLogin" class="more2_info_price_txt">
                {{ item.commodityPrice }}
              </span>
              <span v-if="!isLogin" class="same_price">
                市场价：<i>¥</i>
                {{ item.marketPrice }}
              </span>
            </div>
          </div>
        </div>
      </section>
    </div>
  </div>
</template>

<script>
import { getToken } from '@/assets/js/utils/auth'
export default {
  name: 'ShopHomePageProductComp',
  components: {
  },
  props: {
    productList: { // 商品列表
      type: Array,
      default: function() {
        return []
      }
    }
  },
  data() {
    return {
      isLogin: false // 是否登录
    }
  },
  created() {
    this.isLogin = !!getToken()
  },
  methods: {
    // 点击列表展示商品列表去商品详情
    goToGoodsDetail(item) {
      this.$router.push({ path: '/shop/goodsClassDetail', query: { id: item.id }})
    }
  }
}
</script>

<style scoped lang="less">
.same_price {
  color: @orange;
}
.tab_container{
  .floorhd {
    height: 65px;
  }
  .grid_c1 {
    margin: 0 auto;
    width: 100%;
  }
  .more2_info{
    clear: both;
    line-height: 24px;
    padding: 0 20px;
    height: 65px;
  }
  .more2_info_name{
    height: 48px;
    font-size: 14px;
    line-height: 24px;
    text-align: left;
    color: #666;
    -webkit-transition: color .2s ease;
    transition: color .2s ease;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .more2_img{
    display: block;
    width: 150px;
    height: 150px;
    margin: 30px auto 40px;
    &>img{
      display: block;
      width: auto;
      height: auto;
      max-width: 100%;
      max-height: 100%;
      margin: 0 auto;
    }
  }
  .mod_price{
    float: left;
    width: 100%;
    text-align: left;
    font-size: 16px;
    line-height: 18px;
    height: 18px;
    color: #e1251b;
    margin-top: 10px;
    i{
      vertical-align: middle;
      font-size: 12px;
      font-weight: 700;
      font-style: normal;
      font-family: MicrosoftYahei-regular,Arial,Helvetica,sans-serif;
      margin-right: 1px;
    }
  }
  .more2_info_price_txt{
    font-size: 20px;
    font-weight: 700;
    font-family: arial,sans-serif;
  }
  .index_goods{
    background: #f4f4f4;
    .section{
      margin-left: -5px;
      margin-right: -5px;
    }
  }
  .floor-item {
    background: #fff;
    position: relative;
    float: left;
    width: 240px;
    height: 322px;
    margin: 0 6px 10px;
    &:hover {
      background-color: #fff;
    }
  }
}
</style>
