Authored by 周少峰

下架商品过滤,商品右侧小图一个时不显示

@@ -165,52 +165,40 @@ class HelperSearch @@ -165,52 +165,40 @@ class HelperSearch
165 return $goods; 165 return $goods;
166 } 166 }
167 foreach($product as $key => $val){ 167 foreach($product as $key => $val){
168 - //NEW  
169 - $isNew = $val['is_new'] == 'Y' ? true : false;  
170 - //限量商品  
171 - $isLimit = isset($val['is_limited']) && $val['is_limited'] === 'Y';  
172 - //即将售罄  
173 - $isFew = $val['is_soon_sold_out'] === 'Y' ? true : false;  
174 - //SALE  
175 - $isSale = ($val['is_discount'] == 'Y') ? true : false;  
176 - //新品节  
177 - //再到着  
178 - //年终大促  
179 - // 年中大促  
180 - if ($options['controller'] == 'List' && $options['action'] == 'new') {  
181 - $isNew = false;  
182 - $isSale = false;  
183 - //TODO再到着不显示  
184 - }  
185 - if ($options['controller'] == 'List' && $options['action'] == 'sale') {  
186 - $isNew = false;  
187 - $isSale = false;  
188 - }  
189 - //SALE、NEW标签不共存  
190 - if ($isNew) {  
191 - $isSale = false; 168 + if (!isset($val['goods_list']) || empty($val['goods_list'])) {
  169 + continue;
192 } 170 }
193 $gender = 0; 171 $gender = 0;
194 if (isset(self::$params['gender'])) { 172 if (isset(self::$params['gender'])) {
195 $genderArr = explode(',', self::$params['gender']); 173 $genderArr = explode(',', self::$params['gender']);
196 $gender = $genderArr[0]; 174 $gender = $genderArr[0];
197 } 175 }
  176 + //默认商品链接
  177 + $defaultGood = '';
198 foreach($val['goods_list'] as $k => $v){ 178 foreach($val['goods_list'] as $k => $v){
199 - $goods_list[$k]['url'] = Helpers::getUrlBySkc($val['product_id'], $v['goods_id'], $val['cn_alphabet']); 179 + //删除下架的商品
  180 + if ($v['status'] == 0) {
  181 + continue;
  182 + }
200 //男封 183 //男封
201 if (isset($v['cover_1']) && !empty($v['cover_1']) && $gender == 1) { 184 if (isset($v['cover_1']) && !empty($v['cover_1']) && $gender == 1) {
202 $val['default_images'] = $v['cover_1']; 185 $val['default_images'] = $v['cover_1'];
  186 + $defaultGood = $v['goods_id'];
203 } 187 }
204 //女封 188 //女封
205 - if (isset($v['cover_2']) && !empty($v['cover_2']) && $gender == 2) { 189 + elseif (isset($v['cover_2']) && !empty($v['cover_2']) && $gender == 2) {
206 $val['default_images'] = $v['cover_2']; 190 $val['default_images'] = $v['cover_2'];
  191 + $defaultGood = $v['goods_id'];
207 } 192 }
208 //筛选符合颜色条件的封面图片 193 //筛选符合颜色条件的封面图片
209 if (isset($params['color']) && $params['color'] == $v['color_id']) { 194 if (isset($params['color']) && $params['color'] == $v['color_id']) {
210 $val['default_images'] = $v['images_url']; 195 $val['default_images'] = $v['images_url'];
  196 + $defaultGood = $v['goods_id'];
211 break; 197 break;
212 } 198 }
  199 + $defaultGood = $defaultGood ? $defaultGood : $v['goods_id'];
213 } 200 }
  201 + $defaultUrl = Helpers::getUrlBySkc($val['product_id'], $defaultGood, $val['cn_alphabet']);
214 if (!empty($val['default_images'])) { 202 if (!empty($val['default_images'])) {
215 $val['default_images'] = Images::getImageUrl($val['default_images'],$options['imgSize'][0],$options['imgSize'][1]); 203 $val['default_images'] = Images::getImageUrl($val['default_images'],$options['imgSize'][0],$options['imgSize'][1]);
216 } 204 }
@@ -222,13 +210,38 @@ class HelperSearch @@ -222,13 +210,38 @@ class HelperSearch
222 } 210 }
223 $val['product_name'] = preg_replace($match, $replace, $val['product_name']); 211 $val['product_name'] = preg_replace($match, $replace, $val['product_name']);
224 } 212 }
  213 + //NEW
  214 + $isNew = $val['is_new'] == 'Y' ? true : false;
  215 + //限量商品
  216 + $isLimit = isset($val['is_limited']) && $val['is_limited'] === 'Y';
  217 + //即将售罄
  218 + $isFew = $val['is_soon_sold_out'] === 'Y' ? true : false;
  219 + //SALE
  220 + $isSale = ($val['is_discount'] == 'Y') ? true : false;
  221 + //新品节
  222 + //再到着
  223 + //年终大促
  224 + // 年中大促
  225 + if ($options['controller'] == 'List' && $options['action'] == 'new') {
  226 + $isNew = false;
  227 + $isSale = false;
  228 + //TODO再到着不显示
  229 + }
  230 + if ($options['controller'] == 'List' && $options['action'] == 'sale') {
  231 + $isNew = false;
  232 + $isSale = false;
  233 + }
  234 + //SALE、NEW标签不共存
  235 + if ($isNew) {
  236 + $isSale = false;
  237 + }
