<include file="public/header" title="搜索列表"  body=""/>
    <!--搜索栏-s-->
    <div class="classreturn whiback bornone">
        <div class="content">
            <div class="ds-in-bl return">
                <a href="javascript:history.back(-1);"><img src="__STATIC__/images/return.png" alt="返回"></a>
            </div>
            <div class="ds-in-bl search">
                <form action="" method="post">
                    <div class="sear-input">
                        <a href="{:U('Goods/ajaxSearch')}">
                            <input type="text" id="q" value="<?php echo urldecode(I('q'))?>">
                        </a>
                    </div>
                </form>
            </div>
            <div class="ds-in-bl menu">
                <a href="javascript:void(0);"><img src="__STATIC__/images/class1.png" alt="菜单"></a>
            </div>
        </div>
    </div>
    <!--搜索栏-e-->

    <!--顶部隐藏菜单-s-->
    <include file="public/top_nav"/>
    <!--顶部隐藏菜单-e-->

    <!--排序按钮-s-->
    <nav class="storenav p search_list_dump" id="head_search_box product_sort">
        <ul>
            <li>
                <span class="lb <if condition="(I('sort') eq 'is_new' or  I('sort') eq 'comment_count')">red</if>">综合</span>
                <i></i>
            </li>
            <li class="<if condition="I('sort') eq 'sales_sum'">red</if>">
                <a href="<?php echo urldecode(U('Mobile/Goods/search',array_merge($filter_param,array('sort'=>'sales_sum')),''));?>" >
                     <span class="dq">销量</span>
                </a>
            </li>
            <li class="<if condition="I('sort') eq 'shop_price'">red</if>">
                <a href="<?php echo urldecode(U('Mobile/Goods/search',array_merge($filter_param,array('sort'=>'shop_price','sort_asc'=>$sort_asc)),''));?>">
                    <span class="jg">价格 </span>
                    <i  class="pr  <if condition="I('sort_asc') eq 'asc'">bpr2</if>  <if condition="I('sort_asc') eq 'desc'"> bpr1 </if>"></i>
                </a>
            </li>
            <li >
                <span class="sx">筛选</span>
                <i class="fitter"></i>

            </li>
            <li>
                <i class="listorimg"></i>
            </li>
        </ul>
    </nav>
    <!--排序按钮-e-->

    <!--商品列表-s-->
    <div id="goods_list">
        <empty name="goods_list">
            <p class="goods_title" id="goods_title" style="line-height: 2rem;text-align: center;margin-top: 0.64rem; font-size:0.64rem">抱歉暂时没有相关结果，换个筛选条件试试吧</p>
        <else />
            <!--商品-s-->
            <foreach name="goods_list" item="vo" key="k">
                <div class="orderlistshpop p"  >
                    <div class="maleri30">
                            <div class="sc_list se_sclist">
                                <div class="shopimg fl">
                                    <a href="{:U('Mobile/Goods/goodsInfo',array('id'=>$vo[goods_id]))}" class="item"><img src="{$vo.goods_id|goods_thum_images=400,400}"></a>
                                </div>
                                <div class="deleshow fr">
                                    <div class="deletes">
                                        <a href="{:U('Mobile/Goods/goodsInfo',array('id'=>$vo[goods_id]))}" class="item"><span class="similar-product-text fl">{$vo.goods_name|getSubstr=0,20}</span></a>
                                    </div>
                                    <div class="prices">
                                        <p class="sc_pri fl"><span>￥</span><b>{$vo[shop_price]}元</b></p>
                                    </div>
                                    <p class="weight">
                                    	<span>{$vo[comment_count]}条评价</span>
                                        <span class="proli-eva">{$vo['comment_statistics']['high_rate']}%好评</span>
                                    	<span goods_id="{$vo.goods_id}" class="add_cart"><img src="__STATIC__/images/red-icon-cart.png" alt=""></span>
                                    </p>
                                </div>
                            </div>
                    </div>
                </div>
            </foreach>
            <!--商品-e-->
        </empty>
    </div>
    <!--商品列表-e-->
    <!--综合筛选弹框-s-->
    <div class="fil_all_comm">
        <div class="maleri30">
            <ul>
                <li >
                    <a href="<?php echo urldecode(U('Mobile/Goods/search',array_merge($filter_param,array('sort'=>'')),''));?>" class="<if condition="(I('sort') eq '')">on red</if>" >综合</a>
                </li>
                <li >
                    <a href="<?php echo urldecode(U('Mobile/Goods/search',array_merge($filter_param,array('sort'=>'is_new')),''));?>" class="<if condition="(I('sort') eq 'is_new')">on red</if>">新品</a>
                </li>
                <li >
                    <a href="<?php echo urldecode(U('Mobile/Goods/search',array_merge($filter_param,array('sort'=>'comment_count')),''));?>" class="<if condition="I('sort') eq 'comment_count'">on red</if>">评价</a>
                </li>
            </ul>
        </div>
    </div>
    <!--综合弹框-e-->

    <!--筛选-s-->
    <div class="screen_wi">
        <div class="classreturn loginsignup">
            <div class="content">
                <div class="ds-in-bl return seac_retu">
                    <a href="javascript:void(0);" ><img src="__STATIC__/images/return.png" alt="返回"></a>
                </div>
                <div class="ds-in-bl search center">
                    <span class="sx_jsxz">筛选</span>
                </div>
                <div class="ds-in-bl suce_ok ">
                    <a href="javascript:void(0);">确定</a>
                </div>
            </div>
        </div>

        <!--顶部筛选-s-->
        <div class="popcover">
            <ul>
                <li>
                    <span <if condition="$Request.param.sel eq 'all' or $Request.param.sel eq 'all'">class="ch_dg"</if>>
                    显示全部<input type="hidden"  class="sel" value="all" >
                    </span>
                </li>
                <li>
                    <span <if condition="$Request.param.sel eq 'free_post'">class="ch_dg"</if>>
                    仅看包邮<input type="hidden"  value="free_post" >
                    </span>
                </li>
                <li>
                    <span <if condition="$Request.param.sel eq 'store_count'">class="ch_dg"</if>>
                    仅看有货<input type="hidden"  value='store_count'>
                    </span>
                </li>
                <li>
                    <span <if condition="$Request.param.sel eq 'prom_type'">class="ch_dg"</if>>
                    促销商品<input type="hidden"  value="prom_type" >
                    </span>
                </li>
            </ul>
        </div>
        <!--筛选顶部-e-->

        <!--一级筛选条件-s-->
        <div class="list-se-all ma-to-20 one-related" >
            <!--品牌-s-->
            <notempty name="filter_brand">
                <div class="myorder p " onclick="filtercriteria('brand')">
                    <div class="content30" >
                        <a href="javascript:void(0)">
                            <div class="order" >
                                <div class="fl">
                                    <span>品牌</span>
                                </div>
                                <div class="fr">
                                    <i class="Mright"></i>
                                </div>
                            </div>
                        </a>
                    </div>
                </div>
            </notempty>
            <!--品牌-e-->

            <!--价格-s-->
            <if condition="$filter_price neq null">
            <div class="myorder p" onclick="filterprice()" >
                <div class="content30">
                    <a href="javascript:void(0)">
                        <div class="order" >
                            <div class="fl">
                                <span>价格</span>
                            </div>
                            <div class="fr">
                                <i class="Mright"></i>
                            </div>
                        </div>
                    </a>
                </div>
            </div>
            </if>
            <!--价格-e-->
            <input type="hidden" id="key" value="" />
        </div>
        <!--一级筛选条件-e-->

        <!--二级刷选条件-->
        <div class="list-se-all ma-to-20 two-related">
            <!--商品品牌筛选-s-->
            <foreach name="filter_brand" item="brand" key="brandk">
                <div class="myorder p filter brnda" data-val='{$brand[id]}'>
                    <div class="content30">
                        <div class="order">
                            <div class="fl">
                                <span>{$brand[name]}</span>
                            </div>
                            <div class="fr">
                                <i class=""><input type="checkbox" style="display: none;"  value="{$brand[id]}"/></i>
                            </div>
                        </div>
                    </div>
                </div>
            </foreach>
            <!--商品品牌筛选-e-->

            <!--价格筛选-s-->
            <foreach name="filter_price" item="price" key="pricek">
                <div class="myorder p tow-price">
                    <div class="content30">
                        <a href="{$price[href]}">
                            <div class="order">
                                <div class="fl">
                                    <span>{$price[value]}</span>
                                </div>
                                <div class="fr">
                                    <i class=""></i>
                                </div>
                            </div>
                        </a>
                    </div>
                </div>
            </foreach>
            <!--价格筛选-e-->
        </div>
        <!--二级刷选条件-e-->
    </div>
    <!--筛选-e-->

