<import-sjs
  name="utils"
  from="./index.sjs"
/>
<import-sjs
  from="../utils-component/index.sjs"
  name="totalUtils"
/>
<wrapper>
  <view
    class="car-footer-container"
    style="{{`bottom: calc(${utils.getBottom(tabBarHight)}px + 12rpx)`}}"
  >
    <view
      id="carFixedEnd"
      class="car-id-hide"
    ></view>
    <view
      class="shopcar-button-container"
      hidden="{{globalCar.carts.length}}"
    >
      <!--   icon -->
      <view class="car-icon">
        <image
          class="car-icon-img"
          src="{{inactiveIcon}}"
        />
      </view>
      <!-- 按钮 -->
      <view class="car-button-container">
        去结算
      </view>
    </view>

    <view
      class="shopcar-button-container active"
      hidden="{{!globalCar.carts.length}}"
    >
      <view
        onTap="handleCarClick"
        class="car-click-box"
      >
        <!--   icon -->
        <view class="car-icon">
          <badge
            text="{{utils.getCarTotalNum(globalCar.carts || [])}}"
            overflowCount="{{99}}"
          >
            <image
              slot="inner"
              class="car-icon-img"
              src="{{activeIcon}}"
            />
          </badge>
        </view>
        <!--  金额 -->
        <view class="car-money">
          <view class="total">合计</view>
          <view class="price">
            <view class="price-icon">¥</view>{{globalCar.disCountTotalPrice || 0}}
          </view>
          <view
            class="pre-price"
            a:if="{{globalCar.totalPrice && globalCar.disCountTotalPrice !== globalCar.totalPrice}}"
          >¥{{globalCar.totalPrice}}</view>
        </view>
      </view>
      <!-- 按钮 -->
      <view
        a:if="{{showFlag && utils.isOnlyDeliver(globalCar.carts || [])}}"
        class="car-button-container {{totalUtils.calcNumber(globalCar.disCountTotalPrice, globalCar.deliveryPackingFee || 0)  >= startDeliveryAmount ? 'active' : ''}}"
        onTap="{{totalUtils.calcNumber(globalCar.disCountTotalPrice, globalCar.deliveryPackingFee || 0)  >= startDeliveryAmount ? 'handleToConfirm' : ''}}"
      >
        {{(totalUtils.calcNumber(globalCar.disCountTotalPrice, globalCar.deliveryPackingFee || 0)  >= startDeliveryAmount) ? '去结算' : `差${totalUtils.calcNumber(startDeliveryAmount, totalUtils.calcNumber(globalCar.disCountTotalPrice, globalCar.deliveryPackingFee || 0), 'sub')}起送`}}
        <am-icon
          a:if="{{totalUtils.calcNumber(globalCar.disCountTotalPrice, globalCar.deliveryPackingFee || 0)  < startDeliveryAmount}}"
          type="QuestionCircleOutline"
          color="#fff"
          size="6"
          onTap="showModal"
        />
      </view>
      <view
        a:else
        class="car-button-container {{utils.hasSelected(globalCar.carts || []) ? 'active' : ''}}"
        onTap="handleToConfirm"
      >
        去结算
      </view>
    </view>
  </view>
</wrapper>