Authored by yangyang

完成new页面

@@ -2,11 +2,10 @@ @@ -2,11 +2,10 @@
2 2
3 namespace Product; 3 namespace Product;
4 4
5 -use LibModels\Wap\Product\SearchData;  
6 -use LibModels\Web\Product\SearchData as WebProduct;  
7 use Plugin\HelperSearch; 5 use Plugin\HelperSearch;
8 -use \LibModels\Web\Product\SearchData as Search;  
9 -use Plugin\Images; 6 +use Product\SearchModel;
  7 +use Api\Yohobuy;
  8 +
10 /** 9 /**
11 * sale首页模板数据模型 10 * sale首页模板数据模型
12 * 11 *
@@ -14,31 +13,22 @@ use Plugin\Images; @@ -14,31 +13,22 @@ use Plugin\Images;
14 class NewModel 13 class NewModel
15 { 14 {
16 15
17 - public static function getNewSearchData($params, $options) 16 + public static function getNewSearchData($customCondition, $customOptions)
18 { 17 {
19 - $data = array();  
20 - // 调用接口查询商品数据  
21 - $result = SearchData::searchElasticByCondition($params);  
22 - if (isset($result['code']) && $result['code'] === 200) {  
23 - // 调用分类信息  
24 - $category = Search::getClassesData();  
25 - if (isset($category['code']) && $category['code'] === 200) {  
26 - $result['data']['filter']['group_sort'] = $category['data']['sort'];  
27 - }  
28 - // 调用折扣区间  
29 - $discount = Search::getDiscount();  
30 - if (isset($discount['code']) && $discount['code'] === 200) {  
31 - $result['data']['filter']['discount'] = $discount['data']['discount'];  
32 - }  
33 - // 调用最新上架  
34 - $recent = Search::recentShelve();  
35 - if (isset($discount['code']) && $discount['code'] === 200) {  
36 - $result['data']['filter']['recent'] = $recent['data']['recent'];  
37 - } 18 + $urlList = array();
  19 + $searchCondition = SearchModel::searchCondition($customCondition, $customOptions);
  20 + // 组合搜索商品url
  21 + $urlList['product'] = HelperSearch::getProductUrl($searchCondition['condition']);
  22 + // 组合搜索分类url
  23 + $urlList['sort'] = HelperSearch::getClassesUrl($searchCondition['condition']);
  24 + // 组合搜索最新上架url
  25 + $urlList['recent'] = HelperSearch::getRecentShelveUrl($searchCondition['condition']);
38 //用户浏览记录 26 //用户浏览记录
39 - $result['data']['filter']['review'] = Search::getRecentReview(); 27 + //$urlList['reviewUrl'] = HelperSearch::getReviewUrl($searchCondition['condition']);
  28 +
  29 + $result = Yohobuy::getMulti($urlList, array(), true);
40 // 组织模板数据 30 // 组织模板数据
41 - $data = HelperSearch::getList($result, $options); 31 + $data = HelperSearch::getList($result, $searchCondition['options']);
42 32
43 //new页面模拟数据 33 //new页面模拟数据
44 $data['newMain'] = array( 34 $data['newMain'] = array(
@@ -72,12 +62,8 @@ class NewModel @@ -72,12 +62,8 @@ class NewModel
72 ) 62 )
73 ) 63 )
74 ); 64 );
75 - }  
76 65
77 - return array(  
78 - 'productListPage' => true,  
79 - 'newSale' => $data  
80 - ); 66 + return $data;
81 } 67 }
82 68
83 } 69 }
  1 +<?php
  2 +
  3 +use Action\WebAction;
  4 +
  5 +/**
  6 + * new页
  7 + *
  8 + */
  9 +class NewController extends WebAction
  10 +{
  11 +
  12 + public function indexAction()
  13 + {
  14 + $condition = array(
  15 + 'order' => 's_t_desc'
  16 + );
  17 + $options = array(
  18 + 'specialsale_id' => 'Y',
  19 + 'needDay' => 'Y'
  20 + );
  21 +
  22 + $newData = Product\NewModel::getNewSearchData($condition, $options);
  23 + $data = array(
  24 + 'productListPage' => true,
  25 + 'newSale' => $newData
  26 + );
  27 + $this->setWebNavHeader();
  28 + //渲染模板
  29 + $this->_view->display('new-sale', $data);
  30 + }
  31 +
  32 +}
