<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>搜索列表</title>
	<link rel="stylesheet" type="text/css" href="__STATIC__/css/tpshop.css" />
	<script src="__STATIC__/js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="__PUBLIC__/js/layer/layer-min.js"></script>
	<script src="__PUBLIC__/js/global.js"></script>
	<script src="__PUBLIC__/js/pc_common.js"></script>
    <style>
		@media screen and (min-width:1260px) and (max-width: 1465px) {
			.w1430{width: 1224px;}
		}
		@media screen and (max-width: 1260px) {
			.w1430{width: 983px;}
		}
    </style>
</head>
<body>
<!--header-s-->
<include file="public/header" w='w1430'/>
<!--header-e-->
<div class="search-box p">
	<div class="w1430">
		<div class="search-path fl">
			<a href="{:U('Home/Goods/search',array('q'=>$filter_param['q']))}">搜索结果</a>
			<i class="litt-xyb"></i>
			<a href="{:U('Home/Goods/search',array('q'=>$filter_param['q']))}">{$filter_param['q']}</a>
			<i class="litt-xyb"></i>
            <foreach name="filter_menu" item="v" key="k">
                <a title="{$v['text']}" href="{$v['href']}" class="u-av-label">
                    <em>{$v[text]}</em>
                    <i>x</i>
                </a>
            </foreach>
		</div>
		<div class="search-clear fr">
			<span><a href="{:U('Home/Goods/search',array('q'=>$filter_param['q']))}">清空筛选条件</a></span>
		</div>
	</div>