<!--选择属性的弹窗-s-->
    <form name="buy_goods_form" method="post" id="buy_goods_form">
 
    </form>
<!--选择属性的弹窗-e-->


<!--底部按钮-s-->
<div class="podee">
    <div class="cart-concert-btm p">
        <div class="fl">
            <ul>
                <li>
                    <if condition="(!empty($kf_config['im_choose'])) && ($kf_config['im_choose'] eq 1)">
                        <!--im客服-->
                        <a class="kf" href="{:U('supplier/index')}">
                            <i></i>
                            <p>客服</p>
                        </a>
                        <elseif condition="(!empty($kf_config['im_choose'])) && ($kf_config['im_choose'] eq 2)" />
                        <!--小能客服-->
                        <a href="javascript:;">
                            <i></i>
                            <p>客服</p>
                        </a>
                        <else />
                        <!--早先客服-->
                        <!--<a href="tel:{$tpshop_config['shop_info_phone']}">-->
                        <a href="tencent://message/?uin={$tpshop_config['shop_info_qq']}&Site=TPshop商城&Menu=yes">
                            <i></i>
                            <p>客服</p>
                        </a>
                    </if>
                </li>
                <li>
                    <a href="{:U('Mobile/Cart/index')}" >
                        <span id="tp_cart_info"></span>
                        <i class="gwc"></i>
                        <p>购物车</p>
                    </a>
                </li>
            </ul>
        </div>
        <div class="fr">
            <ul>
                <li class="r" id="join_cart_li" style="float:right">
                    <a class="pb_plusshopcar buy_button choise_num" href="/Mobile/Cart/index.html">去购物车</a>
                </li>
            </ul>
        </div>
    </div>
