Authored by 毕凯

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

@@ -11,3 +11,19 @@ @@ -11,3 +11,19 @@
11 {{/ resetSuccess}} 11 {{/ resetSuccess}}
12 </div> 12 </div>
13 {{> layout/footer}} 13 {{> layout/footer}}
  14 +<script type="text/javascript">
  15 + (function() {
  16 + var count = 5,
  17 + countDown = document.getElementById('count-down');
  18 +
  19 +
  20 + var timer = setInterval(function(){
  21 + if (count > 1) {
  22 + count--;
  23 + countDown.innerHTML = count;
  24 + } else {
  25 + location.href = '/';
  26 + }
  27 + }, 1000);
  28 + })();
  29 +</script>
@@ -5,13 +5,14 @@ use WebPlugin\Images; @@ -5,13 +5,14 @@ use WebPlugin\Images;
5 use Api\Yohobuy; 5 use Api\Yohobuy;
6 use LibModels\Web\Product\HotrankData; 6 use LibModels\Web\Product\HotrankData;
7 use LibModels\Web\Product\SearchData; 7 use LibModels\Web\Product\SearchData;
  8 +use LibModels\Web\Home\IndexData;
  9 +use WebPlugin\DataProcess\WebChannel\Channel as ChannelProcess;
8 10
9 class HotrankModel { 11 class HotrankModel {
10 12
11 /** 13 /**
12 * 获取热销排行频道资源 14 * 获取热销排行频道资源
13 * 15 *
14 - * @param string $channel  
15 * @return array 16 * @return array
16 */ 17 */
17 static public function getChannelResource() 18 static public function getChannelResource()
@@ -34,33 +35,75 @@ class HotrankModel { @@ -34,33 +35,75 @@ class HotrankModel {
34 } 35 }
35 } 36 }
36 37
  38 +
37 /** 39 /**
38 - * 人气单品 一周热卖 40 + * 获取焦点图,热门品牌资源
  41 + * @param string $channel
  42 + * @param string $content_code
  43 + * @return array
39 */ 44 */
40 - static public function getSearchData($param,$page,$ajax) 45 + static public function getFocusResource($channel, $content_code)
41 { 46 {
42 - // 调用接口查询商品数据  
43 - $result = SearchData::searchElasticByCondition($param); 47 + $resource = IndexData::getResourceData($content_code);
  48 + // 格式化数据
  49 + $data = ChannelProcess::getFormat($channel, $resource['data']);
  50 + return $data;
  51 + }
  52 +
44 53
45 - if(!empty($result)) 54 + /**
  55 + * 获取人气单品,一周热卖商品资源
  56 + * @param $config 过滤参数
  57 + * @param $page 当前页数
  58 + * @param $ajax 是否是ajax加载 默认0不是
  59 + */
  60 + static public function getSearchData($config,$page,$ajax)
  61 + {
  62 + //配置查询商品参数
  63 + $viewNum = 60;
  64 + $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'stocknumber'=>1,'status'=>1,
  65 + 'sort'=>$config['sort'],'gender'=>$config['gender'],'attribute_not'=>2);
  66 + if($ajax == 0)
  67 + {
  68 + if($config['sort'] != 0)
46 { 69 {
47 - $res = self::getProductList($result,$page,$ajax);  
48 - if(!empty($res['popular'])) 70 + $param['sort'] = $sort_id;
  71 + }else{
  72 + $param['sort'] = '';
  73 + }
  74 + if($config['road'] == 3)
49 { 75 {
50 - $data['popular'] = $res['popular']; 76 + $param['msort'] = 365;
  77 + }elseif($config['road'] == 4){
  78 + $param['msort'] = 10;
  79 + }else{
  80 + $param['not_maxSortId'] = '10,365';
51 } 81 }
52 - if(!empty($res['hotWeek'])) 82 + }else{
  83 + if(empty($param['sort']))
  84 + {
  85 + if($config['road'] == 3)
53 { 86 {
54 - $data['hotWeek'] = $res['hotWeek']; 87 + $param['msort'] = 365;
  88 + }elseif($config['road'] == 4){
  89 + $param['msort'] = 10;
  90 + }else{
  91 + $param['not_maxSortId'] = '10,365';
55 } 92 }
56 } 93 }
  94 + }
  95 + //根据给定查询数据搜索数据列表
  96 + $result = SearchData::searchElasticByCondition($param);
  97 + $data = self::getProductList($result,$page,$ajax);
57 return $data; 98 return $data;
58 } 99 }
59 100
60 101
61 -  
62 /** 102 /**
63 - * 获取分类标签 103 + * 获取标签资源
  104 + * @param $client_type 客户端类型
  105 + * @param $channel 频道类型
  106 + * @param $is_concurrent 是否异步,true异步,false同步,默认true
64 */ 107 */
65 static public function getHotranktag($client_type,$channel,$is_concurrent) 108 static public function getHotranktag($client_type,$channel,$is_concurrent)
66 { 109 {
@@ -80,6 +123,9 @@ class HotrankModel { @@ -80,6 +123,9 @@ class HotrankModel {
80 123
81 /** 124 /**
82 * 人气单品 一周热卖 数据处理 125 * 人气单品 一周热卖 数据处理
  126 + * @param $result 过滤参数
  127 + * @param $page 当前页数
  128 + * @param $ajax 是否是ajax加载 默认0不是
83 */ 129 */
84 static public function getProductList($result,$page,$ajax=0) 130 static public function getProductList($result,$page,$ajax=0)
85 { 131 {
@@ -144,7 +190,9 @@ class HotrankModel { @@ -144,7 +190,9 @@ class HotrankModel {
144 'name'=>'一周热卖', 190 'name'=>'一周热卖',
145 'list'=>$hot, 191 'list'=>$hot,
146 ); 192 );
147 -  
148 - return array('popular'=>$popular,'hotWeek'=>$hotWeek); 193 + $data['popular'] = $popular;
  194 + $data['hotWeek'] = $hotWeek;
  195 + return $data;
149 } 196 }
  197 +
150 } 198 }
@@ -3,7 +3,7 @@ use Action\WebAction; @@ -3,7 +3,7 @@ use Action\WebAction;
3 use LibModels\Web\Product\BrandData; 3 use LibModels\Web\Product\BrandData;
4 use LibModels\Web\Product\FavoriteData; 4 use LibModels\Web\Product\FavoriteData;
5 5
6 -use \LibModels\Web\Product\HotrankData; 6 +use LibModels\Web\Product\HotrankData;
7 use product\HotrankModel; 7 use product\HotrankModel;
8 use LibModels\Web\Home\IndexData; 8 use LibModels\Web\Home\IndexData;
9 9
@@ -144,28 +144,15 @@ class IndexController extends WebAction @@ -144,28 +144,15 @@ class IndexController extends WebAction
144 ); 144 );
145 145
146 //焦点图 热门品牌 146 //焦点图 热门品牌
147 - $focus = \Index\HomeModel::getChannelResource($channel['channel'], $channel['code']); 147 + $focus = \product\HotrankModel::getFocusResource($channel['channel'], $channel['code']);
148 $data['hotrank']['slide'] = $focus[0]['slide']; 148 $data['hotrank']['slide'] = $focus[0]['slide'];
149 $data['hotrank']['hotBrands'] = $focus[1]['hotBrands']; 149 $data['hotrank']['hotBrands'] = $focus[1]['hotBrands'];
150 150
151 //人气单品 一周热卖 151 //人气单品 一周热卖
152 $page = $this->get('page',1); 152 $page = $this->get('page',1);
153 $sort_id = $this->get('sid',0); 153 $sort_id = $this->get('sid',0);
154 - $viewNum = 60;  
155 - $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'stocknumber'=>1,'status'=>1,'gender'=>$channel['gender'],'attribute_not'=>2);  
156 - if($sort_id != 0)  
157 - {  
158 - $param['sort'] = $sort_id;  
159 - }  
160 - if($channel['road'] == 3)  
161 - {  
162 - $param['msort'] = 365;  
163 - }elseif($channel['road'] == 4){  
164 - $param['msort'] = 10;  
165 - }else{  
166 - $param['not_maxSortId'] = '10,365';  
167 - }  
168 - $publiclist = \product\HotrankModel::getSearchData($param,$page,0); 154 + $config = array('sort' =>$sort_id,'gender' => $channel['gender'],'road' => $channel['road']);
  155 + $publiclist = \product\HotrankModel::getSearchData($config,$page,0);