</div>
<!-- 筛选 start -->
<div class="search-opt">
	<div class="w1430">
		<div class="opt-list">
			<!-- 品牌筛选 start -->
			<if condition="$filter_brand neq null">
				<dl class="brand-section m-tr">
					<dt>品牌</dt>
					<dd class="ri-section">
						<div class="lf-list">
							<div class="brand-box brand-list">
								<div class="clearfix p">
									<foreach name="filter_brand" item="v" key="k">
										<a href="{$v[href]}" data-href="{$v[href]}"  data-key='brand' data-val='{$v[id]}'>
											<i class="litt-zd"></i>
											<img src="{$v[logo]}"/>
											<span>{$v[name]}</span>
										</a>
									</foreach>
								</div>
                                <div class="surclofix p">
                                    <a href="javascript:;" class="u-confirm" onClick="submitMoreFilter('brand',this);">确定</a>
                                    <a href="javascript:;" class="u-cancel">取消</a>
                                </div>
							</div>
						</div>
						<div class="lr-more">
							<a href="javascript:void(0)"><span class="dx_choice">多选</span><i class="litt-pluscr"></i></a>
							<if condition="count($filter_brand) gt 10">
								<a href="javascript:void(0)"><span class="gd_more">更多</span><i class="litt-tcr"></i></a>
							</if>
						</div>
					</dd>
				</dl>
			</if>
			<!-- 品牌筛选 end -->
			<!-- 规格筛选 start -->
            <if condition="$filter_spec neq null">
                <foreach name="filter_spec" item="v" key="k">
                    <dl class="brand-section m-tr">
                        <dt>{$v.name}</dt>
                        <dd class="ri-section">
                            <div class="lf-list">
                                <div class="brand-list">
                                    <div class="clearfix p">
                                        <foreach name="v[item]" item="v2" key="k2">
                                            <a href="{$v2[href]}" data-href="{$v2[href]}" data-key='{$v2[key]}' data-val='{$v2[val]}'>
                                                <input class="shaix_la" type="checkbox" style="display: none"/>
                                                <span>{$v2[item]}</span>
                                            </a>
                                        </foreach>
                                    </div>
                                    <div class="surclofix p">
                                        <a href="javascript:;" class="u-confirm" onClick="submitMoreFilter('spec',this);">确定</a>
                                        <a href="javascript:;" class="u-cancel">取消</a>
                                    </div>
                                </div>
                            </div>
                            <div class="lr-more">
                                <a href="javascript:void(0)"><span class="dx_choice">多选</span><i class="litt-pluscr"></i></a>
                                <if condition="count($v['item']) gt 11">
                                    <a href="javascript:void(0)"><span class="gd_more">更多</span><i class="litt-tcr"></i></a>
                                </if>
                            </div>
                        </dd>
                    </dl>
                </foreach>
            </if>
			<!-- 规格筛选 end -->
            <!-- 属性筛选 start -->
            <if condition="$filter_attr neq null">
                <foreach name="filter_attr" item="v" key="k">
                    <dl class="brand-section m-tr">
                        <dt>{$v.attr_name}</dt>
                        <dd class="ri-section">
                            <div class="lf-list">
                                <div class="brand-list">
                                    <div class="clearfix p">
                                        <foreach name="v[attr_value]" item="v2" key="k2">
                                            <a href="{$v2[href]}" data-href="{$v2[href]}" data-key='{$v2[key]}' data-val='{$v2[val]}'>
                                                <input class="shaix_la" type="checkbox" style="display: none"/>
                                                <span>{$v2[attr_value]}</span>
                                            </a>
                                        </foreach>
                                    </div>
                                    <div class="surclofix p">
                                        <a href="javascript:;" class="u-confirm"  onClick="submitMoreFilter('attr',this);">确定</a>
                                        <a href="javascript:;" class="u-cancel">取消</a>
                                    </div>
                                </div>
                            </div>
                            <div class="lr-more">
                                <a href="javascript:void(0)"><span class="dx_choice">多选</span><i class="litt-pluscr"></i></a>
                                <if condition="count($v['attr_value']) gt 11">
                                    <a href="javascript:void(0)"><span class="gd_more">更多</span><i class="litt-tcr"></i></a>
                                </if>
                            </div>
                        </dd>
                    </dl>
                </foreach>
            </if>
            <!-- 属性筛选 end -->
			<!-- 价格筛选 start -->
			<if condition="$filter_price neq null">
				<dl class="brand-section m-tr">
					<dt>价格</dt>
					<dd class="ri-section">
						<div class="lf-list">
							<div class="brand-list">
								<div class="clearfix p">
									<foreach name="filter_price" item="v" key="k">
										<a href="{$v[href]}" data-href="{$v[href]}" data-key='{$v[key]}' data-val='{$v[val]}'>
											<span>{$v[value]}</span>
										</a>
									</foreach>
								</div>
							</div>
						</div>
						<div class="lr-more">
							<!--<a href="javascript:void(0)"><span class="dx_choice">多选</span><i class="litt-pluscr"></i></a>
                            <a href="javascript:void(0)"><span class="gd_more">更多</span><i class="litt-tcr"></i></a>-->
							<form action="<?php echo urldecode(U('/Home/Goods/search',$filter_param,''));?>" method="post" id="price_form">
								<input type="text" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" name="start_price" id="start_price" value=""/>
								<span>-</span>
								<input type="text" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onkeyup="this.value=this.value.replace(/[^\d]/g,'')"  name="end_price" id="end_price" value=""/>
								<input type="submit" value="确定" onClick="if($('#start_price').val() !='' && $('#end_price').val() !='' ) $('#price_form').submit();"/>
							</form>
						</div>
					</dd>
				</dl>
			</if>
			<!-- 价格筛选 end -->
		</div>
		<p class="moreamore"><a href="">浏览更多</a></p>
	</div>