1 -<?php  
2 -  
3 -use Action\WebAction;  
4 -use LibModels\Web\Product\SaleData;  
5 -  
6 -/**  
7 - * new页  
8 - *  
9 - */  
10 -class NewController extends WebAction  
11 -{  
12 -  
13 - public function indexAction()  
14 - {  
15 - /* 过滤请求参数 */  
16 - $condition = array();  
17 - $condition = filter_input_array(INPUT_GET, array(  
18 - //'query' => FILTER_SANITIZE_STRING,  
19 - 'sort' => FILTER_VALIDATE_INT,  
20 - 'msort' => FILTER_VALIDATE_INT,  
21 - 'misort' => FILTER_VALIDATE_INT,  
22 - 'color' => FILTER_VALIDATE_INT,  
23 - 'size' => FILTER_VALIDATE_INT,  
24 - 'style' => FILTER_DEFAULT,  
25 - 'price' => FILTER_DEFAULT,  
26 - 'gender' => FILTER_DEFAULT,  
27 - 'p_d' => FILTER_DEFAULT,  
28 - 'shelve_time' => FILTER_DEFAULT,  
29 - 'isNew' => FILTER_DEFAULT,  
30 - 'specialoffer' => FILTER_DEFAULT,  
31 - 'limited' => FILTER_DEFAULT,  
32 - 'order' => FILTER_DEFAULT,  
33 - 'viewNum' => FILTER_VALIDATE_INT,  
34 - 'rowNum' => FILTER_VALIDATE_INT,  
35 - 'page' => FILTER_VALIDATE_INT,), false);  
36 -  
37 - //字符转码  
38 - if (!empty($condition)) {  
39 - foreach ($condition as &$value) {  
40 - $value = rawurldecode($value);  
41 - }  
42 - }  
43 -  
44 - //获取性别数据  
45 - $gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));  
46 - $condition['gender'] = $gender;  
47 -  
48 - //每页显示商品数  
49 - if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {  
50 - $condition['viewNum'] = 60;  
51 - }  
52 - $view_num_arr = array(60, 100, 200);  
53 - if (!in_array($condition['viewNum'], $view_num_arr)) {  
54 - $condition['viewNum'] = 60;  
55 - }  
56 - //每行显示的商品数量  
57 - if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {  
58 - $condition['rowNum'] = 5;  
59 - }  
60 - if ($condition['rowNum'] == 6) {  
61 - $imgSize = array(195, 260);  
62 - $minImgSize = array(50, 67);  
63 - } else {  
64 - $condition['rowNum'] = 5;  
65 - $imgSize = array(235, 314);  
66 - $minImgSize = array(60, 80);  
67 - }  
68 - //搜索词  
69 - //$query = $this->get('query');  
70 - $condition['needFilter'] = 1;  
71 - $options = array(  
72 - 'imgSize' => $imgSize,  
73 - 'minImgSize' => $minImgSize,  
74 - 'gender' => $gender,  
75 - 'needPd' => 'Y',  
76 - 'rowNum' => $condition['rowNum'],  
77 - 'viewNum' => $condition['viewNum'],  
78 - 'specialsale_id' => 'Y'  
79 - );  
80 -  
81 - $params = $condition + $_GET;  
82 - $params['attribute_not'] = 2;  
83 - $params = array_filter($params);  
84 - //每页记录数减1,下一页占位  
85 - $params['viewNum'] = $params['viewNum'] - 1;  
86 -  
87 - $data = Product\NewModel::getNewSearchData($params, $options);  
88 - $cate = array('boys', 'girls', 'kids', 'lifestyle');  
89 - $this->setWebNavHeader($cate[$gender - 1]);  
90 - //渲染模板  
91 - $this->_view->display('new-sale', $data);  
92 - }  
93 -  
94 -}