<import-sjs
  name="utils"
  from="./index.sjs"
/>
<wrapper>
  <head-nav-blue
    a:if="{{detailData}}"
    positionY="{{utils.judgePositionY(detailData)}}"
  >
    <view
      class="order-detail-container"
      a:if="{{orderId}}"
    >
      <!-- 交易状态内容 -->
      <view class="order-status">
        {{utils.getText(detailData.status,detailData.deliverType)}}
      </view>
      <view
        class="order-status-extra"
        style="margin-bottom: 24rpx"
        a:if="{{detailData.status === 'CLOSE' && detailData.refundStatus === 'FULL'}}"
      >
        商品已全部退款，订单自动关闭
      </view>
      <view a:if="{{!utils.hadPayed(detailData.status)}}">
        <mas-countdown
          second="{{utils.getDeadLineTime(detailData.gmtOrderTimeout)}}"
          minDigits="{{2}}"
          onTimeup="onTimeup"
          showDay="{{false}}"
          showHour="{{false}}"
          containerClass="time-detail-container"
          numberItemClass="time-detail-number"
          splitorItemClass="time-detail-split"
        />
      </view>
      <!-- qrcode -->
      <order-qr-code
        a:if="{{detailData.deliverType.indexOf('DELIVERY') === -1}}"
        redeemStatus="{{detailData.redeemStatus}}"
        redeemQrValue="{{detailData.redeemQrValue}}"
        status="{{detailData.status}}"
        unSend="{{detailData.deliverType.indexOf('MANUAL') > -1 && detailData.deliverStatus === 'UNSEND'}}"
        onConfirmClick="onConfirmClick"
        takeDeliveryTime="{{detailData.takeDeliveryTime}}"
        takeDeliveryStatus="{{detailData.takeDeliveryStatus}}"
      />
      <!-- 配送类型订单 -->
      <address-box
        a:if="{{detailData.deliverType === 'DELIVERY' && addressData}}"
        isEmpty="{{false}}"
        isDeliver="{{true}}"
        showIcon="{{false}}"
        emptyText="收货地址"
        title="收货人信息"
        addressItem="{{addressData}}"
      />
      <address-deliver-info
        a:if="{{detailData.deliverType === 'DELIVERY' && detailData.deliveryInfo}}"
        logistics="{{detailData.deliveryInfo}}"
        contactMobile="{{detailData.shop.contactMobile}}"
      />
      <!-- 地址栏 -->
      <view class="order-address">
        <mall-store-address
          title=""
          a:if="{{orderId}}"
          hasRefund="{{detailData.refundStatus !== 'NONE'}}"
          shop="{{detailData.shop}}"
          showMobile="{{detailData.deliverType !== 'DELIVERY' || !detailData.deliveryInfo.type || detailData.deliveryInfo.type === 'LOGISTICS'}}"
          contactMobile="{{detailData.shop.contactMobile}}"
          showNavigateIcon="{{true}}"
          orderId="{{orderId}}"
          refundDetailStatus="{{detailData.refundDetailStatus}}"
          refundTotalNum="{{detailData.refundTotalNum}}"
        ></mall-store-address>
        <!-- refund -->
      </view>
      <!-- 订单item -->
      <view class="order-list-container">
        <block a:if="{{list.length > 5 && !loadMore}}">
          <block a:for="{{list.slice(0,5)}}">
            <order-item orderItem="{{item}}"></order-item>
          </block>
        </block>
        <block a:else>
          <block a:for="{{list}}">
            <order-item orderItem="{{item}}"></order-item>
          </block>
        </block>
        <view
          class="load-more"
          onTap="loadMoreItem"
          a:if="{{list.length > 5 && !loadMore}}"
        >
          展开 {{list.length}} 件商品
        </view>
        <!-- 统计栏 -->
        <order-detail-foot-list detail="{{detailData}}" />
      </view>
    </view>
    <order-footer-button
      a:if="{{detailData.status}}"
      onCancel="handelCancel"
      onMoreNewOrder="handelMoreOrder"
      onPay="handelPay"
      showCancelBtn="{{!utils.hadPayed(detailData.status)}}"
      btnText="{{utils.hadPayed(detailData.status) ? '再来一单' : btnText}}"
      type="{{utils.hadPayed(detailData.status) ? 'MORE' : 'PAY'}}"
    />
    <fixed-btn
      text="确认收货"
      a:if="{{detailData.deliverType === 'DELIVERY' && detailData.status === 'UNDELIVERED'}}"
      onClick="onConfirmReceiveClick"
    />
  </head-nav-blue>
</wrapper>
<poll-fun
  onStartFun="handelStartFun"
  onFunCallBack="handelFunCallBack"
  totalCount="{{30}}"
  delayTime="{{3000}}"
  a:if="{{startPoll}}"
/>