This commit is contained in:
devil_gong 2018-09-07 15:04:11 +08:00
parent 10c167e982
commit 1b0e0a98d2
22 changed files with 227 additions and 254 deletions

View File

@ -65,6 +65,7 @@ class ScreeningPriceController extends CommonController
{
foreach($data as $k=>$v)
{
$alias = '';
if(!empty($v['min_price']) && !empty($v['max_price']))
{
$alias = $v['min_price'].'-'.$v['max_price'];
@ -77,6 +78,7 @@ class ScreeningPriceController extends CommonController
{
$alias = $v['min_price'].'以上';
}
$alias = empty($alias) ? '' : '<span class="mini-tips-text">('.$alias.')</span>';
$data[$k]['name_alias'] = $v['name'].' '.$alias;
$data[$k]['is_son'] = $this->IsExistSon($v['id']);
$data[$k]['ajax_url'] = U('Admin/ScreeningPrice/GetNodeSon', array('id'=>$v['id']));

View File

@ -18,6 +18,6 @@ return array(
'screening_price_max_price_text' => '最大价格',
'screening_price_max_price_format' => '最大价格有误',
'screening_price_desc' => '最小价格0 - 最大价格100 则是小于100<br /> 最小价格1000 - 最大价格0 则是大于1000<br /> 最小价格100 - 最大价格500 则是大于等于100并且小于500<br />',
'screening_price_desc' => '规则举例<br /><span class="mini-tips-text">最小价格0 - 最大价格100 则是小于100<br /> 最小价格1000 - 最大价格0 则是大于1000<br /> 最小价格100 - 最大价格500 则是大于等于100并且小于500</span>',
);
?>

View File

@ -16,6 +16,8 @@ class ScreeningPriceModel extends CommonModel
protected $_validate = array(
// 添加,编辑
array('name', '2,16', '{%common_name_format}', 1, 'length', 3),
array('min_price', '1,10', '{%screening_price_min_price_format}', 1, 'length', 3),
array('max_price', '1,10', '{%screening_price_max_price_format}', 1, 'length', 3),
array('is_enable', array(0,1), '{%common_enable_tips}', 1, 'in', 3),
array('sort', 'CheckSort', '{%common_sort_error}', 1, 'function', 3),

View File

@ -49,7 +49,7 @@
<!-- save win end -->
<!-- list start -->
<div id="tree" class="m-t-15">
<div id="tree" class="m-t-15" data-additional='[{"field":"min_price", "value":"0", "type":"input"}, {"field":"max_price", "value":"0", "type":"input"}]'>
<div class="m-t-30 t-c">
<img src="__PUBLIC__/Common/Images/loading.gif" />
<p>{{:L('common_form_loading_tips')}}</p>

View File

@ -2,7 +2,7 @@
namespace Home\Controller;
use Service\GoodsService;
use Service\SearchService;
use Service\BrandService;
/**
@ -14,6 +14,8 @@ use Service\BrandService;
*/
class SearchController extends CommonController
{
private $params;
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
@ -25,6 +27,16 @@ class SearchController extends CommonController
{
// 调用父类前置方法
parent::_initialize();
// 分类id
$this->params['category_id'] = intval(I('category_id', 0));
// 搜索关键字
$this->params['keywords'] = trim(I('keywords'));
// 排序方式
$this->params['order_type'] = I('order_type', 'default');
$this->params['order_way'] = I('order_way', 'desc');
}
/**
@ -36,36 +48,38 @@ class SearchController extends CommonController
*/
public function Index()
{
// 分类id
$category_id = intval(I('category_id', 0));
if(IS_POST)
{
$this->redirect('Home/Search/Index', ['keywords'=>$this->params['keywords']]);
} else {
// 品牌列表
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id']]));
// 搜索关键字
$keywords = trim(I('keywords'));
// 商品分类
$this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->params['category_id']]));
// 品牌列表
$this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$category_id]));
// 筛选价格区间
$this->assign('screening_price_list', SearchService::ScreeningPriceList(['field'=>'id,name']));
// 根据分类id获取同级列表
$category = GoodsService::GoodsCategoryRow(['id'=>$category_id]);
$pid = empty($category['pid']) ? 0 : $category['pid'];
$this->assign('category_list', GoodsService::GoodsCategoryList(['pid'=>$pid]));
// 参数
$this->assign('params', $this->params);
// 价格区间
$price_list = [
['id'=>1, 'name'=>'100以下'],
['id'=>2, 'name'=>'100-300'],
['id'=>3, 'name'=>'300-600'],
['id'=>4, 'name'=>'600-1000'],
['id'=>5, 'name'=>'1000-1500'],
['id'=>6, 'name'=>'1500-2000'],
['id'=>7, 'name'=>'2000-3000'],
['id'=>8, 'name'=>'3000-4000'],
['id'=>9, 'name'=>'5000-8000'],
['id'=>10, 'name'=>'10000y以上'],
];
$this->assign('price_list', $price_list);
$this->display('Index');
}
}
$this->display('Index');
/**
* 获取商品列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-07
* @desc description
*/
public function GoodsList()
{
$data = SearchService::GoodsList($this->params);
$this->ajaxReturn(L('common_operation_success'), 0, $data);
}
}
?>