</div>
<!-- 筛选 end -->
<div class="shop-list-tour ma-to-20 p">
	<div class="w1430">
		<div class="tjhot fl">
			<div class="sx_topb"><h3>推荐热卖</h3></div>
			<div class="tjhot-shoplist" id="ajax_hot_goods">
                <tpshop sql="select * from `__PREFIX__goods` where  is_recommend = 1 and is_on_sale = 1 limit 5" item="vo" key="k">
                    <div class="alone-shop">
                        <a href="{:U('Home/Goods/goodsInfo',array('id'=>$vo.goods_id))}"><img class="lazy" data-original="{$vo.goods_id|goods_thum_images=180,180}"/></a>
                        <p class="line-two-hidd"><a href="{:U('Home/Goods/goodsInfo',array('id'=>$vo.goods_id))}">{$vo.goods_name}</a></p>
                        <p class="price-tag"><span class="li_xfo">￥</span><span>{$vo.shop_price}</span></p>
                    </div>
                </tpshop>
			</div>
			<!--<div class="sx_topb ma-to-20"><h3>销量排行</h3></div>-->
			<!--<div class="tjhot-shoplist" id="ajax_sales_goods">-->
				<!--<script>-->
					<!--/****左侧边栏销量排行****/-->
					<!--function ajax_sales_goods() {-->
						<!--$.ajax({-->
							<!--type: "POST",-->
							<!--url: "/index.php?m=Home&c=Goods&a=ajaxSalesGoods",//+tab,-->
							<!--data:{filter_goods_id_str:"{$filter_goods_id_str}"},-->
							<!--success: function (data) {-->
								<!--if(data){-->
									<!--$('#ajax_sales_goods').html(data);-->
									<!--lazy_ajax();-->
								<!--}-->
							<!--}-->
						<!--});-->
					<!--}-->
				<!--</script>-->
			<!--</div>-->
		</div>
		<div class="stsho fr">
			<div class="sx_topb ba-dark-bg">
				<div class="f-sort fl">
					<ul>
						<li class="<if condition="$Request.param.sort eq ''">red</if>"><a href="<?php echo urldecode(U("/Home/Goods/search",$filter_param,''));?>">综合</a></li>
						<li class="<if condition="$Request.param.sort eq 'sales_sum'">red</if>"><a href="<?php echo urldecode(U("/Home/Goods/search",array_merge($filter_param,array('sort'=>'sales_sum')),''));?>">销量</a></li>
						<if condition="$Request.param.sort_asc eq 'desc'">
							<li class="<if condition="$Request.param.sort eq 'shop_price'">red</if>"><a href="<?php echo urldecode(U("/Home/Goods/search",array_merge($filter_param,array('sort'=>'shop_price','sort_asc'=>'asc')),''));?>">价格<i class="litt-zzx1"></i></a></li>
						<else />
							<li class="<if condition="$Request.param.sort eq 'shop_price'">red</if>"><a href="<?php echo urldecode(U("/Home/Goods/search",array_merge($filter_param,array('sort'=>'shop_price','sort_asc'=>'desc')),''));?>">价格<i class="litt-zzx1"></i></a></li>
						</if>
						<li class="<if condition="$Request.param.sort eq 'comment_count'">red</if>"><a href="<?php echo urldecode(U("/Home/Goods/search",array_merge($filter_param,array('sort'=>'comment_count')),''));?>">评论</a></li>
						<li class="<if condition="$Request.param.sort eq 'is_new'">red</if>"><a href="<?php echo urldecode(U("/Home/Goods/search",array_merge($filter_param,array('sort'=>'is_new')),''));?>">新品</a></li>
					</ul>
				</div>
				<!--<div class="f-address fl">-->
					<!--<div class="shd_address">-->
						<!--<div class="shd">收货地：</div>-->
						<!--<div class="add_cj_p"><input type="text" id="city" /></div>-->
					<!--</div>-->
				<!--</div>-->
				<div class="f-total fr">
					<div class="all-sec">共<span>{$page->totalRows}</span>个商品</div>
					<div class="all-fy">
						<php>$nowPage = $page->nowPage;$totalPages = $page->totalPages;</php>
						<a <if condition="$nowPage gt 1">href="{:U('Home/Goods/search',array_merge($filter_param,array('p'=>$nowPage-1)))}" </if>>&lt;</a>
						<p class="fy-y"><span class="z-cur">{$nowPage}</span>/<span>{$totalPages}</span></p>
						<a <if condition="($nowPage+1) lt $totalPages">href="{:U('Home/Goods/search',array_merge($filter_param,array('p'=>$page->nowPage+1)))}" </if>>&gt;</a>
					</div>
				</div>
			</div>
			<div class="shop-list-splb p">
				<ul>
                    <empty name="goods_list">
                        <p class="ncyekjl" style="font-size: 16px;margin:100px auto;text-align: center;">-- 抱歉没找到您要搜索的商品，换个条件试试！--</p>
                    <else/>
					    <foreach name="goods_list" item="v" key="k">
						<li>
							<div class="s_xsall">
								<div class="xs_img">
									<a href="{:U('/Home/Goods/goodsInfo',array('id'=>$v[goods_id]))}">
										<img class="lazy-list" data-original="{$v.goods_id|goods_thum_images=236,236}"/>
									</a>
								</div>
								<div class="xs_slide">
									<div class="small-xs-shop">
										<ul>
											<foreach name="goods_images" item="v2" key="k2">
												<if condition="$v2[goods_id] eq $v[goods_id]">
													<li>
														<a href="javascript:void(0);">
															<img class="lazy-list" data-original="{$v2|get_sub_images=$v[goods_id],236,236}"/>
														</a>
													</li>
												</if>
											</foreach>
										</ul>
									</div>
								</div>
								<div class="price-tag">
									<span class="now"><em class="li_xfo">￥</em><em>{$v[shop_price]}</em></span>
									<span class="old"><em>￥</em><em>{$v[market_price]}</em></span>
								</div>
								<div class="shop_name2">
									<a href="{:U('/Home/Goods/goodsInfo',array('id'=>$v[goods_id]))}">
										{$v[goods_name]}
									</a>
								</div>
								<div class="J_btn_statu">
									<div class="p-num">
										<input class="J_input_val" id="number_{$v.goods_id}" type="text" value="1">
										<p class="act">
											<a href="javascript:void(0);" onClick="goods_add({$v.goods_id});" class="litt-zzyl1"></a>
											<a href="javascript:void(0);" onClick="goods_cut({$v.goods_id});"  class="litt-zzyl2"></a>
										</p>
									</div>
									<div class="p-btn">
										<if condition="($v['is_virtual'] eq 1)">
											<a href="{:U('/Home/Goods/goodsInfo',array('id'=>$v[goods_id]))}">查看详情</a>
											<else/>
											<a href="javascript:void(0);" onclick="AjaxAddCart({$v[goods_id]},$('#number_'+{$v.goods_id}).val());">加入购物车</a>
										</if>
									</div>
								</div>
							</div>
						</li>
					</foreach>
                    </empty>
				</ul>
			</div>
			<div class="page p">
				{$page->show()}
			</div>
		</div>
	</div>
