<!-- pages/orderList/orderList.wxml -->
<view class='container'>
  <!-- 头部菜单 -->
  <view class='order-tit'>
    <text bindtap='onStsTap' data-sts="0" class="{{sts==0?'on':''}}">全部</text>
    <text bindtap='onStsTap' data-sts="1" class="{{sts==1?'on':''}}">待支付</text>
    <text bindtap='onStsTap' data-sts="2" class="{{sts==2?'on':''}}">待发货</text>
    <text bindtap='onStsTap' data-sts="3" class="{{sts==3?'on':''}}">待收货</text>
    <text bindtap='onStsTap' data-sts="5" class="{{sts==5?'on':''}}">已完成</text>
  </view>
  <!-- end 头部菜单 -->
  <view class='main'>
    <!-- <view class="empty" wx:if="{{list.length==0}}">这里还没有相关订单~</view> -->
    <!-- 订单列表 -->
    <block wx:for="{{list}}" wx:key='orderNumber'>
      <view class='prod-item'>
        <!-- 店铺 -->
        <!-- bindtap='toShopIndex' data-shopid="{{item.shopId}}" -->
        <view class="shop-box">
          <view class="shop-icon">
            <image src="../../images/icon/shop.png"></image>
          </view>
          <view class="shop-name">{{item.shopName}}</view>
        </view>
        <!-- 订单编号 -->
        <view class="order-num">
          <text>订单编号：{{item.orderNumber}}</text>
          <view class='order-state'>
            <text class="order-sts {{item.status<5?'red':''}}">{{['','待支付','待发货','待收货','待评价','已完成','已取消','拼团中'][item.status]}}</text>
            <!-- 退款状态 -->
            <view class="red">
              <text wx:if="{{item.returnMoneySts==0}}"></text>
              <text wx:if="{{item.returnMoneySts==1||item.returnMoneySts==2||item.returnMoneySts==3||item.returnMoneySts==4}}">(退款中)</text>
              <text wx:if="{{item.returnMoneySts==5||item.returnMoneySts==7}}">(退款完成)</text>
              <text wx:if="{{item.returnMoneySts==-1}}">(退款关闭)</text>
            </view>
            <!-- /退款状态 -->
            <view class='clear-btn' wx:if="{{item.status==5 || item.status==6}}">
              <image src='../../images/icon/clear-his.png' class='clear-list-btn' bindtap='delOrderList' data-ordernum="{{item.orderNumber}}"></image>
            </view>
          </view>
        </view>
        <!-- 商品列表 -->
        <!-- 一个订单单个商品的显示 -->
        <block wx:if="{{item.orderItemDtos.length==1}}">
          <block wx:for="{{item.orderItemDtos}}" wx:for-item="prod" wx:key='prodId'>
            <view>
              <view class='item-cont' bindtap='toOrderDetailPage' data-ordernum="{{item.orderNumber}}">
                <view class='prod-pic'>
                  <image src='{{prod.pic}}'></image>
                </view>
                <view class='prod-info'>
                  <view class='prodname'>{{prod.prodName}}</view>
                  <view class="sku-box">
                    <!-- 拼团icon -->
                    <view class="spell-group-icon" wx:if="{{item.orderType}}">
                      <!-- orderType 订单类型(0普通订单 1团购订单 2秒杀订单) -->
                      <text class="group-text">{{['','拼团','秒杀','积分'][item.orderType]}}</text>
                    </view>
                    <!-- /拼团icon -->
                    <view class='prod-info-cont'>{{prod.skuName||''}}</view>
                  </view>
                  <view class='price-nums'>
                    <text class='prodprice'>
                      <text class='symbol' wx:if="{{item.actualTotal}}">￥</text>
                      <text class='big-num' wx:if="{{item.actualTotal}}">{{wxs.parsePrice(prod.price)[0]}}</text>
                      <text class='small-num' wx:if="{{item.actualTotal}}">.{{wxs.parsePrice(prod.price)[1]}}</text>
                      <text class='small-num' wx:if="{{item.actualTotal && item.orderType==3}}" decode="{{true}}">&nbsp;+&nbsp;</text>
                      <text class='big-num' wx:if="{{prod.useScore && item.orderType==3}}">{{prod.useScore}} <text class='small-num'>积分</text></text>
                    </text>
                    <text class="prodcount">x{{prod.prodCount}}</text>
                  </view>
                </view>
              </view>
            </view>
          </block>
        </block>
        <!-- 一个订单多个商品时的显示 -->
        <block wx:else>
          <view class='item-cont' bindtap='toOrderDetailPage' data-ordernum="{{item.orderNumber}}">
            <scroll-view scroll-x="true" scroll-left='0' scroll-with-animation="false" class="categories">
              <block wx:for="{{item.orderItemDtos}}" wx:for-item="prod" wx:key='prodId'>
                <view class='prod-pic'>
                  <!-- 拼团icon -->
                  <!-- <view class="spell-group-order"><image src="../../images/icon/spell-group-order.png"></image></view> -->
                  <!-- 拼团icon -->
                  <image src="{{prod.pic}}"></image>
                </view>
              </block>
            </scroll-view>
          </view>
        </block>
        <view class='total-num'>
          <text class="prodcount">共{{item.totalCounts}}件商品</text>
          <view class='prodprice price'>
            合计：
            <text class='symbol' wx:if="{{item.actualTotal}}">￥</text>
            <text class='big-num' wx:if="{{item.actualTotal}}">{{wxs.parsePrice(item.actualTotal)[0]}}</text>
            <text class='small-num' wx:if="{{item.actualTotal}}">.{{wxs.parsePrice(item.actualTotal)[1]}}</text>
            <text class='small-num' wx:if="{{item.actualTotal && item.orderType==3}}" decode="true">&nbsp;+&nbsp;</text>
            <text class='big-num' wx:if="{{item.orderType==3}}">{{item.orderItemDtos[0].useScore}} <text class='small-num'>积分</text></text>
            <!-- 纯积分支付的普通订单(积分抵扣了所有金额) -->
            <text class='big-num' wx:if="{{item.orderType==0 && item.actualTotal==0}}">{{item.userScore}} <text class='small-num'>积分</text></text>
          </view>
        </view>
        <!-- end 商品列表 -->
        <view class='prod-foot' wx:if="{{item.status == 1 || item.status == 2 || item.status == 3 || item.status==5 || (item.status==5 && item.orderItemDtos[0].commSts==0)}}">
          <view class='btn'>
            <text wx:if="{{item.status == 2 }}" class="button" bindtap="onRefundOrder" data-ordernum="{{item.orderNumber}}" hover-class='none'>取消订单</text>
            <text wx:if="{{item.status==1}}" class="button" bindtap="onCancelOrder" data-ordernum="{{item.orderNumber}}" hover-class='none'>取消订单</text>
            <!-- <text class="button warn" bindtap="" data-ordernum="{{item.orderNumber}}" hover-class='none'>再次购买</text> -->
            <text wx:if="{{item.status==1}}" class="button warn" data-ordertype="{{item.orderType}}" bindtap="onPayAgain" data-ordernum="{{item.orderNumber}}" hover-class='none'>付款</text>
            <text wx:if="{{item.status==3 || item.status==5}}" class="button" bindtap="toDeliveryPage" data-lat="{{item.latitude}}" data-lon="{{item.longitude}}" data-ordernum="{{item.orderNumber}}" hover-class='none'>查看物流</text>
            <text wx:if="{{item.status==3}}" class="button warn" bindtap="onConfirmReceive" data-ordernum="{{item.orderNumber}}" hover-class='none'>确认收货</text>
            <!-- 评价status==5 -->
            <text wx:if="{{item.status==5 && item.orderItemDtos[0].commSts==0}}" class="button warn" bindtap="onComment" data-info="{{item.orderItemDtos}}" data-ordernum="{{item.orderNumber}}" hover-class='none'>评价</text>
          </view>
        </view>
      </view>
    </block>
  </view>

  <!-- 空 -->
  <view class="empty" wx:if="{{!list.length}}">
    <view class="empty-icon">
      <image src="../../images/icon/empty.png"></image>
    </view>
    <view class="empty-text">这里还没有相关订单~</view>
  </view>

</view>
<!-- end 订单列表 -->
<wxs module="wxs" src="../../wxs/number.wxs" />