<import-sjs
  name="utils"
  from="./index.sjs"
/>
<wrapper>
  <view
    class="card-container"
    onTap="navigateToDetail"
  >
    <!-- head -->
    <view class="card-head">
      <!-- left store and status -->
      <view class="card-head-left">
        <!-- store -->
        <view class="store">
          <!-- img -->
          <default-img
            src="{{item.shop.logo}}"
            class="store-img"
            height="42rpx"
            width="42rpx"
          />
          <!-- name -->
          <view class="store-name">
            {{item.shop.storeName}}
          </view>
        </view>
        <!-- address -->
        <view class="address-info">
          地址：{{item.shop.address}}
        </view>
      </view>
      <!-- status -->
      <view class="card-head-right">
        <view class="{{`status-${utils.getColor(item.status)}`}}">
          {{utils.getText(item.status,item.deliverType)}}
        </view>
        <view
          a:if="{{item.refundStatus !== 'NONE'}}"
          class="status-refund"
        >{{item.refundDetailStatus !== 'REFUND' ? '退货退款' : '仅退款'}}</view>
        <view
          class="status-time"
          a:if="{{item.status === 'WAIT_PAY' || item.status === 'NEW'}}"
        >
          <mas-countdown
            second="{{utils.getDeadLineTime(item.gmtOrderTimeout)}}"
            minDigits="{{2}}"
            onTimeup="onTimeup"
            showDay="{{false}}"
            showHour="{{false}}"
            containerClass="time-container"
            numberItemClass="time-number"
            splitorItemClass="split"
          />
        </view>
      </view>
    </view>
    <!-- goodslist -->
    <view class="goods-list">
      <!-- scorll-view -->
      <scroll-view
        scroll-x="{{true}}"
        class="goods-scroll"
      >
        <block a:for="{{item.goods}}">
          <!-- item -->
          <view class="goods-scroll-item">
            <default-img
              class="img"
              src="{{item.picList[0]}}"
              height="120rpx"
              width="120rpx"
            />
            <view class="name">
              {{item.name}}
            </view>
          </view>
        </block>

      </scroll-view>
      <view class="goods">
        <view class="goods-price">
          ¥{{item.totalAmount}}
        </view>
        <view
          class="goods-deliver"
          a:if="{{item.deliverType === 'DELIVERY'}}"
        >
          (含配送)
        </view>
        <view class="goods-num">
          共{{utils.getTotalNum(item.goods)}}件
        </view>
      </view>
    </view>
    <!-- footer -->
    <view
      catchTap="a"
      class="footer"
    >
      <order-center-button
        status="{{item.status}}"
        onClick="navigateToDetail"
      />
      <block a:if="{{item.status === 'UNDELIVERED' && item.deliverType === 'DELIVERY'}}">
        <view
          class="contact-btn"
          onTap="makePhoneCall"
        >
          联系商家
        </view>
        <modal
          onConfirm="handleBtnClick"
          dataType="deliveryInfo"
          zIndex="999"
          buttons="{{item.deliveryInfo.type === 'MERCHANT' ? deliveryInfoBtn : deliveryInfoCopyBtn}}"
        >
          <view
            class="modal-header"
            slot="header"
          >配送信息</view>
          <block a:if="{{item.deliveryInfo.type === 'MERCHANT'}}">
            <view class="normal-modal-text">该订单由商家配送，无配送物流</view>
          </block>
          <block a:if="{{item.deliveryInfo.type === 'LOGISTICS'}}">
            <view class="deliver-modal-container">
              <view class="deliver-modal-container-title">
                配送物流:
              </view>
              <view class="deliver-modal-text">{{item.deliveryInfo.logisticsName}}</view>
            </view>
            <view class="deliver-modal-container">
              <view class="deliver-modal-container-title">
                配送单号:
              </view>
              <view class="deliver-modal-text"> {{item.deliveryInfo.logisticsNo}}</view>
            </view>
          </block>
          <view slot="click">
            <view class="deliver-btn">
              配送信息
            </view>
          </view>
        </modal>
        <!-- <modal
          onConfirm="handleBtnClick"
          dataType="confirmReceive"
          zIndex="999"
          buttons="{{confirmReceiveBtn}}"
        >
          <view
            class="modal-header"
            slot="header"
          >确认收货</view>
          <view class="normal-modal-text">为保障您的权益，请收货商品确认无误再确认收货</view>
          <view slot="click">
            <view class="confirm-deliver-btn">
              确认收货
            </view>
          </view>
        </modal> -->
        <view
          onTap="handleConfirmReceive"
          class="confirm-deliver-btn"
        >
          确认收货
        </view>
      </block>
    </view>
  </view>
</wrapper>