Authored by 阿达

搜索页面参数缺失

@@ -31,6 +31,8 @@ var $input = $('#search-input input'), @@ -31,6 +31,8 @@ var $input = $('#search-input input'),
31 $icon = $('.search-icon'), 31 $icon = $('.search-icon'),
32 $clear = $('#search-input .clear-input'); 32 $clear = $('#search-input .clear-input');
33 33
  34 +var shopId;
  35 +
34 //默认筛选条件 36 //默认筛选条件
35 var defaultOpt = require('./query-param'); 37 var defaultOpt = require('./query-param');
36 38
@@ -86,6 +88,21 @@ $('#search').on('touchend', function() { @@ -86,6 +88,21 @@ $('#search').on('touchend', function() {
86 }); 88 });
87 89
88 /** 90 /**
  91 + * 获取url参数
  92 + */
  93 +function getQueryString(name) {
  94 + var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  95 + var r = window.location.search.substr(1).match(reg);
  96 +
  97 + if (r != null) {
  98 + return window.unescape(r[2]);
  99 + }
  100 + return null;
  101 +}
  102 +
  103 +shopId = getQueryString('shop_id');
  104 +
  105 +/**
89 * 筛选注册的回调,筛选子项点击后逻辑 106 * 筛选注册的回调,筛选子项点击后逻辑
90 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载 107 * 需要执行search的场景:1.点选筛选项;2.relaod为true时切换导航;3.下拉加载
91 * @param opt {type, id} 108 * @param opt {type, id}
@@ -95,7 +112,7 @@ function search(opt) { @@ -95,7 +112,7 @@ function search(opt) {
95 ext, 112 ext,
96 att, 113 att,
97 nav, navType, 114 nav, navType,
98 - page; 115 + page,params;
99 116
100 if (searching) { 117 if (searching) {
101 return; 118 return;
@@ -175,11 +192,17 @@ function search(opt) { @@ -175,11 +192,17 @@ function search(opt) {
175 return; 192 return;
176 } 193 }
177 194
178 - $.extend(setting, defaultOpt, { 195 + params = {
179 type: navType, 196 type: navType,
180 order: nav.order, 197 order: nav.order,
181 page: page 198 page: page
182 - }); 199 + };
  200 +
  201 + if (shopId) {
  202 + params.shop_id = shopId;
  203 + }
  204 +
  205 + $.extend(setting, defaultOpt, params);
183 206
184 searching = true; 207 searching = true;
185 loading.showLoadingMask(); 208 loading.showLoadingMask();