</div>
<!--底部按钮-e-->

<script type="text/javascript" src="__STATIC__/js/sourch_submit.js"></script>
<div class="mask-filter-div" style="display: none;"></div>
<script>
    $(document).ready(function () {
        ajax_header_cart();
    });
        //确定按钮
        $('.suce_ok').click(function(){
            //判断当前二级筛选状态
            if($('.suce_ok').is('.two')) {
//                        get_parment += 'spec=@'+key+'_'+val.join('_');
////                        $('.screen_wi,.popcover,.one-related').show();
////                        $('.two-related').hide();
////                        $('.sx_jsxz').html('筛选');
////                        $('.suce_ok').removeClass('two');
                var t=$('#key').attr('class');
                submitMoreFilter(t);
            }else{
                var sel = $('.sel').val();
                // 组装请求的url
                var url = '';
                for ( var k in get_parment )
                {
                    if(k != 'a' && k != 'c' && k != 'm' && k!='price'){
                        url += "&"+k+'='+get_parment[k];
                    }
                }
                if(sel){
                    url += '&sel='+sel;
                }
                location.href= "/index.php?m=Mobile&c=Goods&a=search"+url;
            }
        })
        //返回按钮
        $('.seac_retu').click(function(){
            //判断当前二级筛选状态
            if($('.suce_ok').is('.two')){
                $(".filterspec").each(function(i,o){
                    //去掉全部选择
                    $(o).find('.fr input').attr('checked',false);
                });
                $('#key').removeAttr('class');
                //显示一级筛选
                $('.screen_wi,.popcover,.one-related').show();
                $('.two-related').hide();
                $('.sx_jsxz').html('筛选');
                $('.suce_ok').removeClass('two');
            }else{
                $('.screen_wi').animate({width: '0', opacity: 'hide'}, 'normal',function(){
                    undercover();
                    $('.screen_wi').hide();
                });
            }
        })
    //筛选弹窗的品牌筛选
    function filtercriteria(criteria){
        $('#key').addClass(criteria);
        $('.filter').show();
        $('.tow-price').hide();
    }

    //筛选弹窗的价格筛选
    function filterprice(){
        $('.tow-price').show();
        $('.filter').hide();
    }

    //加载更多商品
    var  page = 1;
    /*** ajax 提交表单 查询订单列表结果*/
    var ajax_status = 1;
    function ajax_sourch_submit(){
        if(ajax_status == 0){
            return false;
        }
        ajax_status = 0;
        page += 1;
        $.ajax({
            type : "GET",
            url:"{:U('Mobile/Goods/search')}",//+tab,
            data:{brand_id:'{$Request.param.brand_id}',id:'{$Request.param.id}',sort:'{$Request.param.sort}',sort_asc:'{$Request.param.sort_asc}',sel:'{$Request.param.sel}',q:$('#q').val(),is_ajax:1,p:page},
            success: function(data)
            {
                ajax_status = 1;
                if($.trim(data) == ''){
                    // $('#getmore').hide();
                }else{
                    $("#goods_list").append(data);
                }
            }
        });
    }

    //筛选菜单栏切换效果
    var lb = $('.search_list_dump .lb')
    var fil = $('.fil_all_comm');
    var cs = $('.classreturn,.search_list_dump');
    var son = $('.search_list_dump .jg').siblings();
    $(function(){
    $('.storenav ul li span').click(function(){
        $(this).parent().parent().addClass('red').siblings('li').removeClass('red')
        if(!$(this).hasClass('lb')){
            fil.hide();
            undercover();
            cs.removeClass('pore');
        }
        if(!$(this).hasClass('jg')){
            son.removeClass('bpr1');
            son.removeClass('bpr2');
        }
    });


    //综合
    lb.click(function(){
        fil.show();
        cover();
        cs.addClass('pore');
    });

    lb.html($('.on').html());


     //显示隐藏筛选弹窗
    $('.search_list_dump .sx').click(function(){
        $('body').css('position','relative');
        $('.screen_wi').animate({width: '14.4rem', opacity: 'show'}, 'normal',function(){
            $('.screen_wi').show();
            cover();
        });
    })

    //  筛选顶部 筛选1-popcover
    $('.popcover ul li span').click(function(){
        //给span添加样式，并给其子代input添加class
        $(this).addClass('ch_dg').find('input').addClass('sel');
        $(this).parent('li').siblings('li').find('span').removeClass('ch_dg')
                .find('input').removeClass('sel');
    })

    // 一级筛选条件筛选2-one-related
    $('.one-related .myorder .order').click(function(){
        $('.two-related').show();
        $('.suce_ok').addClass('two');
        $('.tow-price,.one-related,.popcover').hide();
        $('.sx_jsxz').html($(this).find('.fl span').text());
    })

    //筛选3-two-related
    $(function(){
        $('.two-related .myorder .order').click(function(){
            var mright = $(this).find('.fr i');
            var input = mright.find("input");
            mright.toggleClass('Mright');
            //改变复选框状态
            mright.hasClass('Mright') ? input.attr('checked',true) : input.attr('checked',false);
        })
    })

    //切换商品排列样式
    $('.listorimg').click(function(){
        $(this).toggleClass('orimg');
        $('#goods_list').toggleClass('addimgchan');
    })
})

    //############   点击多选确定按钮      ############
    // t 为类型  是品牌 还是 规格 还是 属性
    // btn 是点击的确定按钮用于找位置
    get_parment = <?php echo json_encode($_GET); ?>;
    function submitMoreFilter(t){
        var val = new Array();  // 请求的参数值
        $(".filter").each(function(i,o){
            var che=$(o).find('.fr input');
            if(che.attr('checked')){    //选中的值
                val.push(che.val());
            }
        });
        // 没有被勾选的时候
        if(key == ''){
            return false;
        }
        // 品牌
        if(t == 'brand')
        {
            get_parment.brand_id = val.join('_');
        }

        // 组装请求的url
        var url = '';
        for ( var k in get_parment )
        {
            if(k != 'a' && k != 'c' && k != 'm') {
                url += "&" + k + '=' + get_parment[k];
            }
        }
        location.href ="/index.php?m=Mobile&c=Goods&a=search"+url;
    }

    $(document).on("click",".add_cart",function(e){
        var goods_id=$(this).attr("goods_id");
        $.post("{:U('Mobile/Goods/Goodsinfo2')}",{'id':goods_id},function(res){
            $('#buy_goods_form').html(res);
            $('#join_cart').text('确定');
            $('#join_cart').width('100%').show();
            $('#join_cart').attr('data-id',1);
            $('.choose_shop_aready').show();
            $('.podee').hide();
            //$('.mask-filter-div').show();
        });
    })

    //ajax请求购物车列表
    function ajax_header_cart(){
        var cart_cn = getCookie('cn');
        if (cart_cn == '') {
            $.ajax({
                type: "GET",
                url: "/index.php?m=Home&c=Cart&a=header_cart_list",//+tab,
                success: function (data) {
                    cart_cn = getCookie('cn');
                }
            });
        }
        $('#tp_cart_info').html(cart_cn);
    }

    // function ajax_sourch_submit(){};//没用,只是为了覆盖头部引用的JS
</script>
</body>
</html>