View File

@ -13,7 +13,7 @@
<div class="category-info">
<h3 class="category-name b-category-name">
<i><img src="{{$v.icon}}"></i>
<a href="{{:__MY_URL__}}search.php?category_id={{$v.id}}" class="ml-22" title="{{$v.name}}">{{$v.name}}</a>
<a href="{{:U('Home/Search/Index', ['category_id'=>$v['id']])}}" class="ml-22" title="{{$v.name}}">{{$v.name}}</a>
</h3>
<em>&gt;</em>
</div>
@ -26,14 +26,14 @@
<foreach name="v.items" item="vs">
<dl class="dl-sort">
<dt>
<a href="{{:__MY_URL__}}search.php?category_id={{$vs.id}}" title="{{$vs.name}}">
<a href="{{:U('Home/Search/Index', ['category_id'=>$vs['id']])}}" title="{{$vs.name}}">
<span title="{{$vs.name}}">{{$vs.name}}</span>
</a>
</dt>
<if condition="!empty($vs['items'])">
<foreach name="vs.items" item="vss">
<dd>
<a href="{{:__MY_URL__}}search.php?category_id={{$vss.id}}" title="{{$vss.name}}">
<a href="{{:U('Home/Search/Index', ['category_id'=>$vss['id']])}}" title="{{$vss.name}}">
<span>{{$vss.name}}</span>
</a>
</dd>

View File

@ -12,8 +12,8 @@
</div>
<div class="search-bar pr">
<form action="search.php">
<input id="searchInput" name="keywords" type="text" placeholder="{{:L('common_so_tips')}}" autocomplete="off" />
<form action="{{:U('Home/Search/Index')}}" method="POST">
<input id="search-input" name="keywords" type="text" placeholder="{{:L('common_so_tips')}}" value="<if condition="!empty($params['keywords'])">{{$params.keywords}}</if>" />
<input id="ai-topsearch" class="submit am-btn" placeholder="{{:L('common_so_tips')}}" index="1" type="submit" value="{{:L('common_so_text')}}" />
</form>
</div>

View File

@ -73,8 +73,8 @@
<dt class="am-badge am-round">价格</dt>
<div class="dd-conent" data-selected-tag="screening-price">
<dd class="select-all selected"><a href="javascript:;">不限</a></dd>
<if condition="!empty($price_list)">
<foreach name="price_list" item="price">
<if condition="!empty($screening_price_list)">
<foreach name="screening_price_list" item="price">
<dd><a href="javascript:;">{{$price.name}}</a></dd>
</foreach>
<else />
@ -102,189 +102,11 @@
<li class="big"><a title="评价" href="#">评价为主</a></li>
</ul>
<div class="clear"></div>
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-5 data-list">
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
<li>
<div class="i-pic limit">
<img src="../images/imgsearch1.jpg" />
<p class="title fl">【良品铺子旗舰店】手剥松子218g 坚果炒货零食新货巴西松子包邮</p>
<p class="price fl">
<b>¥</b>
<strong>56.90</strong>
</p>
<p class="number fl">
销量<span>1110</span>
</p>
</div>
</li>
</ul>
<ul class="am-avg-sm-2 am-avg-md-3 am-avg-lg-5 data-list"></ul>
</div>
<!--分页 -->
<ul class="am-pagination am-pagination-right search-pages">
<li class="am-disabled"><a href="#">&laquo;</a></li>
<li class="am-active"><a href="#">1</a></li>
<li><a href="#">2</a></li>
<li><a href="#">3</a></li>
<li><a href="#">4</a></li>
<li><a href="#">5</a></li>
<li><a href="#">&raquo;</a></li>
</ul>
<button type="button" class="am-btn am-btn-default am-btn-block search-pages-submit">加载更多 <i class="am-icon-angle-double-down"></i></button>
<button type="button" class="am-btn am-btn-default am-btn-block search-pages-submit" data-url="{{:U('Home/Search/GoodsList')}}">加载更多 <i class="am-icon-angle-double-down"></i></button>
</div>
</div>
</div>
@ -293,7 +115,6 @@
<div class="theme-popover-mask"></div>
<!-- footer start -->
<include file="Public/Footer" />
<!-- footer end -->

