init
This commit is contained in:
264
app/vn/view/search/index.phtml
Executable file
264
app/vn/view/search/index.phtml
Executable file
@@ -0,0 +1,264 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
{include file="include/head" /}
|
||||
<script type="text/javascript">
|
||||
var navID = "0";
|
||||
</script>
|
||||
<link rel="stylesheet" type="text/css" href="__PUBLIC__/webvn/css/subject/search.css">
|
||||
</head>
|
||||
<body>
|
||||
<!--top-->
|
||||
<header class="header-PC header-Product">
|
||||
<div id="header" class="theme-black">
|
||||
{include file="include/top" /}
|
||||
{include file="include/top-header" /}
|
||||
</div>
|
||||
</header>
|
||||
{include file="include/top-header-mobile" /}
|
||||
<!--top End-->
|
||||
|
||||
|
||||
<!-- 搜索页 s -->
|
||||
<div class="S-search-bg banner-other nsea">
|
||||
<div class="swt-Container S-search-content secon secon1">
|
||||
<div class="S-Searchbox">
|
||||
<div class="Search">
|
||||
<input type="text" name="textfield" class="ipt" placeholder="HDD enclosure" id="search-in">
|
||||
<button type="submit" name="button" value="" class="searchbtn icon-search" id="search-btn"></button>
|
||||
<div id="search" class="search_content search_default">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
if ($list):
|
||||
?>
|
||||
<ul class="seul">
|
||||
<?php foreach ($list as $detail): ?>
|
||||
<li>
|
||||
<a href="<?php echo $detail['link'] == 'downloaddetail' ? '/vn/download.html' : url_rewrite('vn/'.$detail['link'], ['id' => $detail['id']]); ?>">
|
||||
<div class="sepic"><img src="<?php echo getImage($detail['picture']); ?>"></div>
|
||||
<div class="seinfo">
|
||||
<?php if (isset($search['skeyword'])): ?>
|
||||
<p class="info1">
|
||||
<?php
|
||||
if (stripos($detail['name'], $name_word) !== false)
|
||||
{
|
||||
$replace_str = substr($detail['name'], stripos($detail['name'], $name_word), strlen($name_word));
|
||||
echo str_replace($replace_str, '<font color=red><b>' . $replace_str . '</b></font>', $detail['name']);
|
||||
}
|
||||
else
|
||||
echo $detail['name'];
|
||||
?>
|
||||
</p>
|
||||
<p class="info2">
|
||||
<?php
|
||||
if (stripos($detail['description'], $name_word) !== false)
|
||||
{
|
||||
$replace_str = substr($detail['description'], stripos($detail['description'], $name_word), strlen($name_word));
|
||||
echo str_replace($replace_str, '<font color=red><b>' . $replace_str . '</b></font>', $detail['description']);
|
||||
}
|
||||
else
|
||||
echo $detail['description'];
|
||||
?>
|
||||
</p>
|
||||
<p class="info3">
|
||||
<?php
|
||||
if (stripos($detail['brand_id'], $brand_word) !== false)
|
||||
{
|
||||
$replace_str = substr($detail['brand_id'], stripos($detail['brand_id'], $brand_word), strlen($brand_word));
|
||||
echo str_replace($replace_str, '<font color=red><b>' . $replace_str . '</b></font>', $detail['brand_id']);
|
||||
}
|
||||
else
|
||||
echo $detail['brand_id'];
|
||||
?>
|
||||
</p>
|
||||
<?php else: ?>
|
||||
<p class="info1"><?php echo $detail['name']; ?></p>
|
||||
<p class="info2"><?php echo msubstr($detail['description'], 0, 160); ?></p>
|
||||
<p class="info3"><?php echo $detail['brand_id']; ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<div class="clear" style="margin-top:20px;"></div>
|
||||
<!-- 分页 s -->
|
||||
<?php
|
||||
if ($page) {
|
||||
echo $page;
|
||||
}
|
||||
?>
|
||||
<!-- 分页 e -->
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 搜索页 e -->
|
||||
<script>
|
||||
$(function() {
|
||||
$("#search-btn").bind("click", function(event) {
|
||||
var skeyword = $("#search-in").val();
|
||||
if (skeyword) {
|
||||
var href = "__ORICOROOT__<?php echo url('/search'); ?>?skeyword=" + encodeURIComponent(skeyword);
|
||||
location.href = href;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<!-- bottom s -->
|
||||
{include file="include/bottom" /}
|
||||
<!-- bottom e -->
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<script type="text/javascript">
|
||||
var search_list = [];
|
||||
$(function() {
|
||||
$.ajax({
|
||||
url: '/vn/product/get_filter',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
search_list = res.data.product_name;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function handle_mousemove(i)
|
||||
{
|
||||
index = i;
|
||||
$(".ul_add li").removeClass("ul_search");
|
||||
$(".ul_add li").eq(index).addClass('ul_search');
|
||||
}
|
||||
|
||||
var index = -1; // 鼠标悬停位置
|
||||
$(function() {
|
||||
var search_input = $(".Search input");
|
||||
var search_content = $(".search_content");
|
||||
|
||||
$(search_input).on("keyup", function(e)
|
||||
{
|
||||
if (e.keyCode != 38 && e.keyCode != 40 && e.keyCode != 13)
|
||||
{
|
||||
index = -1; // 鼠标悬停位置
|
||||
}
|
||||
var search_table_list = [];
|
||||
var value = search_input.val();
|
||||
if (value.length > 0) {
|
||||
var search_list_len = search_list.length;
|
||||
for (var i=0;i<search_list_len;i++)
|
||||
{
|
||||
if (search_table_list.length > 4)
|
||||
break;
|
||||
if(search_list[i].name.toLowerCase().indexOf(value.toLowerCase()) != -1 || search_list[i].brand_id.toLowerCase().indexOf(value.toLowerCase()) != -1)
|
||||
{
|
||||
search_table_list.push(search_list[i]);
|
||||
}
|
||||
}
|
||||
var html = '<ul>';
|
||||
var data_length = search_table_list.length;
|
||||
for(var i=0;i<data_length;i++) {
|
||||
html += '<li onmousemove="handle_mousemove(' + i + ')">';
|
||||
html += search_table_list[i].name + '(' + search_table_list[i].brand_id + ')';
|
||||
html += '</li>';
|
||||
}
|
||||
html += '</ul>';
|
||||
$('#search').html(html);
|
||||
}
|
||||
else if (value.length == 0)
|
||||
$('#search').html('');
|
||||
|
||||
if (data_length > 0)
|
||||
$(search_content).show().addClass("ul_add");
|
||||
else
|
||||
$(search_content).hide();
|
||||
|
||||
if (e.keyCode == 38)
|
||||
{
|
||||
// 上键
|
||||
if (search_table_list == '' || search_table_list == undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
index = (index - 1) < 0 ? -1 : (index - 1);
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$(".ul_add li").removeClass("ul_search");
|
||||
$(".ul_add li").eq(index).addClass('ul_search');
|
||||
|
||||
}
|
||||
else if (e.keyCode == 40)
|
||||
{
|
||||
// 下键
|
||||
if (search_table_list == '' || search_table_list == undefined)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
index += 1;
|
||||
if (index >= search_table_list.length - 1)
|
||||
{
|
||||
index = search_table_list.length - 1;
|
||||
}
|
||||
|
||||
$(".ul_add li").removeClass("ul_search");
|
||||
$(".ul_add li").eq(index).addClass('ul_search');
|
||||
}
|
||||
|
||||
$("#search-in").keyup(function(event) {
|
||||
if (event && event.keyCode === 13) {
|
||||
if (index >= 0)
|
||||
{
|
||||
var text = $(".ul_add li").eq(index)[0].innerText;
|
||||
$("#search-in").val(text);
|
||||
}
|
||||
|
||||
$("#search-btn").trigger("click");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
/*点击获取提示关键字*/
|
||||
$("#search ul li").live('click',function(){
|
||||
//获取点击的值
|
||||
var keywords = $(this).text();
|
||||
if(keywords) {
|
||||
$('#search-in').val(keywords);
|
||||
var href = "<?php echo url('/vn/search'); ?>?skeyword=" + encodeURIComponent(keywords);
|
||||
location.href = href;
|
||||
$(".search_content").hide();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//点击search以外部分隐藏
|
||||
|
||||
$("body").click(function (e) {
|
||||
if (!$(e.target).closest(".Search").length) {
|
||||
$(".search_content").hide()
|
||||
}
|
||||
});
|
||||
|
||||
$(function() {
|
||||
$("#search-btn").bind("click", function(event) {
|
||||
var skeyword = $("#search-in").val();
|
||||
if (skeyword) {
|
||||
var href = "<?php echo url('/vn/search'); ?>?skeyword=" + encodeURIComponent(skeyword);
|
||||
location.href = href;
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user