<!--components/static/good-detail-popup/good-detail-popup.wxml-->
<popup visible="{{showPopup}}" bind:close="closePopup">
    <view slot="header" class="popup-header">
        <view class="location">
            <image src="/assets/img/location.svg" class="icon"></image>
            <view class="address" bind:tap="handleSelcetLocation">{{defualtAddress}}</view>
        </view>
        <view class="info">
            <view class="left">
                <image src="{{checkItem ? checkItem.picUrl : skus[0].picUrl}}" mode="aspectFill" />
            </view>
            <view class="right">
                <view wx:if="skuId" class="price">
                    {{ checkItem ? checkItem.price?'￥'+checkItem.price/100:'暂无报价' : skus[0].price?'￥'+skus[0].price/100:'暂无报价' }}
                </view>
                <!-- 如果不显示库存的话最多可以加到99999去，显示的话就最多可以加到库存量去 -->
                <van-stepper integer max="{{showStock?checkItem ? checkItem.stock : skus[0].stock :99999}}" value="{{ count }}"
                    bind:change="onCountChange" />
                <view class="stock" wx:if="{{showStock}}">库存 {{ checkItem ? checkItem.stock : skus[0].stock }}
                    {{checkItem?checkItem.unit:goodList[0].stock}}
                </view>
            </view>
        </view>
    </view>

    <view class="sku-container" style="padding-bottom: {{hasTabBar?safeBottom+ 80 + 120 + 24 :safeBottom + 80+24}}rpx;">
        <view class="skuTitle">商品分类 ({{skus.length}})</view>
        <scroll-view scroll-y class="scroll">
            <view wx:for="{{skus}}" wx:key="skuId">
                <sku-item active="{{(skuId && skuId==item.skuId)?true:false}}" disable="{{item.stock===0?true:false}}"
                    bind:selectsku="onSetSkuId" item="{{item}}" />
            </view>
        </scroll-view>
    </view>
    <view class="footer">
        <view bind:tap="handleAddCart" class="submit add-cart" wx:if="{{show}}">
            加入购物车
        </view>
        <view class="footer">
            <view bind:tap="handleAddCart" wx:if="{{showShopCart}}" class="submit add-cart">
                加入购物车
            </view>
            <!-- bind:tap="handleSubmit" -->
            <view bind:tap="handleBeforeSubmit" class="submit"
                style="margin-bottom:{{hasTabBar? safeBottom/2 + 140  : safeBottom}}rpx;border-top-left-radius: {{showShopCart?0:24}}rpx;border-Bottom-left-radius: {{showShopCart?0:24}}rpx;">
                {{ skuId ? ('立即支付 ￥' + (checkItem.price * count / 100)) : '选择商品' }}
            </view>
        </view>
    </view>
</popup>

<coupon-popup
  id="couponPopup"
  bind:select="onCouponSelect"
/>