View File

@ -3,7 +3,7 @@
namespace Service;
/**
* 文章
* 文章服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1

View File

@ -3,7 +3,7 @@
namespace Service;
/**
* 轮播
* 轮播服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1

View File

@ -5,7 +5,7 @@ namespace Service;
use Service\GoodsService;
/**
* 品牌
* 品牌服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1

View File

@ -3,7 +3,7 @@
namespace Service;
/**
* 商品
* 商品服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1

View File

@ -3,7 +3,7 @@
namespace Service;
/**
* 导航
* 导航服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1

View File

@ -0,0 +1,71 @@
<?php
namespace Service;
use Service\GoodsService;
/**
* 搜索服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class SearchService
{
/**
* 根据分类id获取同级列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-08-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsCategoryList($params = [])
{
// 根据分类id获取同级列表
$category = GoodsService::GoodsCategoryRow(['id'=>$params['category_id']]);
$pid = empty($category['pid']) ? 0 : $category['pid'];
return GoodsService::GoodsCategoryList(['pid'=>$pid]);
}
/**
* 获取商品价格筛选列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-07
* @desc description
* @param [array] $params [输入参数]
*/
public static function ScreeningPriceList($params = [])
{
$field = empty($params['field']) ? '*' : $params['field'];
return M('ScreeningPrice')->field($field)->where(['is_enable'=>1])->order('sort asc')->select();
}
/**
* 获取商品列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-07
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsList($params = [])
{
$result = [
'total' => 0,
'data' => [],
];
$goods_where = [
'g.is_delete_time' => 0,
];
$result['data'] = GoodsService::GoodsList(['where'=>$goods_where]);
return $result;
}
}
?>

View File

@ -65,6 +65,7 @@
* 公共
*/
.data-error-tips { text-align: center; }
.mini-tips-text { font-size: 12px; color: #999; }
/**
* 地图提示
@ -87,7 +88,7 @@
.plug-images-list { padding: 0px; margin: 0px; overflow: hidden; }
.plug-images-list li { list-style-type: none; width: 150px; height: 200px; overflow: hidden; float: left; margin: 0 10px 10px 0; }
.plug-images-list li.plug-images-add-tag { border: 1px solid #eee; }
.plug-images-list li img { width: 100%; height: 172px; }
.plug-images-list li img { width: 100%; height: 150px; }
.plug-images-list .plug-images-add { text-align: center; width: 100%; }
.plug-images-list .plug-images-add .add-icon { color: #ccc; font-size: 80px; font-style: normal; height: 200px; line-height: 200px; cursor: pointer; display: block; }
.plug-images-list .plug-images-add .add-icon:hover { color: #b4b4b4; }

View File

@ -456,7 +456,7 @@ function Tree(id, url, level, is_add_node)
{
html += '<a href="'+result.data[i]['icon_url']+'" target="_blank"><img src="'+result.data[i]['icon_url']+'" width="20" height="20" style="margin-right:5px;" /></a>';
}
html += '<span>'+result.data[i]['name']+'</span>';
html += '<span>'+(result.data[i]['name_alias'] || result.data[i]['name'])+'</span>';
html += '</span>';

View File

@ -60,7 +60,7 @@ li.select-result dt {left:-26px; top:0;font-weight:bold;width:50px;}
.select-list dl dt{left:0px; cursor:pointer; text-align: center;}
{display:none ;float:left; top:20px; padding-top:5px; z-index:10; left:0px; width:300%;position:absolute;}
.select-list .dd-conent{display:none ;float:left; top:30px; z-index:10; left:0px; width:300%;position:absolute; background:#fff;overflow: hidden;}
.select-list .dd-conent{display:none ;z-index:10; left:0; width:100%;position:fixed; background:#fff;overflow: hidden;}
.select-list .dd-conent dd{width:33.33% ;text-align: center;margin-left: 0px;height:25px ;}
dl#select2 .dd-conent{ left:-100%; right:-100%;}
dl#select3 .dd-conent{ left:-200%; right:0px;}
@ -135,8 +135,6 @@ dl#select3 .dd-conent{ left:-200%; right:0px;}
/*文字布局*/
.limit p.title,.i-pic.check p.title{padding:0px 10px;overflow:hidden;height:36px;line-height:18px ;}
.price.fl{font-size:16px ;}
.search-pages-submit { display: none; }
}
@media only screen and (min-width:1025px) {
@ -151,8 +149,6 @@ dl#select3 .dd-conent{ left:-200%; right:0px;}
.theme-popover { padding: 0; }
.data-list li:nth-child(2n) .i-pic.limit { margin-right: 0px; }
.data-list li:nth-child(2n+1) .i-pic.limit { margin-left: 0px; }
.search-pages { display: none; }
.search-pages-submit { display: block; }
.screening-remove-submit { margin-top: -28px; }
.select .title-tips { padding: 0 5px; }
}

