<view class="spec-goods">
    <image class="wh100 spec-img xc-distance-bottom" bindtap="previewImage" src="{{sele_g.original_img}}"
           binderror="pop_err_img" data-errorimg="data.original_img"></image>
    <view class="spec-goods-info">
        <view class="spec-goods-name ellipsis-2">{{sele_g.goods_name}}</view>
        <view class="flex ai_end xc-val-money">
            <text class="fs20">￥</text>
            <!-- 如果是等级会员，且有等级价 -->
            <block wx:if="{{card_field && sele_g[card_field]>0}}">{{sele_g[card_field]}}</block>
            <block wx:else>{{sele_g.shop_price}}</block>
        </view>

        <view class="flex">
            <view class="spec-goods-stock">已售：{{sele_g.sales_sum}}</view>
            <block wx:if="{{sales_rules>=2}}">

                <block wx:if="{{!filters.is_virtual_gd(sele_g.is_virtual)}}">
                    <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">
                        可售：{{def_pick_store.CanOutQty}}
                    </view>
                    <view class="spec-goods-stock" wx:else>可售:0</view>
                </block>

            </block>
            <block wx:else>
                <view class="spec-goods-stock">可售：{{sele_g.store_count}}</view>
            </block>
        </view>


    </view>

    <!-- 选择门店模块 -->
    <view class="flex-space-between address ai_end xc-width ">

        <view class="flex" wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
            <text class="fs30 xc-black3 shop_name {{def_pick_store.distance!=null?'max':''}} ">{{def_pick_store.pickup_name}}</text>
            <view class="distance fs24 xc-ash" wx:if="{{def_pick_store.distance!=null}}">
                距离:{{def_pick_store.distance > 1000 ? filters.toFix(def_pick_store.distance / 1000, 2) + "km" : filters.toFix(def_pick_store.distance, 0) + "m"}}

            </view>
        </view>

        <!-- 没有门店的时候 -->
        <view class="flex" bindtap="choice_store" wx:else>
            <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
            <view class="fs30" style="color:black;">选择门店</view>
        </view>

        <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28"
              bindtap="choice_store">更多门店<text class="right-arrow"></text>
        </view>
    </view>

    <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
    <block wx:else>
        <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view>
        <block wx:else>
            <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view>
            <view class="no_store" wx:elif="{{def_pick_store.is_no_dis_nor && is_normal}}">(该店不可售)</view>
            <view wx:elif="{{def_pick_store &&  !def_pick_store.CanOutQty  && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2}}">
                (库存不足)
            </view>
        </block>
    </block>
    <view class="fs24 xc-ash-9f xc-distance-top " wx:if="{{def_pick_store && def_pick_store.fulladdress}}">
        地址:{{def_pick_store.fulladdress}}
    </view>


    <!--商品的属性项目-->
    <view class="xc-goods-attribute">
        <view hidden="{{ismend==1}}" class="spec-name">商品规格</view>
        <view hidden="{{ismend==1}}" style="max-height: 120rpx;overflow-y: auto;">
            <view class="spec_bt {{sele_g.goods_id==item.goods_id?'act':''}}" bindtap="sele_spec" data-nor="1"
                  data-gid='{{item.goods_id}}' wx:for="{{sku_g_pt}}" wx:key="sku_g">
                {{item.gg}}
            </view>
        </view>
    </view>

    <view class="b_num">
        <view>购买数量</view>
        <view class="count">
            <view bindtap="{{goodsInputNum <= 1 ? '':'subCartNum'}}"
                  class="sub {{goodsInputNum <= 1 ? 'active':''}}">-
            </view>
            <input bindblur="inputCartNum" type="number" value="{{goodsInputNum}}"></input>
            <view bindtap="addCartNum" class="add">+</view>
        </view>
    </view>
</view>
<!-- 提示再买多少优惠 -->
<view style="margin-top: 35rpx;color:#333;font-size:28rpx;" wx:if="{{hui_condition}}">
    再买{{hui_condition.need}}
    <text wx:if="{{hui_condition.money}}">，免{{hui_condition.money}}元</text>
    <text wx:if="{{hui_condition.sale}}">，打{{hui_condition.sale}}折</text>
    <text wx:if="{{hui_condition.past==1}}">，包邮</text>
    <text wx:if="{{hui_condition.intValue>0}}">，送{{hui_condition.intValue}}积分</text>
    <text wx:if="{{hui_condition.couponId>0}}">，送优惠券</text>
    <text wx:if="{{hui_condition.gift_id>0}}">，送赠品</text>
    <text wx:if="{{hui_condition.lb_id>0}}">，送礼包</text>
    <text wx:if="{{hui_condition.zxlb_id>0}}">，送专享礼包</text>
</view>


<!-- 按钮部分 -->
<view class="spec-cart-btns">

    <!-- 根本就找不到门店 -->
    <block wx:if="{{def_pick_store && def_pick_store.is_no_dis}}">
        <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">
            配送不匹配
        </view>
    </block>
    <block wx:elif="{{def_pick_store && def_pick_store.is_no_dis_nor && is_normal}}">
        <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">
            该店不可售
        </view>
    </block>

    <block wx:else>
        <!-- 根本就找不到门店 -->
        <block wx:if="{{!only_pk && !def_pickpu_list}}">
            <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">
                库存不足
            </view>
        </block>
        <block wx:else>


            <block wx:if="{{only_pk && !only_pk.length}}">
                <view class="spec-cart-btn fs32" data-action="add"
                      style="background-color: #dcdcdc;color: #999;">库存不足
                </view>
            </block>
            <block wx:else>
                <block wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">
                    <view class="spec-cart-btn fs32" data-action="add"
                          style="background-color: #dcdcdc;color: #999">库存不足
                    </view>
                </block>
                <block wx:else>
                    <block wx:if="{{!def_pick_store}}">
                        <view class="spec-cart-btn fs32" data-action="add"
                              style="background-color: #dcdcdc;color: #999">请先选择门店
                        </view>
                    </block>
                    <block wx:else>
                        <block wx:if="{{sales_rules>=2  && !sele_g.whsle_id }}">
                            <view wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<1 }}" class="spec-cart-btn fs32" data-action="add"
                                  style="background-color: #dcdcdc;color: #999">库存不足
                            </view>
                            <block wx:else>
                                <view class="flex jc_sb">
                                    <view class="spec-cart-btn spec-buy w40 {{sp_seleing?'gray':''}}" bindtap="addCart"
                                          data-action="add" style="background-color: #ffb03f;">加入购物车
                                    </view>
                                    <view class="spec-cart-btn spec-buy w40 {{sp_seleing?'gray':''}}" bindtap="addCart"
                                          data-action="buy">立即购买
                                    </view>
                                </view>
                            </block>
                        </block>

                        <block wx:elif="{{data.store_count<1}}">
                            <view class="spec-cart-btn fs32" data-action="add"
                                  style="background-color: #dcdcdc;color: #999">库存不足
                            </view>
                        </block>


                        <block wx:else>
                            <view class="flex jc_sb">
                                <view class="spec-cart-btn spec-buy w40 {{sp_seleing?'gray':''}}" bindtap="addCart"
                                      data-action="add" style="background-color: #ffb03f;">加入购物车
                                </view>
                                <view class="spec-cart-btn spec-buy w40 {{sp_seleing?'gray':''}}" bindtap="addCart"
                                      data-action="buy">立即购买
                                </view>
                            </view>
                        </block>

                    </block>
                </block>
            </block>
        </block>
    </block>
</view>

