<import-sjs
  name="carUtils"
  from="../goods-detail/index.sjs"
/>
<import-sjs
  from="./index.sjs"
  name="utils"
/>
<import-sjs
  from="../utils-component/index.sjs"
  name="priceUtils"
/>
<wrapper>
  <view class="goods-item-container">
    <view
      class="goods-item-box {{activeId === goodsItem.skuId ? 'goods-item-active' : ''}}"
      onTap="handleClick"
    >
      <!-- img -->
      <stock-img
        imgSrc="{{goodsItem.picList[0]}}"
        isNoStock="{{showStock && !goodsItem.stock}}"
      />
      <!-- 描述信息 -->
      <view class="goods-info">
        <!-- name -->
        <view class="name">{{goodsItem.name}}
        </view>
        <!-- unit 和 库存 -->
        <view class="unit-and-stock">
          <view class="unit">{{goodsItem.specDesc}}</view>
          <view
            a:if="{{showStock}}"
            class="{{goodsItem.stock >= goodsItem.quantity && goodsItem.stock  ? 'stock' : 'stock red'}}"
          >库存: {{goodsItem.stock || 0}}</view>
        </view>
        <!-- 限购 -->
        <view class="goods-limit">
          <view style="display: flex">
            <goods-tag
              a:if="{{goodsItem.buyLimitType === 'GENERAL'}}"
              text="限{{goodsItem.buyLimitCount}}份"
            />
            <goods-tag
              a:if="{{showBooking && goodsItem.userLimitType === 'BESPEAK'}}"
              text="{{goodsItem.isbespeak ? '已预约' : '去预约'}}"
              isbespeak="{{goodsItem.isbespeak}}"
              clickTip="{{goodsItem.activity.joinLinkTip}}"
              url="{{goodsItem.activity.joinLink}}"
              linkType="{{goodsItem.activity.joinLinkType}}"
            />
          </view>
          <view style="display: flex">
            <goods-tag
              a:if="{{showAuto && (goodsItem.deliverType.indexOf('AUTO') > -1 || goodsItem.deliverType.indexOf('MANUAL') > -1)}}"
              text="到店自提"
            />
            <goods-tag
              a:if="{{showAuto && goodsItem.deliverType.indexOf('DELIVERY') > -1}}"
              text="可配送"
            />
            <!-- <goods-tag
            a:if="{{showAuto && goodsItem.deliverType.indexOf('MANUAL') > -1}}"
            text="到店自提"
          /> -->
          </view>
        </view>
        <!-- price -->
        <view class="price-button-container">
          <view style="display: flex;flex: 1;flex-direction: column">
            <price-tag
              a:if="{{memberLevel && goodsItem.memberPrices}}"
              price="{{priceUtils.getMemberLevelPrice(goodsItem.memberPrices,memberLevel)}}"
              fontSize="22rpx"
              padding="2px 4px"
              maxWidth="164rpx"
            />
            <view style="display: flex;align-items: baseline;">
              <view class="price">
                <!-- (memberLevel && goodsItem.memberPrices) ? priceUtils.getMemberLevelPrice(goodsItem.memberPrices,memberLevel) :  -->
                <view class="price-icon">¥</view>
                {{goodsItem.sellPrice}}
              </view>
              <view
                class="pre-price"
                a:if="{{goodsItem.price !== goodsItem.sellPrice}}"
              >¥{{goodsItem.price}}</view>
            </view>
          </view>
          <!-- 步进器 -->
          <view
            class="step {{carUtils.isActive(goodsItem) ? '' : 'disable'}}"
            hidden="{{!goodsItem.quantity}}"
          >
            <stepper
              catchChange="changeNum"
              defaultNum="{{defaultNum}}"
              maxNum="{{utils.getMaxBuyNum(goodsItem)}}"
              targetId="{{targetId}}"
              numType="{{utils.getNumType(goodsItem)}}"
            />
          </view>
          <!-- plus -->
          <!--<view class="add-plus">
          +</view> -->
          <view
            catchTap="handelPlusClick"
            hidden="{{goodsItem.quantity}}"
            class="stepper-add {{carUtils.isActive(goodsItem) ? '' : 'disable'}}"
          >
            <am-icon
              type="add"
              size="{{10}}"
            />
          </view>
          <!--<view class="add-plus-disable">
          +</view> -->
        </view>
      </view>

    </view>
  </view>
</wrapper>