<nav type="back" background-color="#46a9a4" title="订单列表" />

<view class="list" wx:if="{{orderList && orderList.length>0}}">
  <block wx:for="{{orderList}}" wx:key="index">
    <view class="order">
      <view class="orderNum">
        <view>
          <view>
            订单编号：
            <text data-text="{{item.orderNum}}" bind:tap="onCopy">{{item.orderNum}}</text>
          </view>
          <view style="margin-top: 10rpx;">下单时间：{{item.createdAt}}</view>
        </view>
        <view class="tag">{{statusMap_shop[item.status]}}</view>
      </view>


      <view class="addressbox" wx:if="{{item.distributeType=='delivery'}}">
        <!-- <view class="address">
            <view class="a">取</view>
            <view class="address2">
              <view class="address-address">{{item.address.full_region||'暂无'}} {{item.address.address||''}}</view>
              <view class="name" data-mobile="{{item.address.mobile}}" bind:tap="callPhone">{{item.address.name||''}} {{item.address.mobile||''}}</view>
            </view>
          </view> -->
        <!-- <view class="address">
          <view class="b">收</view>
          <view class="address2">
            <view class="address-address">{{item.info.address||'暂无'}}</view>
            <view class="name" data-mobile="{{item.terminus.mobile}}" bind:tap="callPhone">{{item.info.name||''}} {{item.info.mobile||''}}</view>
          </view>
        </view> -->
      </view>
      <view class="cart">
        <block wx:for="{{item.targetObject}}" wx:key="index" wx:for-item="childer">
          <view class="good_item">
            <image data-list="{{[childer.image]}}" bind:tap="previewImg" src="{{childer.image||'https://file-cloud.fmode.cn/13WZ0W7u3l/20240830/jq956l022025894.jpg?imageView2/1/w/200/h/200'}}" alt="" />
            <view class="left">
              <view class="name">{{childer.name}}</view>
              <block wx:if="{{item.specMap[childer.objectId].list}}">
                <view class="buttom" wx:for="{{item.specMap[childer.objectId].list}}" wx:for-item="spec_item" wx:key="spec_item">
                  <view class="price">
                    <text class="price">{{spec_item.spec}} ￥{{spec_item.price}}</text>
                  </view>
                  <view class="add">
                    <van-icon name="cross" />
                    {{spec_item.count}}
                  </view>
                </view>
              </block>
              <block wx:else>
                <view class="buttom">
                  <view class="price">
                    <text class="price">{{item.specMap[childer.objectId].spec}} ￥{{item.specMap[childer.objectId].price}}</text>
                  </view>
                  <view class="add">
                    <van-icon name="cross" />
                    {{item.specMap[childer.objectId].count}}
                  </view>
                </view>
              </block>

            </view>
          </view>
        </block>
      </view>

      <view class="li">
        <van-cell title="支付时间：{{item.payTime}}" />
        <van-cell title="发货信息" data-index="{{index}}" bind:tap="openShipments">
          <block wx:if="{{item.distributeType!='delivery'}}">
            自取
          </block>
          <block wx:elif="{{item.expressCompany.objectId&&item.trackingNumber}}">
            {{item.expressCompany.name||'未知快递公司'}}
            {{item.trackingNumber||'未知快递单号'}}
          </block>
          <block wx:else>
            未发货（点击发货）
          </block>
        </van-cell>

        <block wx:if="{{item.content||item.refundImgs.length>0}}">
          <van-cell title="退款详情" />
          <van-cell value="{{ item.content }}" />
          <view style="display: flex;justify-content: flex-end;">
            <block wx:for="{{item.refundImgs}}" wx:key="index" wx:for-index="ref_index" wx:for-item="ref_item">
              <image data-list="{{item.refundImgs}}" bind:tap="previewImg" style="width: 100rpx;height: 100rpx;" src="{{ref_item}}" mode="aspectFit" />
            </block>
          </view>
        </block>
      </view>
      <view class="totalPrice">合计：<text>￥{{item.totalPrice}}</text></view>

      <view class="btn">
        <!-- <button style="background:#d8faf8;color: #46a9a4;" data-index="{{index}}" bind:tap="delOrder">取消订单</button> -->
        <button wx:if="{{item.distributeType=='delivery'&&item.status=='200'}}" data-index="{{index}}" bind:tap="openShipments">前往发货</button>
        <button wx:if="{{item.distributeType=='verify'&&item.status=='200'}}" data-index="{{index}}" bind:tap="confirm_receipt">确认收货</button>
        <button wx:if="{{item.status=='500'||item.status=='602'}}" data-index="{{index}}" bind:tap="agree_refund">同意退款</button>
        <button wx:if="{{item.status=='500'}}" data-index="{{index}}" bind:tap="overrule_refund">驳回退款</button>
        <button wx:if="{{item.status=='601'}}" data-index="{{index}}" bind:tap="confirm_refund">确认退款</button>
      </view>
    </view>



  </block>
</view>

<!-- 发货弹框 -->
<van-popup class="refund_popup" custom-style="height: 800rpx" show="{{ isShipments }}" position="bottom" round bind:close="closeShipments">
  <view class="title">
    发货
  </view>
  <view class="refundPopup">
    <view class="address">
      <view class="b">收</view>
      <view class="address2">
        <view class="address-address" data-text="{{shipments_order.info.address}}" bind:tap="onCopy">{{shipments_order.info.address||orderList[shipments_index].expressCompany.name||'暂无'}}</view>
        <view class="name" data-text="{{shipments_order.info.name+' '+shipments_order.info.mobile}}" bind:tap="onCopy">{{shipments_order.info.name||''}} {{shipments_order.info.mobile||''}}</view>
      </view>
    </view>
    <van-cell-group>
      <van-cell bind:tap="openExpress" required title="快递公司" is-link value="{{checkExp.name||'请选择'}}" />
      <van-field model:value="{{ trackingNumber }}" required clearable label="快递单号" placeholder="请输入快递单号" bind:click-icon="onClickIcon" />
    </van-cell-group>
    
  </view>
  <button bind:tap="confirmShipment">确认</button>
</van-popup>


<!-- 指针查询 -->
<van-popup show="{{ isShowExpress }}" position="bottom" bind:close="closeExpress" round>
  <view class="expressPopup">
    <view class="title">选择快递公司</view>
    <van-search bind:change="valChange" placeholder="请输入搜索关键词" />
    <scroll-view class="itemBox" bindscrolltolower="getPointerItem" scroll-y>
      <block wx:for="{{expComList}}" wx:for-item="pointer_item" wx:key="pointer_item">
        <view class="item" data-index="{{index}}" bind:tap="checkPointer" style="color:{{checkExp.objectId==pointer_item.objectId?'#46a9a4':'black'}};">
          {{pointer_item.name}}
          <van-icon name="success" wx:if="{{checkExp.objectId==pointer_item.objectId}}" color="#46a9a4" />
        </view>
      </block>
    </scroll-view>
  </view>
</van-popup>