<template>
  <view class="detail">
    <view class="title">
      <view class="title-left">
        <image class="header-img" :src="avatar" mode=""></image>
        <text>{{ commodityInformation.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 commodityInformation.goods">
        <image class="commodity-img" :src="item.sku_item.image" mode=""></image>
        <view class="">
          <view class="commodity-2">
            <view class="commodity-title" v-show="language == 'zh-CN'"
              >{{ item.goods.name_cn }}
            </view>
            <view class="commodity-title" v-show="language == 'en-US'"
              >{{ item.goods.name_en }}
            </view>
            <view class="commodity-title" v-show="language == 'es-ES'"
              >{{ item.goods.name_es }}
            </view>
            <view class="commodity-title" v-show="language == 'it-IT'"
              >{{ item.goods.name_ita }}
            </view>
            <view class="commodity-price">
              <text style="font-size: 20rpx">￥</text>
              <text>{{ item.discount_price.split(".")[0] }}</text
              >.
              <text style="font-size: 20rpx">{{
                item.discount_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
      space="nbsp"
      style="font-size: 24rpx; text-align: right"
      v-if="commodityInformation.goods && language != 'zh-CN'"
      >{{ i18n.Atotalof }}
      <text>{{ "&nbsp;" + commodityInformation.goods.length + "&nbsp;" }}</text
      >{{ i18n.Atotalof + i18n.mineCommodity }} {{ "&nbsp;" }}</view
    >
    <view class="btn-list">
      <view
        space="nbsp"
        style="font-size: 24rpx"
        v-if="commodityInformation.goods && language == 'zh-CN'"
        >{{ i18n.Atotalof }} <text>{{ commodityInformation.goods.length }}</text
        >{{ i18n.Atotalof + i18n.mineCommodity }} {{ "&nbsp;" }}</view
      >
      <text style="font-size: 28rpx">{{ i18n.actualPayment }}</text>
      <view
        style="color: #222; font-weight: 600"
        v-if="commodityInformation.amount"
      >
        <text style="font-size: 20rpx">￥</text>
        <text>{{ commodityInformation.amount.split(".")[0] }}</text
        >.
        <text style="font-size: 20rpx">{{
          commodityInformation.amount.split(".")[1]
        }}</text>
      </view>
    </view>
    <view
      class="information"
      v-if="status == 'undelivered' || status == 'unfill'"
    >
      <text class="_label">{{ i18n.orderNotes }}</text>
      <view class="_title-right"> {{ commodityInformation.remark }}</view>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    status: {
      typeof: Number,
      default: 0,
    },
    commodityInformation: {
      typeof: Object,
      default: () => {
        return {};
      },
    },
    language: {
      typeof: String,
      default: "",
    },
  },
  computed: {
    i18n() {
      return this.$t("index");
    },
  },
  data() {
    return {
      avatar: "",
    };
  },
  watch: {
    commodityInformation(newVal) {
      console.log(newVal);
      if (newVal.member) {
        this.avatar = newVal.member.avatar;
      }
    },
  },
  methods: {
    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;
      margin-bottom: 10rpx;

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

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

        .commodity-title {
          width: 328rpx;
          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;
    align-items: center;
  }
  .information {
    display: flex;
    justify-content: space-between;
    font-size: 28rpx;
    align-items: flex-end;
    margin-top: 34rpx;
    ._label {
      font-size: 28rpx;
      color: #333;
    }
    ._title-right {
      font-size: 28rpx;
      color: #333;
      opacity: 0.6;
    }
  }
}
</style>