225 $good = array( 238 $good = array(
226 'tags' => array( 239 'tags' => array(
227 'isNew' => $isNew, 240 'isNew' => $isNew,
228 'isLimit' => $isLimit, 241 'isLimit' => $isLimit,
229 'isSale' => $isSale 242 'isSale' => $isSale
230 ), 243 ),
231 - 'url' => self::fromPram($goods_list[0]['url'],++$key), 244 + 'url' => self::fromPram($defaultUrl,++$key),
232 'thumb' => $val['default_images'], 245 'thumb' => $val['default_images'],
233 'name' => $val['product_name'], 246 'name' => $val['product_name'],
234 'salePrice' => $val['sales_price'], 247 'salePrice' => $val['sales_price'],
@@ -1195,12 +1208,15 @@ class HelperSearch @@ -1195,12 +1208,15 @@ class HelperSearch
1195 $result = array(); 1208 $result = array();
1196 if (isset($product[0]['goods_list']) && !empty($product[0]['goods_list'])){ 1209 if (isset($product[0]['goods_list']) && !empty($product[0]['goods_list'])){
1197 foreach ($product[0]['goods_list'] as $key => $val){ 1210 foreach ($product[0]['goods_list'] as $key => $val){
1198 - $result[$key]['coverImg'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]); 1211 + if ($val['status'] == 0) {
  1212 + continue;
  1213 + }
  1214 + $result[$key]['coverImg'] = Images::getImageUrl($val['images_url'], $options['minImgSize'][0], $options['minImgSize'][1]);
1199 $result[$key]['url'] = Helpers::getUrlBySkc($product[0]['product_id'], $val['goods_id'], $product[0]['cn_alphabet']); 1215 $result[$key]['url'] = Helpers::getUrlBySkc($product[0]['product_id'], $val['goods_id'], $product[0]['cn_alphabet']);
1200 $result[$key]['src'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]); 1216 $result[$key]['src'] = Images::getImageUrl($val['images_url'], $options['imgSize'][0], $options['imgSize'][1]);
1201 } 1217 }
1202 } 1218 }
1203 - return $result; 1219 + return array_values($result);
1204 } 1220 }
1205 1221
1206 /** 1222 /**
@@ -108,10 +108,6 @@ class ListController extends WebAction @@ -108,10 +108,6 @@ class ListController extends WebAction
108 $this ->echoJson($res); 108 $this ->echoJson($res);
109 return ; 109 return ;
110 } 110 }
111 - //大图  
112 - $imgSize = array();  
113 - //小图  
114 - $minImgSize = array();  
115 $rowNum = $this->post('rowNum'); 111 $rowNum = $this->post('rowNum');
116 if ($rowNum == 5) { 112 if ($rowNum == 5) {
117 $imgSize = array(195, 260); 113 $imgSize = array(195, 260);