<wxs module="filters" src="../../../../utils/filter.wxs"></wxs>
<view wx:if="{{act}}" class="container">
    <view class="flex jc_sb">
        <view class="white">以下商品{{act.zhprice}}元任选{{act.zhbuyqty}}件</view>
        <view class="rule-container" bindtap="showRule">规则详情
            <text class="iconfont icon-arrow_right"></text>
        </view>
    </view>
    <view wx:if="{{djs}}" class="countdown-container">距开始还剩
        <text wx:if="{{djs.day}}">{{djs.day}}天</text>
        <text class="num-box">{{djs.hou}}</text>
        :
        <text class="num-box">{{djs.min}}</text>
        :
        <text class="num-box">{{djs.sec}}</text>
    </view>


   

    <!-- 商品列表 -->
    <view class="list-container">
        <scroll-view class="list" scroll-y bindscrolltolower="get_more_list">
            <block wx:for="{{list}}">
                <view class="list-item" bindtap="go_url"
                      data-url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}">
                    <view class="img-container">
                        <image src="{{iurl}}{{item.original_img?item.original_img:'/miniapp/images/default_g_img.gif'}}"
                               mode="aspectFit" class="img-block"></image>
                    </view>
                    <view class="pdl20 flex f1 fdc jc_sb"  >
                        <view>
                            <view class="fs30 ellipsis-2">{{item.goods_name}}</view>
                            <view class="c-fa8b2b fs28" wx:if="{{item.zhqty && (item.num<item.zhqty || !item.num)}}">此商品还需购买{{item.zhqty-(item.num?item.num:0)}}件</view>
                            <view class="num-container" wx:if="{{item.showNum}}">
                                <text class="num-box {{item.num<=1?'c-dedfe3':''}}" catchtap="sub"
                                      data-index="{{index}}">-</text>
                                <text class="num-box">{{item.num}}</text>
                                <text class="num-box" catchtap="add" data-index="{{index}}">+</text>
                            </view>
                        </view>

                        <view class="flex jc_sb ai_end pdt12">
                            <view>
                                <!-- 要判断实际价格，因为有等级卡价 -->
                                <block wx:if="{{card_field && item[card_field]>0}}">
                                    <text class="rmb fs30 c-red">{{filters.toFix(item[card_field],2)}}</text>
                                </block>
                                <block wx:else>
                                    <text class="rmb fs30 c-red">{{filters.toFix(item.shop_price,2)}}</text>
                                </block>
