<template>
  <div class="refund-goods-con">
    <div class="title">{{ RefundTypeObj[type].label }}商品</div>
    <div class="goods flex-default" v-if="list.length == 1">
      <img class="thumb" :src="order1st.thumb" />
      <div class="info">
        <div class="name">{{ order1st.name }}</div>
        <div class="sku">{{ order1st.skuLabel }}</div>
      </div>
    </div>
    <div v-else class="goods-list">
      <img
        class="thumb"
        v-for="(item, index) of list"
        :key="`goods-thumb-${index}`"
        :src="item.thumb"
      />
    </div>
  </div>
</template>

<script>
import { RefundType, RefundTypeObj } from "@/enums";
export default {
  props: {
    list: {
      type: Array,
      default: () => [{}],
    },
    type: {
      type: [Number, String],
      default: "",
    },
  },
  computed: {
    order1st() {
      let obj = this.list[0] || {};
      if (obj.propList && obj.propList.length != 0) {
        let skuLabel = obj.propList
          .map((p) => `${p.name}：${p.value}`)
          .join("  ");
        obj.skuLabel = skuLabel;
      }

      return obj;
    },
  },
  data() {
    return {
      RefundType,
      RefundTypeObj,
    };
  },
};
</script>

<style lang="less">
.refund-goods-con {
  background: #ffffff;
  margin-bottom: 10px;
  border-radius: 10px;
  padding: 18px 18px;
  color: #140603;
  > .title {
    font-size: 16px;
    line-height: 18px;
    font-weight: bold;
    margin-bottom: 16px;
  }
  > .goods-list{
    white-space: nowrap;
    overflow-x: auto;
  }
  .thumb {
    height: 100px;
    width: 100px;
    background-color: #d8d8d8;
    border-radius: 6px;
    margin-right: 10px;
  }
  .info {
    flex: 1;
    padding-top: 5px;
  }
  .info .name {
    font-size: 14px;
    line-height: 18px;
    margin-bottom: 8px;
  }
  .info .sku {
    font-size: 12px;
    line-height: 16px;
    color: #aeaeae;
  }
}
</style>