View File

@ -5,7 +5,6 @@ $(function()
{
$(this).addClass("selected").siblings().removeClass("selected");
var selected_tag_name = $(this).parent('.dd-conent').attr('data-selected-tag');
console.log(selected_tag_name)
if ($(this).hasClass("select-all")) {
$('#'+selected_tag_name).remove();
} else {
@ -46,18 +45,19 @@ $(function()
var hh = document.documentElement.clientHeight;
var ls = document.documentElement.clientWidth;
if (ls < 640) {
if (ls < 640)
{
$(".select dt").on('click', function() {
if ($(this).next("div").css("display") == 'none') {
$('body,html').scrollTop(0);
$(this).next('div.dd-conent').css('top', ($(this).offset().top+33)+'px')
if ($(this).next('div.dd-conent').css("display") == 'none') {
$(".theme-popover-mask").height(hh);
$(".theme-popover").css({"position":"fixed", "top":0, "padding-top":"46px"});
$(this).next("div").slideToggle(300);
$(".select div").not($(this).next()).hide();
$(this).next('div.dd-conent').slideToggle(300);
$('.select div.dd-conent').not($(this).next()).hide();
} else {
$(this).next("div").slideUp(300);
$(this).next('div.dd-conent').slideUp(300);
$(".theme-popover-mask").height(0);
$(".theme-popover").css({"position":"static", "top":0, "padding-top":"0"});
}
@ -112,4 +112,44 @@ $(function()
});
search_nav();
// 获取商品列表
function get_goods_list()
{
var keywords = $('#search-input').val() || '';
$.ajax({
url:$('.search-pages-submit').data('url'),
type:'POST',
dataType:"json",
timeout:10000,
data:{keywords: keywords},
success:function(result)
{
if(result.code == 0 && result.data.data.length > 0)
{
for(var i in result.data.data)
{
var html = '<li class="am-animation-scale-up"><div class="i-pic limit">';
html += '<a href="'+result.data.data[i]['goods_url']+'" target="_blank">';
html += '<img src="'+result.data.data[i]['images']+'" />';
html += '<p class="title fl">'+result.data.data[i]['title']+'</p>';
html += '</a>';
html += '<p class="price fl"><b>¥</b><strong>'+result.data.data[i]['price']+'</strong></p>';
html += '<p class="number fl">销量<span>'+result.data.data[i]['sales_count']+'</span></p>';
html += '</div></li>';
$('.data-list').append(html);
}
} else {
Prompt(result.msg);
}
},
error:function(xhr, type)
{
Prompt('网络异常出错');
}
});
}
get_goods_list();
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

File diff suppressed because one or more lines are too long