<!--                                <text class="rmb fs20 line-through cb">{{filters.toFix(item.market_price,2)}}</text>-->
                            </view>
                            
                        </view>
                    </view>
                </view>
            </block>

            <nodata wx:if="{{list.length==0 && is_get}}" nodataContainer="t-c"></nodata>
            <view wx:if="{{no_more}}" class="noMore">没有更多了</view>
        </scroll-view>

    </view>

    <!-- 底部栏 -->
    <view class="bar-container">
        <block wx:if="{{all_num>=act.zhbuyqty}}">
            <view wx:if="{{need_to_buy}}" class="t-c bg-fcfb c-fa8b2b fs28 pd20">
                再买{{need_to_buy}}件，下单立享【{{act.zhprice}}元任选{{act.zhbuyqty}}件】
            </view>
            <view wx:else class="t-c bg-fcfb c-fa8b2b fs28 pd20">下单立享【{{act.zhprice}}元任选{{act.zhbuyqty}}件】</view>
        </block>
        <block wx:else>
                <view wx:if="{{all_num>0}}" class="t-c bg-fcfb c-fa8b2b fs28 pd20">
                    再买{{act.zhbuyqty-all_num>need_to_buy?act.zhbuyqty-all_num:need_to_buy}}件，下单立享【{{act.zhprice}}元任选{{act.zhbuyqty}}件】
                </view>
                <view wx:else class="t-c bg-fcfb c-fa8b2b fs28 pd20">
                    买{{act.zhbuyqty}}件，下单立享【{{act.zhprice}}元任选{{act.zhbuyqty}}件】
                </view>
        </block>
   
    </view>
    <!-- 分享 -->
    <view wx:if="{{imgDraw}}" class="share-container" bindtap="share">
        <text class="iconfont icon-zhuanfa fs40"></text>
        <view class="fs22 c-8">分享</view>
    </view>


    <!-- 规则详情和提示信息弹窗 -->
    <view class="rule-pop-container" wx:if="{{showRule}}">
        <view class="pop-title">{{!type ? '规则详情':'提示'}}
            <text class="iconfont icon-guan" bindtap="closeRule"></text>
        </view>
        <block wx:if="{{!type}}">
            <view class="pdt40">
                <view class="pdb20">活动时间</view>
                <view class="">{{filters.format_time(act.start_time,1)}} 至 {{filters.format_time(act.end_time,1)}}
                </view>
            </view>
            <view class="pdt40">
                <view class="pdb20">活动内容</view>
                <view class="">
                    <view class="pdb10">{{act.remark}}</view>
                </view>
            </view>
        </block>

        <!-- 小的提示按钮的展示 -->
        <block wx:else>
            <view class="pdt40 pdb20">
                <view class="">合计金额及提示仅为初步预估，请以最终下单金额为准。</view>
            </view>
        </block>

        <view class="pdv20">
            <view class="btn" bindtap="closeRule">我知道了</view>
        </view>
    </view>

    <!-- 遮罩层 -->
    <view class="mask" wx:if="{{showMask}}" bindtap="close_all"></view>
    <!-- 海报 -->
    <view class="poster-container" wx:if="{{showPoster}}">
        <view class="t-r pdb20 white2">
            <text class="iconfont icon-close fs40" bindtap="closePoster"></text>
        </view>
        <image src="{{myimg}}" class="poster" show-menu-by-longpress></image>
        <view class="pdt10 fs26 white2">
            <text class="iconfont icon-zhiwen"></text>
            长按图片保存至相册
        </view>
    </view>

</view>

