shopnc手机版店铺实现店内搜索
一、修改店铺搜索框提示文字
/wap/tmpl/go_store.html
<input type="text" class="htsearch-input clr-999" value="" id="keyword" placeholder="搜索本店商品"/>
二、增加表单提交项,store_id
/wap/tmpl/go_store.html
<script type="text/html" id="go_store">
下面增加:
<input type="hidden" name="store_id" id="store_id" value="<%=store_info.store_id%>">
三、搜索提交按钮跳转网址修改
/wap/js/tmpl/go_store.js
//根据关键字搜索商品
$('.search-btn').click(function(){
var keyword = encodeURIComponent($('#keyword').val());
location.href = WapSiteUrl+'/tmpl/product_list.html?keyword='+keyword;
});修改为:
//根据关键字搜索商品
$('.search-btn').click(function(){
var keyword = encodeURIComponent($('#keyword').val());
var store_id = encodeURIComponent($('#store_id').val());
location.href = WapSiteUrl+'/tmpl/product_list.html?keyword='+keyword+'&store_id='+store_id;
});四、修改ajax读取页面url,增加store_id参数
/wap/js/tmpl/product_list.js
1、
$("input[name=keyword]").val(escape(GetQueryString('keyword')));
$("input[name=gc_id]").val(GetQueryString('gc_id'));下面增加:
var store_id = GetQueryString('store_id');2、
if($("input[name=gc_id]").val()!=''){
}else{
}中的url修改为:
url:ApiUrl+"/index.php?act=goods&op=goods_list&key=4&page="+pagesize+"&curpage=1"+"&store_id="+store_id+'&keyword='+$("input[name=keyword]").val(),五、goods模块查询条件中增加store_id
/mobile/control/goods.php
在
//查询条件
$condition = array();
if(!empty($_GET['gc_id']) && intval($_GET['gc_id']) > 0) {
$condition['gc_id'] = $_GET['gc_id'];
} elseif (!empty($_GET['keyword'])) {
$condition['goods_name|goods_jingle'] = array('like', '%' . $_GET['keyword'] . '%');
}下面增加:
if(!empty($_GET['store_id'])){
$condition['store_id'] = $_GET['store_id'];
}六、以上修改完成后,店铺内搜索就可以完成,但是手机版网站首页的搜索就会出问题,原因是没有store_id
修改/wap/js/index.js
$('.search-btn').click(function(){
var keyword = encodeURIComponent($('#keyword').val());
location.href = WapSiteUrl+'/tmpl/product_list.html?keyword='+keyword;
});修改为:
$('.search-btn').click(function(){
var keyword = encodeURIComponent($('#keyword').val());
location.href = WapSiteUrl+'/tmpl/product_list.html?keyword='+keyword+'&store_id=';
});<< 上一篇
下一篇 >>