<template>
  <view class="detail">
    <view class="title">
      <view class="title-left">
        <image class="header-img" :src="itemInfo.image" mode=""></image>
        <text>{{ itemInfo.merchant_name }}</text>
        <image
          class="right-325"
          src="../../../static/mine/325.png"
          mode=""
        ></image>
      </view>
      <text
        class="order-status"
        v-if="itemInfo.order_goods[0].refund.status == 0"
        >退款中</text
      >
      <text
        class="order-status"
        v-if="itemInfo.order_goods[0].refund.status == 1"
        >退款成功</text
      >
      <text
        class="order-status"
        v-if="itemInfo.order_goods[0].refund.status == 2"
        >拒绝退款</text
      >
      <text
        class="order-status"
        v-if="itemInfo.order_goods[0].refund.status == 3"
        >平台介入</text
      >
    </view>
    <view
      class="commodity-information"
      v-for="item in itemInfo.order_goods"
      @click.stop="$emit('toRefundDetail', item)"
    >
      <view class="commodity-1" v-if="item.refund">
        <image class="commodity-img" :src="item.sku_item.image" mode=""></image>
        <view class="information-right">
          <view class="commodity-2">
            <view class="commodity-title">
              {{ item.goods_name }}
            </view>
          </view>

          <view class="commodity-3">
            <view class="specifications"> {{ item.sku_item.item }} </view>
          </view>
          <view
            style="
              display: flex;
              justify-content: space-between;
              align-items: center;
            "
          >
            <view
              class="commodity-price"
              v-if="item.refund.actual_refund_price"
            >
              <text style="color: #222; font-size: 26rpx">退款</text>
              <text style="font-size: 20rpx">￥</text>
              <text>{{ item.refund.actual_refund_price.split(".")[0] }}</text
              >.
              <text style="font-size: 20rpx">{{
                item.refund.actual_refund_price.split(".")[1]
              }}</text>
            </view>

            <view class="commodity-price" v-else>
              <text style="color: #222; font-size: 26rpx">退款</text>
              <text style="font-size: 20rpx">￥</text>
              <text>{{ item.refund.refund_price.split(".")[0] }}</text
              >.
              <text style="font-size: 20rpx">{{
                item.refund.refund_price.split(".")[1]
              }}</text>
            </view>
            <view class="btn-list">
              <button
                class="status-1"
                v-if="item.refund.status == 1"
                @click.stop="$emit('deleteAfterOrder', item)"
              >
                删除记录</button
              ><button
                class="status-2"
                v-if="
                  item.refund.status == 1 ||
                  item.refund.status == 0 ||
                  item.refund.status == 3
                "
                @click.stop="$emit('toRefundDetail', item)"
              >
                售后详情
              </button>
              <button
                class="status-2"
                v-if="item.refund.status == 2 || item.refund.status == 3"
                @click.stop="$emit('unreviewAfter', item)"
              >
                继续申请
              </button>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="result" v-if="itemInfo.order_goods[0].refund.status == 0">
      <view class="result-left"> 申请中 </view>
      <view class="result-right"> 等待卖家同意退款 </view>
    </view>
    <view class="result" v-if="itemInfo.order_goods[0].refund.status == 1">
      <view class="result-left"> 退款成功 </view>
      <view class="result-right">
        退款成功¥{{
          itemInfo.order_goods[0].refund.actual_refund_price &&
          Number(itemInfo.order_goods[0].refund.actual_refund_price) != 0
            ? itemInfo.order_goods[0].refund.actual_refund_price
            : itemInfo.order_goods[0].refund.refund_price
        }}
      </view>
    </view>
    <view class="result" v-if="itemInfo.order_goods[0].refund.status == 2">
      <view class="result-left"> 退款失败 </view>
      <view class="result-right"> 卖家拒绝退款 </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    refundDetail: {
      typeof: Object,
      default: {},
    },
    itemInfo: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {};
  },
};
</script>

<style scoped lang="scss">
.detail {
  padding: 28rpx 20rpx;
  background-color: #fff;
  border-radius: 16rpx;
  margin-top: 28rpx;

  .title {
    display: flex;
    justify-content: space-between;

    .title-left {
      display: flex;
      font-size: 32rpx;
      align-items: center;

      .header-img {
        width: 36rpx;
        height: 36rpx;
        border-radius: 50%;
        margin-right: 20rpx;
      }

      .right-325 {
        width: 32rpx;
        height: 32rpx;
      }
    }

    .order-status {
      color: #f83224;
      font-size: 26rpx;
    }
  }

  .commodity-information {
    margin-top: 28rpx;

    .information-right {
      width: 70%;
    }

    .commodity-1 {
      display: flex;

      .commodity-img {
        width: 180rpx;
        height: 180rpx;
        margin-right: 20rpx;
        border-radius: 10rpx;
      }

      .commodity-2 {
        display: flex;
        justify-content: space-between;

        .commodity-title {
          width: 100%;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
          margin-right: 38rpx;
        }
      }

      .commodity-3 {
        display: flex;
        justify-content: space-between;
        margin-top: 20rpx;
        color: #777;

        .specifications {
          font-size: 28rpx;
          color: #777;
        }
      }

      .commodity-price {
        margin-top: 40rpx;
      }
    }
  }

  .price {
    display: flex;
    justify-content: flex-end;
    font-size: 28rpx;
    align-items: flex-end;
  }

  .result {
    background-color: #f4f4f4;
    border-radius: 16rpx;
    height: 76rpx;
    display: flex;
    align-items: center;
    margin-top: 20rpx;
    padding-left: 24rpx;

    .result-left {
      margin-right: 32rpx;
      color: #222;
      font-size: 28rpx;
    }

    .result-right {
      color: #333;
      font-size: 28rpx;
    }
  }

  .btn-list {
    display: flex;
    justify-content: flex-end;
    margin-top: 34rpx;

    .status-1 {
      background-color: #fff;
      border-radius: 34rpx;
      margin: 0;
      padding: 0;
      font-size: 20rpx;
      color: #222;
      width: 128rpx;
      height: 58rpx;
      line-height: 58rpx;
      margin-right: 20rpx;
      border: 2rpx solid #979797;
    }

    .status-2 {
      background-color: #ffffff;
      border-radius: 34rpx;
      margin: 0;
      padding: 0;
      font-size: 20rpx;
      color: #f83224;
      width: 128rpx;
      height: 58rpx;
      line-height: 58rpx;
      border: 2rpx solid #f83224;
      margin-left: 10rpx;
    }
  }
}
</style>