</div>
<div class="underheader-floor p specilike">
	<div class="w1430">
		<div class="layout-title">
			<span class="fl">猜你喜欢</span>
            <span class="update_h fr" onclick="favourite();">
                <i class="litt-hyh"></i>
                换一换
            </span>
		</div>
		<ul class="ul-li-column p" id="favourite_goods">
		</ul>
	</div>
</div>
<script>
	/****猜你喜欢****/
	var favorite_page = 0;
	function favourite()
	{
		favorite_page++;
		$.ajax({
			type: "GET",
			url: "/index.php?m=Home&c=Index&a=ajax_favorite&i=7&p="+favorite_page,//+tab,
			success: function (data) {
				if(data == ''&& favorite_page > 1){
					favorite_page = 0;
					favourite();
				}else{
					$('#favourite_goods').html(data);
					lazy_ajax();
				}

			}
		});
	}
</script>
<!--footer-s-->
<div class="footer p">
    <include file="public/footer" />
	<include file="public/sidebar_cart" />
</div>
<!--footer-e-->
<script src="__STATIC__/js/lazyload.min.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC__/js/popt.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC__/js/headerfooter.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    //更多
     $('.gd_more').parent().click(function(){
     	var jed = $(this).parents('.lr-more').siblings();
     	jed.toggleClass('ov-inh').find('.brand-box').toggleClass('ov-inh');
     	if(jed.toggleClass('ov-inh').find('.brand-list')){
     		jed.toggleClass('ov-inh').find('.brand-list').toggleClass('ov-inh');
     	}
     	if(jed.hasClass('ov-inh')){
     		$(this).find('.gd_more').html('收起');
     	}else{
     		$(this).find('.gd_more').html('更多');
     	}
     })
    var cancelBtn = null;
    /***多选 start*****/
    $('.dx_choice').parent().click(function(){
        var _this = this;
        var st = 0;
        var jed = $(_this).parents('.ri-section'); //当前选项层DIV

        //关闭前一个多选框
        if(cancelBtn != null){
            $(cancelBtn).parent().siblings('.clearfix').find('a').each(function(i,o){
                $(o).removeClass('addhover-js').find('.litt-zd').hide(); //针对品牌筛选的红色边框和右下角对勾隐藏
                $(o).removeClass('red_hov_cli')    //针对纯文字型选项
                        .attr('href',$(o).data('href'))  //还原连接
                        .children('input').prop('checked',false).hide(); //隐藏多选框
                $(o).unbind('click');
            });
            $(cancelBtn).parents('.lf-list').siblings('.lr-more').show(); //显示其它多选按钮
            $(cancelBtn).parents('.ri-section').removeClass('sum_ov_inh'); //移除多选样式

        }
        cancelBtn = jed.find('.u-cancel'); //前一个取消按钮

        //打开多选
        jed.addClass('sum_ov_inh'); //添加这一行的样式
        //遍历a标签
        jed.find('.clearfix>a').each(function(i,o){
            $(o).attr('href','javascript:;'); //移除连接
            $(o).children('input').show();  //显示多选框
            $(o).bind('click',function(){
                if($(o).hasClass('red_hov_cli')){
                    //取消选中
                    $(o).find('i').toggle().end().removeClass('addhover-js'); //针对品牌选项，改变筛选的选中状态
                    $(o).removeClass('red_hov_cli').end().children('input').prop('checked',false); //针对纯文字型选项选中状态
                    $(o).parent().siblings('.surclofix').children('.u-confirm').removeClass('u-confirm01');
                    st--;
                }else{
                    $(o).find('i').toggle().end().addClass('addhover-js');
                    $(o).addClass('red_hov_cli').end().children('input').prop('checked',true);
                    $(o).parent().siblings('.surclofix').children('.u-confirm').addClass('u-confirm01');
                    st++;
                }
                //如果没有选中项,确定按钮点不了
                if(st==0){
                    jed.find('.u-confirm').disabled=true;
                }
            });
        });
        //隐藏当前多选按钮
        $(_this).parent().hide();
    });

    /***多选 end*****/
        //############   取消多选        ###########
    $('.surclofix .u-cancel').each(function(){
        $(this).click(function(){
            var jed = $(this).parents('.ri-section');
            //遍历a标签
            jed.find('.clearfix>a').each(function(i,o){
                $(o).removeClass('addhover-js').find('.litt-zd').hide(); //针对品牌筛选的红色边框和右下角对勾隐藏
                $(o).removeClass('red_hov_cli')    //针对纯文字型选项，隐藏筛选的选中状态
                        .attr('href',$(o).data('href'))  //还原连接
                        .children('input').prop('checked',false).hide(); //隐藏多选框
                $(o).unbind('click');
            });
            jed.find('.lr-more').show(); //显示多选按钮
            jed.removeClass('sum_ov_inh') //移除这一行的样式
            $('.u-confirm').removeClass('u-confirm01'); //移除确定按钮可点击标识
        });
    })
	$(function(){
		favourite();
//		ajax_hot_goods();
//		ajax_sales_goods();

        //############   更多类别属性筛选start       ###########
        $('.moreamore').click(function(){
            $('.m-tr').each(function(i,o){
                if(i >  7){
                    var attrdisplay = $(o).css('display');
                    if(attrdisplay == 'none'){
                        $(o).css('display','block');
                    }
                    if(attrdisplay == 'block'){
                        $(o).css('display','none');
                    }
                }
            });
            if($(this).hasClass('checked')){
                $(this).removeClass('checked').html('<a class="red">收起</a>');
            }else{
                $(this).addClass('checked').html('<a >更多选项</a>');
            }
        })
        $('.moreamore').trigger('click').html('<a >更多选项</a>'); //  默认点击一下
        //############   更多类别属性筛选end       ###########

		/***价格排序 start*****/
		var price_i = 0;
		$('.f-sort ul li').click(function(){
			$(this).addClass('red').siblings().removeClass('red').find('i').removeClass('litt-zzx2').removeClass('litt-zzx3').addClass('litt-zzx1');
			var jd = $(this).find('i');
			price_i++;
			if(price_i>2)price_i=1;
			switch(price_i){
				case 1:jd.addClass('litt-zzx2').removeClass('litt-zzx1').removeClass('litt-zzx3');break;
				case 2:jd.addClass('litt-zzx3').removeClass('litt-zzx2').removeClass('litt-zzx1');break;
			}
		})
		/***价格排序 end*******/
		/***地址选择 start*****/
		$("#city").click(function (e) {
			SelCity(this,e);
		});
		/***地址选择 end*****/
		/***是否自营 start****/
		$('.choice-mo-shop ul li').click(function(){
			$(this).find('.litt-zzdg1').toggleClass('litt-zzdg2');
			$(this).find('a').toggleClass('red');
		})
		/***是否自营 end****/
		/***滑过浏览商品 start***/
		$('.small-xs-shop ul li').hover(function(){
			$(this).addClass('bored').siblings().removeClass('bored');
			var small_src = $(this).find('img').attr('src');
			$(this).parents('.s_xsall').find('.xs_img').find('img').attr('src',small_src);
		},function(){

		})
		/***滑过浏览商品 end***/
	})

	/****加减购物车数额***/
	function goods_cut($val){
		var num_val=document.getElementById('number_'+$val);
		var new_num=num_val.value;
		var Num = parseInt(new_num);
		if(Num>1)Num=Num-1;
		num_val.value=Num;
	}

	function goods_add($val){
		var num_val=document.getElementById('number_'+$val);
		var new_num=num_val.value;
		var Num = parseInt(new_num);
		Num=Num+1;
		num_val.value=Num;
	}
	/****加减购物车数额***/
        //############   点击多选确定按钮      ############
