Compare commits
5 Commits
2a1c9f7825
...
e1572d7ac0
| Author | SHA1 | Date | |
|---|---|---|---|
| e1572d7ac0 | |||
| df54c9591a | |||
| 1100e347bd | |||
| de44890014 | |||
| f970f22539 |
@@ -222,3 +222,22 @@ if (!function_exists('get_platform')) {
|
|||||||
return $platform;
|
return $platform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!function_exists('highlight_keywords')) {
|
||||||
|
/**
|
||||||
|
* 高亮关键词
|
||||||
|
* @param string $item
|
||||||
|
* @param string $keywords
|
||||||
|
* @param array $class
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function highlight_keywords(string $text, string $keywords, array $class=[]): string
|
||||||
|
{
|
||||||
|
return preg_replace_callback('/' . preg_quote($keywords, '/') . '+/i', function($match) use($text, $class) {
|
||||||
|
if (empty($match)) {
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
return '<strong class="' . implode(' ', $class) . '">' . $match[0] . '</strong>';
|
||||||
|
}, $text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -299,9 +299,9 @@ class Product extends Common
|
|||||||
'query' => request()->param()
|
'query' => request()->param()
|
||||||
])
|
])
|
||||||
->each(function ($item) use($keywords) {
|
->each(function ($item) use($keywords) {
|
||||||
$item['spu'] = str_replace($keywords, '<strong class="redpoint">'.$keywords.'</strong>', $item['spu']);
|
$item['spu'] = highlight_keywords($item['spu'], $keywords, ['redpoint']);
|
||||||
$item['name'] = str_replace($keywords, '<strong class="redpoint">'.$keywords.'</strong>', $item['name']);
|
$item['name'] = highlight_keywords($item['name'], $keywords, ['redpoint']);
|
||||||
$item['short_name'] = str_replace($keywords, '<strong class="redpoint">'.$keywords.'</strong>', $item['short_name']);
|
$item['short_name'] = highlight_keywords($item['short_name'], $keywords, ['redpoint']);
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
View::assign('products', $products);
|
View::assign('products', $products);
|
||||||
|
|||||||
@@ -79,6 +79,6 @@ class ProductModel extends ProductBaseModel
|
|||||||
// 关键词搜索
|
// 关键词搜索
|
||||||
public function searchKeywordsAttr($query, string $keywords)
|
public function searchKeywordsAttr($query, string $keywords)
|
||||||
{
|
{
|
||||||
$query->whereRaw('BINARY spu LIKE "%' . $keywords . '%" OR BINARY name LIKE "%' . $keywords . '%" OR BINARY short_name LIKE "%' . $keywords . '%"');
|
$query->whereRaw('spu LIKE "%' . $keywords . '%" OR name LIKE "%' . $keywords . '%" OR short_name LIKE "%' . $keywords . '%"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@
|
|||||||
$('#dropdown').hide();
|
$('#dropdown').hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$('.nhlplxwmit:not(:first)').hover(function () {
|
$('.nhlplxwmit').hover(function () {
|
||||||
// 当鼠标移入时,显示.lxewmimg 并隐藏.lximg
|
// 当鼠标移入时,显示.lxewmimg 并隐藏.lximg
|
||||||
var lxe = $(this).find('.lxewmimg');
|
var lxe = $(this).find('.lxewmimg');
|
||||||
var lxi = $(this).find('.lximg');
|
var lxi = $(this).find('.lximg');
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
z-index: 10;
|
||||||
}
|
}
|
||||||
/* .orico_Page_introduction .introductionMain .iotb_part2 .fdimgs.fdimgs1 .fdimgs-div {
|
/* .orico_Page_introduction .introductionMain .iotb_part2 .fdimgs.fdimgs1 .fdimgs-div {
|
||||||
height: 405px;
|
height: 405px;
|
||||||
|
|||||||
@@ -174,6 +174,7 @@
|
|||||||
.header-PC #header .nav2 .navItem .navItemConten1 li a {
|
.header-PC #header .nav2 .navItem .navItemConten1 li a {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.header-PC #header .nav2 .navItem .navItemConten1 li a:hover {
|
.header-PC #header .nav2 .navItem .navItemConten1 li a:hover {
|
||||||
color: #004bfa;
|
color: #004bfa;
|
||||||
|
|||||||
@@ -596,6 +596,7 @@
|
|||||||
background: url(/static/index/pc/images/fl.png);
|
background: url(/static/index/pc/images/fl.png);
|
||||||
left: 90px;
|
left: 90px;
|
||||||
margin-top: -24.5px;
|
margin-top: -24.5px;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scrollbutton.smallImgDown,
|
.scrollbutton.smallImgDown,
|
||||||
@@ -603,6 +604,7 @@
|
|||||||
background: url(/static/index/pc/images/rh.png);
|
background: url(/static/index/pc/images/rh.png);
|
||||||
right: 0px;
|
right: 0px;
|
||||||
margin-top: -24.5px;
|
margin-top: -24.5px;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
.orico_Page_prdetail .glcpmain {
|
.orico_Page_prdetail .glcpmain {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
Reference in New Issue
Block a user