Authored by cailing

热销修改

@@ -104,7 +104,6 @@ class HotrankModel @@ -104,7 +104,6 @@ class HotrankModel
104 $sort = $info['data']['category_id']; 104 $sort = $info['data']['category_id'];
105 } 105 }
106 } 106 }
107 - //一周热卖  
108 $config = array( 107 $config = array(
109 'sort' => $sort, 108 'sort' => $sort,
110 'gender' => $data['gender'], 109 'gender' => $data['gender'],
@@ -114,7 +113,7 @@ class HotrankModel @@ -114,7 +113,7 @@ class HotrankModel
114 $lister = $list['hotWeek']['list']; 113 $lister = $list['hotWeek']['list'];
115 $lister = array_values($lister); 114 $lister = array_values($lister);
116 if ($sid == 1 && $page == 1) { 115 if ($sid == 1 && $page == 1) {
117 - $lister = array_slice($lister, 10, 50); 116 + $lister = array_slice($lister, 10, 50); //排除十个“人气单品”的商品
118 } 117 }
119 else { 118 else {
120 $lister = array_slice($lister, 0, 50); 119 $lister = array_slice($lister, 0, 50);
@@ -149,10 +148,9 @@ class HotrankModel @@ -149,10 +148,9 @@ class HotrankModel
149 public static function getSearchData($config, $page, $ajax) 148 public static function getSearchData($config, $page, $ajax)
150 { 149 {
151 //配置查询商品参数 150 //配置查询商品参数
152 - $viewNum = 60;  
153 $param = array( 151 $param = array(
154 'order' => 's_n_desc', 152 'order' => 's_n_desc',
155 - 'viewNum' => $viewNum, 153 + 'viewNum' => 60,
156 'page' => $page, 154 'page' => $page,
157 'stocknumber' => 1, 155 'stocknumber' => 1,
158 'status' => 1, 156 'status' => 1,
@@ -206,17 +204,23 @@ class HotrankModel @@ -206,17 +204,23 @@ class HotrankModel
206 public static function getProductList($result, $page, $ajax = 0) 204 public static function getProductList($result, $page, $ajax = 0)
207 { 205 {
208 $product = array(); 206 $product = array();
  207 + if (isset($result) && isset($result['data']) && isset($result['data']['product_list'])) {
  208 + $data = array(
  209 + 'popular' => array(
  210 + 'name' => '人气单品',
  211 + 'list' => array(),
  212 + ),
  213 + 'hotWeek' => array(
  214 + 'name' => '一周热卖',
  215 + 'list' => array(),
  216 + )
  217 + );
209 $url = Helpers::url('/product/pro', '', 'item'); 218 $url = Helpers::url('/product/pro', '', 'item');
210 - if (empty($result) || empty($result['data']) || empty($result['data']['product_list'])) {  
211 - return $product;  
212 - }  
213 - $data = $result['data']['product_list'];  
214 - $popular = array(); //一周热卖  
215 - $hotWeek = array(); //人气单品  
216 - foreach ($data as $key => $val) { 219 + foreach ($result['data']['product_list'] as $key => $val) {
217 if (empty($val['goods_list'])) { 220 if (empty($val['goods_list'])) {
218 continue; 221 continue;
219 } 222 }
  223 + //配置商品图片超链接路径
220 $defaultGoodsId = 0; 224 $defaultGoodsId = 0;
221 foreach ($val['goods_list'] as $v) { 225 foreach ($val['goods_list'] as $v) {
222 if ($v['is_default'] == 'Y') { 226 if ($v['is_default'] == 'Y') {
@@ -234,12 +238,12 @@ class HotrankModel @@ -234,12 +238,12 @@ class HotrankModel
234 if ($key <= 5) { 238 if ($key <= 5) {
235 //6张大图 239 //6张大图
236 $product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2); 240 $product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 378, 504, 2);
237 - $popular['list'][] = $product; 241 + $data['popular']['list'][] = $product;
238 } 242 }
239 else { 243 else {
240 //4张小图 244 //4张小图
241 $product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); 245 $product['img'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
242 - $popular['list'][] = $product; 246 + $data['popular']['list'][] = $product;
243 } 247 }
244 } 248 }
245 else { 249 else {
@@ -248,18 +252,11 @@ class HotrankModel @@ -248,18 +252,11 @@ class HotrankModel
248 $product['url'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html'; 252 $product['url'] = $url . '_' . $product_id . '_' . $defaultGoodsId . '.html';
249 $product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? false : $val['market_price']; 253 $product['marketPrice'] = (int) $val['market_price'] == (int) $val['sales_price'] ? false : $val['market_price'];
250 $product['salePrice'] = empty($val['sales_price']) ? false : $val['sales_price']; 254 $product['salePrice'] = empty($val['sales_price']) ? false : $val['sales_price'];
251 - $product['rank'] = '';  
252 $product['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2); 255 $product['thumb'] = empty($val['default_images']) ? '' : Images::getImageUrl($val['default_images'], 280, 373, 2);
253 - $hot[] = $product; 256 + $data['hotWeek']['list'][] = $product;
  257 + }
254 } 258 }
255 } 259 }
256 - $popular['name'] = '人气单品';  
257 - $hotWeek = array(  
258 - 'name' => '一周热卖',  
259 - 'list' => $hot,  
260 - );  
261 - $data['popular'] = $popular;  
262 - $data['hotWeek'] = $hotWeek;  
263 return $data; 260 return $data;
264 } 261 }
265 262