diff --git a/application/index/controller/Search.php b/application/index/controller/Search.php index ffd1a460e..878f42f2a 100755 --- a/application/index/controller/Search.php +++ b/application/index/controller/Search.php @@ -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; } } ?> \ No newline at end of file diff --git a/application/index/view/default/buy/index.html b/application/index/view/default/buy/index.html index f5bc33bc9..6fdcbb630 100755 --- a/application/index/view/default/buy/index.html +++ b/application/index/view/default/buy/index.html @@ -156,7 +156,7 @@

- 合计 ¥{{$base.total_price}} + 合计 {{$base.total_price}}

@@ -191,7 +191,7 @@
实付款: - ¥ + {{$base.actual_price}}
diff --git a/application/index/view/default/search/content.html b/application/index/view/default/search/content.html new file mode 100644 index 000000000..f98c795ab --- /dev/null +++ b/application/index/view/default/search/content.html @@ -0,0 +1,85 @@ +{{if !empty($data)}} + {{foreach $data as $v}} +
  • +
    + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
    + plugins_view_search_goods_inside_top +
    + {{/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}} + + + {{$v.title}} + + +

    {{$v.title}}

    +
    +

    + ¥{{$v.original_price}} + 销量 {{$v.sales_count}} +

    + + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
    + plugins_view_search_goods_price_top +
    + {{/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}} + +

    + ¥{{$v.price}} +

    + + + {{if isset($shopxo_is_develop) and $shopxo_is_develop eq true and (!isset($is_footer) or $is_footer eq 1)}} +
    + plugins_view_search_goods_inside_bottom +
    + {{/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}} +
    +
  • + {{/foreach}} +{{/if}} \ No newline at end of file diff --git a/public/static/index/default/css/search.css b/public/static/index/default/css/search.css index 826e7f614..8ba56c883 100755 --- a/public/static/index/default/css/search.css +++ b/public/static/index/default/css/search.css @@ -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) { diff --git a/public/static/index/default/js/search.js b/public/static/index/default/js/search.js index 1d8a1eac5..cf3e42952 100755 --- a/public/static/index/default/js/search.js +++ b/public/static/index/default/js/search.js @@ -185,21 +185,7 @@ $(function() $('.loding-view').hide(); if(result.code == 0) { - for(var i in result.data.data) - { - var html = '
  • '; - html += ''; - html += ''; - html += ''; - html += ''; - html += '

    '+result.data.data[i]['title']+'

    '; - html += '
    '; - html += '

    ¥ '+result.data.data[i]['min_price']+'

    '; - html += '

    销量'+result.data.data[i]['sales_count']+'

    '; - html += '
  • '; - - $('.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();