<template>
  <div class="delivery-item-con">
    <div class="header flex-default">
      <div class="shop flex-default" @click="goShop(data.merchantId)">
        <m-icon icon="icon-shop" :size="16" />
        <span class="name">{{ detail.enterpriseName }}</span>
        <m-icon icon="icon-more" :size="9" />
      </div>
      <div class="status" :style="{ color: detail.statusColor }">
        {{ detail.statusLabel }}
      </div>
    </div>
    <div class="content flex-default" @click="hanleDetail">
      <div class="info flex-default">
        <img class="thumb" :src="detail.thumb" />
        <div class="spu">
          <div class="name">{{ detail.name }}</div>
          <div class="sku">{{ detail.propList | propFilter }}</div>
        </div>
      </div>
      <div class="right-con flex-default">
        <!-- <div class="price">￥{{ data.amount }}</div> -->
        <div class="amt">共{{ detail.number }}件</div>
      </div>
    </div>
    <div class="opt flex-default">
      <van-button
        v-for="(item, index) of btnList"
        :key="`button-item-${index}`"
        class="opt-btn"
        :type="btnMap[item].type"
        size="small"
        :plain="item.plain"
        round
        @click="btnMap[item].click"
      >
        {{ btnMap[item].label }}
      </van-button>
    </div>
  </div>
</template>

<script>
import {
  DeliveryStatus,
  DeliveryStatusObj,
  OrderType,
  RefundType,
} from "@/enums";
import { DeliveryMixin } from "@/mixins";
export default {
  mixins: [DeliveryMixin],
  props: {
    isRefund: {
      type: Boolean,
      default: false,
    },
    data: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  computed: {
    detail() {
      return {
        ...this.data,
        statusLabel: DeliveryStatusObj[this.data.deliveryState].label,
        statusColor: DeliveryStatusObj[this.data.deliveryState].color,
      };
    },
  },
  data() {
    return {
      DeliveryStatus,
      DeliveryStatusObj,
    };
  },
  methods: {
    hanleDetail() {
      let params = { deliveryId: this.data.deliveryId };
      this.$router.push({ name: "delivery-detail", params });
    },
  },
  filters: {
    propFilter(props) {
      return props.map((item) => item.value).join("+");
    },
  },
};
</script>

<style lang="less">
.delivery-item-con {
  background: #ffffff;
  width: 100%;
  padding: 14px 16px 18px 8px;
  border-radius: 8px;
  margin-top: 10px;
  > .header {
    color: #140603;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    .shop {
      align-items: center;
      flex: 1;
    }
    .shop .name {
      font-size: 14px;
      margin-left: 6px;
      margin-right: 5px;
      font-weight: bold;
    }
    .status {
      font-size: 12px;
      color: #dd2e41;
    }
  }
  > .content {
    align-items: center;
    margin-bottom: 20px;
    .thumb {
      height: 84px;
      width: 84px;
      border-radius: 3px;
      background-color: lightgray;
      margin-right: 4px;
    }
    > .info-list {
      width: ~"calc(100% - 84px)";
      white-space: nowrap;
      .thumb {
        display: inline-block;
      }
    }
    > .info {
      align-items: center;
      flex: 1;
    }
    > .info .spu {
      flex: 1;
      margin-left: 10px;
      width: 73px;
    }
    > .info .spu .name {
      color: #140603;
      font-size: 13px;
      line-height: 15px;
      margin-bottom: 6px;
    }
    > .info .spu .sku {
      color: #72767d;
      font-size: 11px;
      line-height: 13px;
    }
    > .right-con {
      flex-direction: column;
      align-items: flex-end;
      margin-left: 5px;
    }
    > .right-con .price {
      color: #140603;
      font-size: 14px;
      font-weight: bold;
      line-height: 16px;
      margin-bottom: 5px;
    }
    > .right-con .amt {
      color: #aeaeae;
      font-size: 10px;
      line-height: 12px;
      font-weight: bold;
    }
  }
  > .opt {
    justify-content: flex-end;
    .opt-btn {
      margin-left: 8px;
      width: 70px;
      padding: 0;
      height: 25px;
    }
    .van-button--black {
      border: 1px solid #aeaeae;
      color: #140603;
    }
  }
}
</style>