<template>
  <view
    class="detail"
    @click="$emit('toDetail', itemInfo)"
    v-if="itemInfo.order"
  >
    <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"
        :style="itemInfo.order.simplify_status == 'closed' ? 'color:#666' : ''"
        >{{ itemInfo.order.simplify_status_text }}</text
      >
    </view>
    <view
      class="commodity-information"
      v-for="item in itemInfo.order_goods"
      :key="item.id"
    >
      <view class="commodity-1">
        <image class="commodity-img" :src="item.sku_item.image" mode=""></image>
        <view style="width: 70%">
          <view class="commodity-2">
            <view class="commodity-title"> {{ item.goods.name_cn }} </view>
            <view class="commodity-price" v-if="item.sku_item">
              <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>

          <!-- 测试提需求去掉 -->
          <!-- <button
            v-if="itemInfo.order.status == 'unreview' && !item.refund"
            @click.stop="$emit('unreviewAfter', item)"
            class="application"
          >
            申请退款
          </button> -->
        </view>
      </view>
    </view>
    <view class="price">
      <text>需付款</text>
      <text style="font-size: 20rpx">￥</text>
      <text>{{ itemInfo.order.amount.split(".")[0] }}</text
      >.
      <text style="font-size: 20rpx">{{
        itemInfo.order.amount.split(".")[1]
      }}</text>
    </view>
    <view class="btn-list">
      <view
        class="more"
        v-if="itemInfo.order.simplify_status == 'finished'"
        @click.stop="more"
      >
        更多
      </view>
      <button
        class="status-1"
        @click.stop="$emit('cancellationOrder', itemInfo)"
        v-if="itemInfo.order.simplify_status == 'unpaid'"
      >
        取消订单
      </button>
      <button
        class="status-2"
        v-if="itemInfo.order.simplify_status == 'unpaid'"
        @click.stop="$emit('toPay', itemInfo)"
      >
        继续付款
      </button>
      <button
        class="status-1"
        @click.stop="$emit('deleteOrder', itemInfo)"
        v-if="
          itemInfo.order.simplify_status == 'closed' ||
          itemInfo.order.simplify_status == 'refund'
        "
      >
        删除订单
      </button>
      <button
        class="status-2"
        v-if="itemInfo.order.simplify_status == 'closed'"
        @click.stop="$emit('againOrder', itemInfo)"
      >
        再次购买
      </button>
      <button
        class="status-1"
        @click.stop="$emit('toLogistics', itemInfo)"
        v-if="
          itemInfo.order.simplify_status == 'delivered' ||
          itemInfo.order.simplify_status == 'finished'
        "
      >
        查看物流
      </button>
      <button
        class="status-1"
        v-if="
          itemInfo.order.simplify_status == 'refund' ||
          itemInfo.order.simplify_status == 'finished'
        "
        @click.stop="$emit('againOrder', itemInfo)"
      >
        再来一单
      </button>
      <button
        class="status-2"
        v-if="itemInfo.order.simplify_status == 'delivered'"
        @click.stop="$emit('confirm', itemInfo)"
      >
        确认收货
      </button>

      <button
        class="status-2"
        v-if="itemInfo.order.simplify_status == 'finished'"
        @click="$emit('toDetail', itemInfo)"
      >
        去评价
      </button>
      <u-transition :show="show">
        <view class="transition" @click.stop="$emit('deleteOrder', itemInfo)"
          >删除订单</view
        >
      </u-transition>
    </view>
  </view>
</template>

<script>
import textRight from "../../accountSecurity/component/textRight.vue";
export default {
  components: {
    textRight,
  },
  props: {
    itemInfo: {
      typeof: Object,
      default: {},
    },
  },
  computed: {},
  data() {
    return {
      show: false,
    };
  },
  watch: {
    itemInfo(newVal) {},
  },
  methods: {
    more() {
      this.show = !this.show;
    },
    // toEvaluate() {
    //   uni.navigateTo({
    //     url: "/pageD/evaluate/evaluate?",
    //   });
    // },
  },
};
</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: 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;
        }
      }
      .application {
        background-color: #fff;
        border-radius: 34rpx;
        padding: 0;
        margin: 0;
        // padding: 0 26rpx;
        font-size: 28rpx;
        color: #222;
        height: 58rpx;
        line-height: 58rpx;
        margin-left: 20rpx;
        border: 2rpx solid #979797;
        margin-top: 10rpx;
        width: 140rpx;
        font-size: 22rpx;
        float: right;
      }
    }
  }
  .price {
    display: flex;
    justify-content: flex-end;
    font-size: 28rpx;
    align-items: flex-end;
  }
  .btn-list {
    display: flex;
    justify-content: flex-end;
    margin-top: 34rpx;
    position: relative;
    .more {
      color: #777;
      font-size: 28rpx;
      line-height: 68rpx;
      margin-right: 20rpx;
    }
    .status-1 {
      background-color: #fff;
      border-radius: 34rpx;
      margin: 0;
      padding: 0;
      font-size: 28rpx;
      color: #222;
      width: 168rpx;
      height: 68rpx;
      line-height: 68rpx;
      margin-left: 20rpx;
      border: 2rpx solid #979797;
    }
    .status-2 {
      background-color: #ffffff;
      border-radius: 34rpx;
      margin: 0;
      padding: 0;
      font-size: 28rpx;
      color: #f83224;
      width: 168rpx;
      height: 68rpx;
      line-height: 68rpx;
      margin-left: 20rpx;
      border: 2rpx solid #f83224;
    }
  }
}
.transition {
  width: 164rpx;
  height: 88rpx;
  background: #ffffff;
  box-shadow: 0rpx 0rpx 20rpx -6rpx rgba(0, 0, 0, 0.3);
  position: absolute;
  bottom: 60rpx;
  left: 0;
  text-align: center;
  line-height: 88rpx;
  font-size: 26rpx;
  color: #222;
  z-index: 10000;
}
</style>