// t 为类型  是品牌 还是 规格 还是 属性
// btn 是点击的确定按钮用于找位置
    get_parment = <?php echo json_encode($_GET); ?>;
    function submitMoreFilter(t,btn)
    {
        // 没有被勾选的时候
        if(!$(btn).hasClass("u-confirm01")){
            return false;
        }

        // 获取现有的get参数
        var key = ''; // 请求的 参数名称
        var val = new Array(); // 请求的参数值
        $(btn).parent().siblings(".clearfix").find(".red_hov_cli").each(function(i,o){
            key = $(o).data('key');
            val.push($(o).data('val'));
        });
        //parment = key+'_'+val.join('_');
//        return false;
        // 品牌
        if(t == 'brand')
        {
            get_parment.brand_id = val.join('_');
        }
        // 规格
        if(t == 'spec')
        {
            if(get_parment.hasOwnProperty('spec'))
            {
                get_parment.spec += '@'+key+'_'+val.join('_');
            }
            else
            {
                get_parment.spec = key+'_'+val.join('_');
            }
        }
        // 属性
        if(t == 'attr')
        {
            if(get_parment.hasOwnProperty('attr'))
            {
                get_parment.attr += '@'+key+'_'+val.join('_');
            }
            else
            {
                get_parment.attr = key+'_'+val.join('_');
            }
        }
        // 组装请求的url
        var url = '';
        for ( var k in get_parment )
        {
            url += "&"+k+'='+get_parment[k];
        }
        location.href ="/index.php?m=Home&c=Goods&a=search"+url;
    }
</script>
</body>
</html>