<template>
  <div class="shop_card" @click="intoDetail">
    <div class="shop_car-img" v-if="showImg">
      <img :src="data.cover" width="100%" />
    </div>
    <div class="shop_card-top">
      <p
        class="shop_card-title text_clip_2"
        v-text="data.name"
        :title="data.name"
      ></p>
      <p class="shop_card-text under_text">
        <span
          class="text_clip"
          v-text="data.department_name"
          :title="data.department_name"
        ></span>
        <span>
          <img :src="require('../assets/imgs/shop_ic_star.png')" />
          <span v-text="data.score"></span>
        </span>
      </p>
    </div>
    <div class="shop_card-bottom">
      <p class="shop_card-text summary text_clip_2" v-if="data.descript">
        <span v-text="data.descript"></span>
      </p>
      <p class="shop_card-text update_time">
        <img
          :src="require('@/assets/imgs/shop_ic_updatetime.png')"
          style="margin-right: 5px;"
        />
        <span
          class="text_clip"
          v-text="'更新时间：' + helper.dateStringTransform(data.update_date)"
        ></span>
      </p>
      <div class="shop_card-text access">
        <span>
          <img :src="require('@/assets/imgs/shop_icon_liulan.png')" />
          <span
            class="text_clip"
            v-text="
              helper.numberFormat(data.view_count, 2) +
                (data.view_count > 10000 ? '万' : '') +
                '次浏览'
            "
          ></span>
        </span>
        <span>
          <img :src="require('@/assets/imgs/shop_ic_huoqu.png')" />
          <span
            class="text_clip"
            v-text="
              helper.numberFormat(data.apply_count, 2) +
                (data.apply_count > 10000 ? '万' : '') +
                '次获取'
            "
          ></span>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import helper from "@/services/helper";
export default {
  props: {
    data: {
      type: Object,
      default: () => {},
    },
    detailPath: {
      type: String,
      required: true,
    },
    showImg: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      helper,
    };
  },
  methods: {
    intoDetail() {
      this.$router.push(this.detailPath + this.data.id);
    },
  },
};
</script>

<style scoped>
.shop_card {
  overflow: hidden;
  border: 1px solid #ededed;
  border-radius: 10px;
  box-sizing: border-box;
  cursor: pointer;
}
.shop_car-img {
  cursor: pointer;
}
.shop_car-img > img {
  display: block;
}
.shop_card-top {
  background-color: #f9fafc;
  padding: 19px 19px 6px;
}
.shop_card-bottom {
  background-color: #fff;
  padding: 12px 19px 15px;
}
.shop_card-title {
  height: 42px;
  font-size: 16px;
  color: #0d1847;
  line-height: 21px;
  cursor: pointer;
  margin-bottom: 8px;
}
.shop_card-text {
  font-size: 14px;
  color: #8890a7;
  line-height: 21px;
}
.shop_card-text.under_text {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #58617a;
}
.shop_card-text.under_text > span:nth-child(2) {
  flex-shrink: 0;
  margin-left: 10px;
  font-family: Arial;
  font-size: 18px;
  font-weight: bold;
  color: #ea7d19;
}
.shop_card-text.summary {
  height: 42px;
  margin-bottom: 12px;
}
.shop_card-text.update_time {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 15px;
}
.shop_card-text.update_time > i {
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: 5px;
}
.shop_card-text.access {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 11px;
  border-top: 1px solid #ededed;
  color: #58617a;
}
.shop_card-text.access > span > * {
  vertical-align: middle;
}
.shop_card-text.access > span > img {
  margin-right: 5px;
}
</style>
