搜索页面商品信息新增钩子

This commit is contained in:
devil_gong 2019-07-28 18:24:06 +08:00
parent ea5c573651
commit f9ddb5edbd
5 changed files with 106 additions and 34 deletions

View File

@ -10,6 +10,7 @@
// +----------------------------------------------------------------------
namespace app\index\controller;
use think\facade\Hook;
use app\service\SearchService;
use app\service\BrandService;
use app\service\SeoService;
@ -149,20 +150,20 @@ class Search extends Common
// 获取商品列表
$this->params['keywords'] = $this->params['wd'];
$ret = SearchService::GoodsList($this->params);
if(empty($ret['data']['data']))
{
$msg = '没有相关数据';
$code = -100;
} else {
$msg = '操作成功';
$code = 0;
}
// 搜索记录
SearchService::SearchAdd($this->params);
// 返回
return DataReturn($msg, $code, $ret['data']);
// 无数据直接返回
if(empty($ret['data']) || $ret['code'] != 0)
{
return DataReturn('没有相关数据', -100);
}
// 返回数据html
$this->assign('data', $ret['data']['data']);
$ret['data']['data'] = $this->fetch('content');
return $ret;
}
}
?>

View File

@ -156,7 +156,7 @@
<!-- 含运费小计 -->
<div class="buy-point-discharge">
<p>
合计 <span>¥</span><em class="pay-sum">{{$base.total_price}}</em>
合计 <span></span><em class="pay-sum">{{$base.total_price}}</em>
</p>
</div>
@ -191,7 +191,7 @@
<div class="base-real-pay">
<em>实付款:</em>
<span class="price">
<span>¥</span>
<span></span>
<em class="nav-total-price">{{$base.actual_price}}</em>
</span>
</div>

View File

@ -0,0 +1,85 @@
{{if !empty($data)}}
{{foreach $data as $v}}
<li class="am-animation-scale-up">
<div class="items">
<!-- 搜索页面商品信息顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_search_goods_inside_top</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_search_goods_inside_top';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'goods_id'=>$v['id'], 'goods'=>$v]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
<a href="{{$v.goods_url}}" target="_blank" class="goods-images">
<img src="{{$v.images}}" alt="{{$v.title}}">
</a>
<a href="{{$v.goods_url}}" target="_blank" class="goods-title">
<p class="am-text-truncate am-padding-xs" title="{{$v.title}}">{{$v.title}}</p>
</a>
<p class="am-padding-horizontal-xs am-cf">
<span class="am-fl original-price">¥{{$v.original_price}}</span>
<span class="am-fr sales-count">销量 {{$v.sales_count}}</span>
</p>
<!-- 搜索页面商品信息售价顶部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_search_goods_price_top</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_search_goods_price_top';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'goods_id'=>$v['id'], 'goods'=>$v]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
<p class="price am-padding-horizontal-xs">
<strong>¥{{$v.price}}</strong>
</p>
<!-- 搜索页面商品信息底部钩子 -->
{{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}}
<div class="plugins-tag">
<span>plugins_view_search_goods_inside_bottom</span>
</div>
{{/if}}
{{php}}
$hook_name = 'plugins_view_search_goods_inside_bottom';
$hook_data = Hook::listen($hook_name, ['hook_name'=>$hook_name, 'is_backend'=>false, 'goods_id'=>$v['id'], 'goods'=>$v]);
if(!empty($hook_data) && is_array($hook_data))
{
foreach($hook_data as $hook)
{
if(is_string($hook) || is_int($hook))
{
echo htmlspecialchars_decode($hook);
}
}
}
{{/php}}
</div>
</li>
{{/foreach}}
{{/if}}

View File

@ -1,5 +1,5 @@
.i-pic.limit img{ width:100%;}
.i-pic.limit .price strong{ font-size: 14px; }
.items img{ width:100%;}
.items .price strong{ font-size: 14px; }
.theme-popover {z-index: 1011;overflow:visible;background:#fff; width: 100%; }
.sort-nav a:hover, .sort-nav a:focus { color: #d2364c; }
.select .title-tips { font-size: 12px; color: #888; }
@ -47,14 +47,14 @@ dl#select3 .dd-conent{ left:-200%; right:0px;}
.theme-popover-mask{z-index:1001;width: 100%;height: auto;position:fixed ;background:#000 ;top:0;opacity: 0.6;bottom: 0;}
/*搜索结果*/
.i-pic.limit {margin:5px;border: 1px #e8e8e8 solid;overflow: hidden;position: relative;cursor: pointer;}
.number.fl{position: absolute;bottom:5px;right:5px ;}
.price.fl{padding: 5px;}
.items {margin:5px;border: 1px #e8e8e8 solid;overflow: hidden;position: relative;cursor: pointer;}
.items .sales-count { color: #888; }
.items .original-price { text-decoration: line-through; color: #666; }
/*分页*/
.am-pagination li{ float:none;}
.search-side{display: none;}
.limit p.title,.i-pic.check p.title{padding:0px 5px;}
.search-pages-submit { margin: 10px 0; }
@media only screen and (min-width: 640px) {
@ -104,7 +104,7 @@ dl#select3 .dd-conent{ left:-200%; right:0px;}
.data-list { width: calc(100% + 10px); margin-left: -5px; }
/*选中效果*/
.search-list ul li:hover .i-pic.limit,.search-side li:hover .i-pic.check{ -webkit-box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4); box-shadow:0px 12px 12px -10px rgba(0,0,0,.4); border: 4px solid #d2364c; -webkit-transition: border-color .2s ease-in; -moz-transition: border-color .2s ease-in; -ms-transition: border-color .2s ease-in; -o-transition: border-color .2s ease-in; transition: border-color .2s ease-in; }
.search-list ul li:hover .items,.search-side li:hover .items.check{ -webkit-box-shadow: 0px 12px 12px -10px rgba(0,0,0,.4); box-shadow:0px 12px 12px -10px rgba(0,0,0,.4); border: 4px solid #d2364c; -webkit-transition: border-color .2s ease-in; -moz-transition: border-color .2s ease-in; -ms-transition: border-color .2s ease-in; -o-transition: border-color .2s ease-in; transition: border-color .2s ease-in; }
}
@media only screen and (max-width: 640px) {

View File

@ -185,21 +185,7 @@ $(function()
$('.loding-view').hide();
if(result.code == 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 += '</a>';
html += '<a href="'+result.data.data[i]['goods_url']+'" target="_blank">';
html += '<p class="am-text-truncate title fl">'+result.data.data[i]['title']+'</p>';
html += '</a>';
html += '<p class="price fl"><strong>¥ '+result.data.data[i]['min_price']+'</strong></p>';
html += '<p class="number fl">销量<span>'+result.data.data[i]['sales_count']+'</span></p>';
html += '</div></li>';
$('.data-list').append(html);
}
$('.data-list').append(result.data.data);
$('.search-pages-submit').attr('data-page', data.page+1);
$('.search-pages-submit').attr('disabled', (result.data.page_total <= 1));
$('.search-pages-submit').show();