<template>
  <div>
    <!-- 新订单 -->
    <div class="detail_cont">
      <template v-if="orderDetail.detailItems">
        <div class="detail_title2">商品详情</div>
        <div class="shop_detail" v-for="(item,i) in orderDetail.detailItems" :key="i">
          <div class="info">
            <img v-if="item.foodPic" :src="item.foodPic" alt="" srcset="">
            <div class="shop_title">{{item.foodName}}</div>
          </div>
          <div class="shop_num">x{{item.quantity}}</div>
        </div>
        <div class="detail_ine"></div>
      </template>

      <template v-if="orderDetail.caution || orderDetail.takeRemark">
        <div class="info2" v-if="orderDetail.caution">
          <div class="title">用户备注：</div>
          <div class="cont cont1">{{orderDetail.caution.length > 60 ? orderDetail.caution.slice(0,60) + '...' : orderDetail.caution}}</div>
        </div>
        <div class="info2 info3" v-if="orderDetail.takeRemark">
          <div class="title">发单备注：</div>
          <div class="cont cont1">{{orderDetail.takeRemark.length > 60 ? orderDetail.takeRemark.slice(0,60) + '...' : orderDetail.takeRemark}}</div>
        </div>
        <div class="detail_ine"></div>
      </template>
      <template v-if="orderDetail.invoiceTitle || orderDetail.taxpayerId">
        <div class="detail_title2">发票信息</div>
        <div class="info2 info4" v-if="orderDetail.invoiceTitle">
          <div class="title">发票抬头：</div>
          <div class="cont">{{orderDetail.invoiceTitle}}</div>
        </div>
        <div class="info2 info4" v-if="orderDetail.taxpayerId">
          <div class="title">税号：</div>
          <div class="cont">{{orderDetail.taxpayerId}}</div>
        </div>
        <div class="detail_ine"></div>
      </template>
      <template v-if="orderDetail.receiptContactName">
        <div class="detail_title2">顾客信息</div>
        <div class="info2 info4">
          <div class="title">姓名：</div>
          <div class="cont">{{orderDetail.receiptContactName}}</div>
        </div>
        <div class="info2 info4" v-if="orderDetail.receiptPhone">
          <div class="title">隐私号：</div>
          <div class="cont">{{orderDetail.receiptPhone}}</div>
        </div>
        <div class="info2 info4" v-if="orderDetail.receiptPrivacyPhone">
          <div class="title">手机号：</div>
          <div class="cont">{{orderDetail.receiptPrivacyPhone}}</div>
        </div>
      </template>
      <div class="detail_ine"></div>
      <div class="detail_title2">订单金额</div>
      <div class="info2 info4">
        <div class="title">商品金额：</div>
        <div class="cont">¥{{orderDetail.productAmount}}</div>
      </div>
      <div class="detail_ine"></div>
      <div class="detail_title2">订单信息</div>

      <div class="info2 info4" v-if="orderDetail.waimaiOrderId">
        <div class="title">送达时间：</div>
        <div class="cont cont2">{{ !orderDetail.exceptTime ? '立即送达' : orderDetail.exceptTime}}</div>
      </div>
      <div class="info2 info4" v-if="!orderDetail.waimaiOrderId">
        <div class="title">取件时间：</div>
        <div class="cont cont2">{{ !orderDetail.orderType ? '立即取件' : orderDetail.takeTime}}</div>
      </div>
      <!-- <div class="info2 info4" v-if="orderDetail.takeTime && buttonStatus !== 0 && buttonStatus !== 10 ">
        <div class="title">发单时间：</div>
        <div class="cont">{{orderDetail.takeTime}}</div>
      </div> -->
      <div class="info2 info4" v-if="orderDetail.waimaiOrderId">
        <div class="title">外卖下单时间：</div>
        <div class="cont">{{orderDetail.orderTime}}</div>
      </div>
      <div class="info2 info4" v-if="orderDetail.createTime && !orderDetail.waimaiOrderId">
        <div class="title">订单创建时间：</div>
        <div class="cont">{{orderDetail.createTime}}</div>
      </div>
      <div class="info2 info4" v-if="orderDetail.orderSn">
        <div class="title">订单编号：</div>
        <div class="cont">{{orderDetail.orderSn}}</div>
      </div>
      <div class="info2 info4" v-if="orderDetail.outOrderId">
        <div class="title">{{takeOUtType(orderDetail.orderType)}}订单编号：</div>
        <div class="cont">{{orderDetail.outOrderId}}</div>
      </div>

    </div>
  </div>

</template>
    
<script>
export default {
  name: "OrderDetail",
  data() {
    return {};
  },
  props: {
    buttonStatus: Number,
    orderDetail: Object,
  },
  methods: {
    takeOUtType(type) {
      let name = "";
      switch (type) {
        case 1:
          name = "美团";
          break;
        case 2:
          name = "饿了么";
          break;
        case 3:
          name = "饿百";
          break;

        default:
          name = "美团";
          break;
      }
      return name;
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped="scoped">
.detail_cont {
  width: 100%;
  padding: 16px;
  box-sizing: border-box;
  .detail_title2 {
    width: 100%;
    font-size: 12px;
    font-weight: 600;
    color: #777777;
    margin-bottom: 15px;
  }
  .shop_detail {
    width: 100%;
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
    .info {
      flex-grow: 1;
      display: flex;
      align-items: flex-start;
      img {
        width: 47px;
        height: 47px;
        border-radius: 4px 4px 4px 4px;
        margin-right: 12px;
      }
      .shop_title {
        font-size: 12px;
        font-weight: 500;
        color: #333333;
        line-height: 18px;
      }
    }
    .shop_num {
      margin-left: 10px;
      color: #b1b1b1;
    }
  }
  .detail_ine {
    width: 100%;
    height: 1px;
    border-top: 2px dotted #f0f0f0;
    margin: 16px 0;
  }
  .info2 {
    width: 100%;
    display: flex;
    margin-bottom: 5px;
    .title {
      flex-shrink: 0;
      font-size: 14px;
      font-weight: 400;
      // width: 80px;
      color: #b1b1b1;
    }
    .cont {
      font-size: 14px;
      font-weight: 400;
      color: #333333;
      line-height: 20px;
      word-break: break-all;
      text-align: right;
    }
    .cont1 {
      text-align: left;
    }
    .cont2 {
      color: #fc7200;
    }
  }
  .info3 {
    margin-top: 10px;
  }
  .info4 {
    display: flex;
    justify-content: space-between;
  }
}
</style>