169 $data['hotrank']['popular'] = $publiclist['popular']; 156 $data['hotrank']['popular'] = $publiclist['popular'];
170 $data['hotrank']['hotWeek'] = $publiclist['hotWeek']; 157 $data['hotrank']['hotWeek'] = $publiclist['hotWeek'];
171 158
@@ -180,7 +167,6 @@ class IndexController extends WebAction @@ -180,7 +167,6 @@ class IndexController extends WebAction
180 */ 167 */
181 public function getdataAction() 168 public function getdataAction()
182 { 169 {
183 -  
184 $page = $this->get('page',1); 170 $page = $this->get('page',1);
185 //加载到100个以后停止 171 //加载到100个以后停止
186 if($page > 2) 172 if($page > 2)
@@ -200,24 +186,11 @@ class IndexController extends WebAction @@ -200,24 +186,11 @@ class IndexController extends WebAction
200 $sort = $info['data']['category_id']; 186 $sort = $info['data']['category_id'];
201 } 187 }
202 } 188 }
203 - $viewNum = 60;  
204 //获取频道资源 189 //获取频道资源
205 $channel = \product\HotrankModel::getChannelResource(); 190 $channel = \product\HotrankModel::getChannelResource();
206 - $param = array('order'=>'s_n_desc','viewNum'=>$viewNum,'page'=>$page,'sort'=>$sort,'stocknumber'=>1,'status'=>1,  
207 - 'gender'=>$channel['gender'],'attribute_not'=>2,);  
208 - if(empty($param['sort']))  
209 - {  
210 - if($channel['road'] == 3)  
211 - {  
212 - $param['msort'] = 365;  
213 - }elseif($channel['road'] == 4){  
214 - $param['msort'] = 10;  
215 - }else{  
216 - $param['not_maxSortId'] = '10,365';  
217 - }  
218 - }  
219 //一周热卖 191 //一周热卖
220 - $list = \product\HotrankModel::getSearchData($param, $page, 1); 192 + $config = array('sort' =>$sort,'gender' => $channel['gender'],'road' => $channel['road']);
  193 + $list = \product\HotrankModel::getSearchData($config, $page, 1);
221 $lister = $list['hotWeek']['list']; 194 $lister = $list['hotWeek']['list'];
222 $lister = array_values($lister); 195 $lister = array_values($lister);
223 if($sid == 1 && $page == 1) 196 if($sid == 1 && $page == 1)