<template>
  <view class="detail">
    <view class="title">
      <view class="title-left" v-if="orderInformation.member">
        <image
          class="header-img"
          :src="orderInformation.member.avatar"
          mode=""
        ></image>
        <text>{{ orderInformation.member.nickname }}</text>
        <image
          class="right-325"
          src="../../../static/mine/325.png"
          mode=""
        ></image>
      </view>
    </view>
    <view class="commodity-information">
      <view class="commodity-1" v-for="item in orderInformation.goods">
        <image class="commodity-img" :src="item.sku_item.image" mode=""></image>
        <view class="">
          <view class="commodity-2">
            <view class="commodity-title"> {{ item.goods_name }}</view>
            <view class="commodity-price">
              <text style="font-size: 20rpx">￥</text>
              <text>{{ item.sku_item.price.split(".")[0] }}</text
              >.
              <text style="font-size: 20rpx">{{
                item.sku_item.price.split(".")[1]
              }}</text>
            </view>
          </view>

          <view class="commodity-3">
            <view class="specifications"> {{ item.sku_item.item }} </view>
            <view style="font-size: 24rpx"> x{{ item.goods_num }} </view>
          </view>
        </view>
      </view>
    </view>
    <view class="detail-1">
      <text class="_text-1">{{
        "共" + orderInformation.goods.length + "件商品" + "&nbsp;"
      }}</text>
      <text class="_text-2">买家实付</text>
      <view class="_price">
        <text style="font-size: 20rpx">￥</text>
        <text>{{ payMoney.split(".")[0] }}</text
        >.
        <text style="font-size: 20rpx">{{ payMoney.split(".")[1] }}</text>
      </view>
    </view>
    <view class="information">
      <text class="_label">退款状态</text>
      <view style="color: #f83224"> {{ statusName }} </view>
    </view>
    <view class="information">
      <text class="_label">退款原因</text>
      <view class="_title-right">
        {{ orderInformation.goods[0].refund.refund_illustrate }}
      </view>
    </view>
    <view class="information">
      <text class="_label">退款金额</text>
      <view lass="_title-right" style="font-weight: 600">
        ￥{{ orderInformation.goods[0].refund.refund_price }}
      </view>
    </view>
    <view class="information">
      <text class="_label">申请时间</text>
      <view style="color: #222"> {{ orderInformation.created_at }} </view>
    </view>
    <view class="information">
      <text class="_label">退款编号</text>
      <view style="color: #222">
        <text>{{ orderInformation.order_no + "｜" }}</text>
        <text @click="cope(orderInformation.order_no)">复制</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    status: {
      typeof: Number,
      default: 0,
    },
    orderInformation: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {};
  },
  computed: {
    statusName() {
      if (this.orderInformation.goods[0].refund.status == "0") {
        return "待商家处理";
      } else if (this.orderInformation.goods[0].refund.status == "1") {
        return "已退款";
      } else if (this.orderInformation.goods[0].refund.status == "2") {
        return "拒绝退款";
      } else if (this.orderInformation.goods[0].refund.status == "3") {
        return "平台介入";
      }
    },
    // 买家实付金额
    payMoney() {
      let money = 0;
      this.orderInformation.goods.map((item) => {
        money = money + Number(item.amount);
      });
      return String(money.toFixed(2));
    },
    //退款金额
    refundMoney() {
      let money = 0;
      this.orderInformation.goods.map((item) => {
        if (item.refund.actual_refund_price) {
          money = money + Number(item.refund.actual_refund_price);
        } else {
          money = money + Number(item.refund.refund_price);
        }
      });
      return String(money.toFixed(2));
    },
  },
  methods: {
    cope(str) {
      uni.setClipboardData({
        data: str,
        success() {
          uni.showToast({
            title: "复制成功",
            icon: "none",
          });
        },
      });
    },
    application() {
      uni.navigateTo({
        url: "/pageC/applicationRefund/applicationRefund",
      });
    },
  },
};
</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;

    .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: 326rpx;
          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;
        }
      }
    }
  }
  .last {
    border-bottom: 2rpx solid rgba(151, 151, 151, 0.1);
    padding-bottom: 20rpx;
  }
  .btn-list {
    display: flex;
    justify-content: flex-end;
    button {
      width: 152rpx;
      height: 58rpx;
      border: 2rpx solid #979797;
      color: #444;
      margin: 0;
      padding: 0;
      font-size: 24rpx;
      background-color: #fff;
      border-radius: 34rpx;
      margin-top: 20rpx;
      margin-left: 20rpx;
    }
  }
  .detail-1 {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    padding-bottom: 20rpx;
    border-bottom: 2rpx solid rgba(151, 151, 151, 0.1);
    ._text-1 {
      color: #222;
      font-size: 24rpx;
    }
    ._text-2 {
      color: #222;
      font-size: 28rpx;
      font-weight: 600;
    }
    ._price {
      font-weight: 600;
      color: #222;
    }
  }
  .information {
    display: flex;
    justify-content: space-between;
    font-size: 28rpx;
    align-items: flex-end;
    margin: 24rpx 0;
    ._label {
      font-size: 28rpx;
      color: #333;
    }
    ._title-right {
      font-size: 28rpx;
      color: #333;
    }
  }
  ._bottom {
    display: flex;
    justify-content: flex-end;
    font-size: 28rpx;
    align-items: flex-end;
    margin-top: 34rpx;
  }
}
</style>