<painter style="position: absolute; top: -9999rpx;" palette="{{imgDraw}}" bind:imgOK="onImgOK"/>
<!-- 活动异常提醒 -->
<catch wx:if="{{error}}">{{error}}</catch>
<warn id="warn"></warn>
<!-- 选择门店的弹框，1.1版最新的 -->
<block wx:if="{{store==1}}">
    <view class="mongolia-layer" bindtap="close_popup"></view>
    <view class="popup-frame">
        <block wx:if="{{sort_store==0}}">
            <!-- 头部 标题 -->
            <view class="popup-top flex-space-between">
                <text class="fs32 nearby_store">{{choice_sort_store==0?'附近的门店':region_name}}</text>
                <view>
                    <view>
                        <icon bindtap="close_popup" class="modal-closes" color="black" size="22" type="cancel"></icon>
                    </view>
                    <view class="flex choose_more" bindtap="more_store" wx:if="{{is_show_sto_cat>0}}">
                        <text class="fs26 red-co" style="line-height: 30rpx;height: 30rpx" >{{choice_sort_store==0?'更多门店':'返回'}}</text>
                        <view class="bg_rights" ></view>
                    </view>
                </view>
            </view>
            <!-- 门店列表，最外层的门店列表，一开始 -->
            <view class="store-list">
                <!--如果还没有点击更多门店的时候  -->
                <block wx:if="{{choice_sort_store==0}}">
                    <!-- 需要for循环 -->
                    <block wx:if="{{is_show_sto_cat==1}}">
                        <view class="store_choose flex" wx:for="{{def_pickpu_list}}" bindtap="choose_for_store_fir"
                              data-ind="{{index}}">
                            <view class="store flex-vertical">
                                <!-- 需要点击事件 -->
                                <block wx:if="{{index==fir_pick_index}}">
                                    <view class="circle white xc-hook fs20 red-b">Г</view>
                                </block>
                                <block wx:else>
                                    <view class="circle  xc-hooks"></view>
                                </block>
                                <view class="address-frame xc-ash">
                                    <view class="flex-vertical-between butttem5">
                                        <view class="flex xc-ash">
                                            <view class="fs30 xc-black3 address_name">{{item.pickup_name}}
                                                <text wx:if="{{item.pickup_id==is_no_pipei}}" class="c-red">(不匹配)</text>
                                            </view>
                                        </view>
                                        <view>
                                            <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}">
                                                距离：{{item.distance>1000?filters.toFix(item.distance/1000,2)+'km':filters.toFix(item.distance,0)+"m"}}
                                            </view>
                                        </view>
                                    </view>
                                    <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
                                </view>
                            </view>
                        </view>
                    </block>
                    <block wx:else>
                        <view class="store_choose flex" wx:for="{{only_pk}}" bindtap="choose_for_store_fir"
                              data-ind="{{index}}">
                            <view class="store flex-vertical">
                                <!-- 需要点击事件 -->
                                <block wx:if="{{index==fir_pick_index}}">
                                    <view class="circle white xc-hook fs20 red-b">Г</view>
                                </block>
                                <block wx:else>
                                    <view class="circle  xc-hooks"></view>
                                </block>

                                <view class="address-frame xc-ash">
                                    <view class="flex-vertical-between ">
                                        <view class="flex xc-ash">
                                            <view class="fs30 xc-black3 address_name">{{item.pickup_name}}
                                                <text wx:if="{{item.pickup_id==is_no_pipei}}" class="c-red">(不匹配)</text>
                                            </view>
                                        </view>
                                        <view>
                                            <view class="distance fs24 address-val"
                                                  wx:if="{{item.distance!=null}}">
                                                距离：{{item.distance>1000?filters.toFix(item.distance/1000,2)+"km":filters.toFix(item.distance,0)+"m"}}
                                            </view>
                                        </view>
                                    </view>
                                    <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
                                </view>
                            </view>
                        </view>
                    </block>
                </block>
                <block wx:else> <!-- 如果是点击选择门店分类后显示分类下的门店  -->
                    <view class="store_choose flex" wx:for="{{sec_sto.s_arr}}" data-ind="{{index}}"
                          bindtap="choose_for_store">
                        <view class="store flex-vertical">
                            <!-- 需要点击事件 -->
                            <block wx:if="{{index==sec_pick_index}}">
                                <view class="circle white xc-hook fs20 red-b">Г</view>
                            </block>
                            <block wx:else>
                                <view class="circle  xc-hooks"></view>
                            </block>

                            <view class="address-frame xc-ash">
                                <view class="flex-vertical-between ">
                                    <view class="flex xc-ash">
                                        <view class="fs28 xc-black3 address_name">{{item.pickup_name}}</view>
                                    </view>
                                    <view>
                                        <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}">
                                            距离：{{item.distance>1000?filters.toFix(item.distance/1000,2)+"km":filters.toFix(item.distance,0)+"m"}}
                                        </view>
                                    </view>
                                </view>
                                <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
                            </view>
                        </view>
                    </view>
                </block>

            </view>

            <!-- 门店列表底部 -->
            <view class="store-bottom-frame">
                <view class="store-bottom flex-vertical-between">
                    <view class="determine red-b fs28 white t-c" bindtap="sure_pick"
                          data-openindstore="{{open_ind_store}}">确定
                    </view>
                    <view class="default  t-c fs28" bindtap="set_def_pick" data-openindstore="{{open_ind_store}}">设为默认
                    </view>
                </view>
            </view>

        </block>


        <block wx:else>
            <view class="popup-top flex-space-between">
                <text class="fs32 nearby_store">门店分类选择</text>
                <view>
                    <view>
                        <icon bindtap="close_popup" class="modal-closes" color="black" size="22" type="cancel"></icon>
                    </view>
                    <view class="felx choose_mores" bindtap="returns">
                        <text class="fs26 red-co">返回</text>
                    </view>
                </view>
            </view>
            <view class="sort_store_list">

                <view class="sort-store-frame" wx:for="{{all_sto}}" data-index="{{index}}" bindtap="choice_sort_store"
                      data-region="{{item.name}}">
                    <view class="sort-store flex-vertical-between">
                        <view class="fs30" di>{{item.name}}</view>
                        <view class="black_rights-frame">
                            <view class="black_rights"></view>
                        </view>
                    </view>
                </view>

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



