Showing
9 changed files
with
281 additions
and
95 deletions
1 | +<?php | ||
2 | +namespace LibModels\wap\Home; | ||
3 | + | ||
4 | +use Api\Yohobuy; | ||
5 | +use Api\Sign; | ||
6 | +use Plugin\Helpers; | ||
7 | + | ||
8 | +/** | ||
9 | + * 首页数据接口操作类 | ||
10 | + * | ||
11 | + * @name IndexData | ||
12 | + * @package Library/LibModels/wap/Home | ||
13 | + * @copyright yoho.inc | ||
14 | + * @version 1.0 (2015-10-9) | ||
15 | + * @author gtskk <rocky.zhang@yoho.cn> | ||
16 | + */ | ||
17 | +class IndexData | ||
18 | +{ | ||
19 | + /** | ||
20 | + * 获取启动轮播图 | ||
21 | + * | ||
22 | + * @return array 轮播图有关数据 | ||
23 | + */ | ||
24 | + public static function getBannerStart() | ||
25 | + { | ||
26 | + // 构建必传参数 | ||
27 | + $param = Yohobuy::param(); | ||
28 | + | ||
29 | + $param['content_code'] = '7ba9118028f9b22090b57341487567eb'; | ||
30 | + $param['client_secret'] = Sign::getSign($param); | ||
31 | + | ||
32 | + return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/get', $param); | ||
33 | + } | ||
34 | + | ||
35 | + /** | ||
36 | + * 获取启动封面图 | ||
37 | + * | ||
38 | + * @return array 封面图有关数据 | ||
39 | + */ | ||
40 | + public static function getCoverStart() | ||
41 | + { | ||
42 | + // 构建必传参数 | ||
43 | + $param = Yohobuy::param(); | ||
44 | + | ||
45 | + $param['method'] = 'app.cover.getCoverStart'; | ||
46 | + $param['client_secret'] = Sign::getSign($param); | ||
47 | + | ||
48 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
49 | + } | ||
50 | + | ||
51 | + /** | ||
52 | + * 获取启动页频道数据 | ||
53 | + * | ||
54 | + * @return array 启动页频道有关数据 | ||
55 | + */ | ||
56 | + public static function getHomeChannels() | ||
57 | + { | ||
58 | + // 构建必传参数 | ||
59 | + $param = Yohobuy::param(); | ||
60 | + | ||
61 | + $param['client_secret'] = Sign::getSign($param); | ||
62 | + | ||
63 | + return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/category/getCategory', $param); | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * 获取用户个人信息 | ||
68 | + * | ||
69 | + * @param integer $uid 用户ID | ||
70 | + * @return array 用户个人信息数据 | ||
71 | + */ | ||
72 | + public static function getUserProfile($uid) | ||
73 | + { | ||
74 | + // 构建必传参数 | ||
75 | + $param = Yohobuy::param(); | ||
76 | + $param['method'] = 'app.passport.profile'; | ||
77 | + $param['uid'] = $uid; | ||
78 | + | ||
79 | + $param['client_secret'] = Sign::getSign($param); | ||
80 | + | ||
81 | + return Yohobuy::get(Yohobuy::API_URL, $param); | ||
82 | + } | ||
83 | + | ||
84 | + /** | ||
85 | + * 获取首页频道数据(除了可能喜欢的各楼层有关数据) | ||
86 | + * @param integer $uid 用户ID | ||
87 | + * @param string $gender 用户性别, "1,3"表示男, "2,3"表示女, "1,2,3"表示全部 | ||
88 | + * @param string $contentCode 内容位置码 | ||
89 | + * @param integer $limit 查询返回的最大限字数,默认为20 | ||
90 | + * @param integer $page 分页第几页,默认为第1页 | ||
91 | + * @return array 首页频道数据 | ||
92 | + */ | ||
93 | + public static function getUserChannelData($uid, $gender, $contentCode, $limit = 20, $page = 1) | ||
94 | + { | ||
95 | + $param = Yohobuy::param(); | ||
96 | + $param['uid'] = $uid; | ||
97 | + $param['gender'] = $gender; | ||
98 | + $param['content_code'] = $contentCode; | ||
99 | + $param['page'] = $page; | ||
100 | + $param['limit'] = $limit; | ||
101 | + | ||
102 | + $param['client_secret'] = Sign::getSign($param); | ||
103 | + | ||
104 | + return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/home', $param); | ||
105 | + } | ||
106 | +} |
@@ -9,7 +9,7 @@ use Plugin\Helpers; | @@ -9,7 +9,7 @@ use Plugin\Helpers; | ||
9 | * 新品到着,折扣专区接口操作类 | 9 | * 新品到着,折扣专区接口操作类 |
10 | * | 10 | * |
11 | * @name NewsaleData | 11 | * @name NewsaleData |
12 | - * @package Library/LibModels/Channel | 12 | + * @package Library/LibModels/wap/Product |
13 | * @copyright yoho.inc | 13 | * @copyright yoho.inc |
14 | * @version 1.0 (2015-10-8) | 14 | * @version 1.0 (2015-10-8) |
15 | * @author gtskk <rocky.zhang@yoho.cn> | 15 | * @author gtskk <rocky.zhang@yoho.cn> |
@@ -50,15 +50,17 @@ class NewsaleData | @@ -50,15 +50,17 @@ class NewsaleData | ||
50 | $param['page'] = $page; | 50 | $param['page'] = $page; |
51 | $param['limit'] = $limit; | 51 | $param['limit'] = $limit; |
52 | $param['yh_channel'] = $channel; | 52 | $param['yh_channel'] = $channel; |
53 | - $param['client_secret'] = Sign::getSign($param); | ||
54 | 53 | ||
55 | // 构建url地址列表 | 54 | // 构建url地址列表 |
56 | $urlList = array(); | 55 | $urlList = array(); |
57 | $param['dayLimit'] = 1; | 56 | $param['dayLimit'] = 1; |
57 | + $param['client_secret'] = Sign::getSign($param); | ||
58 | $urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 58 | $urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); |
59 | $param['dayLimit'] = 2; | 59 | $param['dayLimit'] = 2; |
60 | + $param['client_secret'] = Sign::getSign($param); | ||
60 | $urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 61 | $urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); |
61 | $param['dayLimit'] = 3; | 62 | $param['dayLimit'] = 3; |
63 | + $param['client_secret'] = Sign::getSign($param); | ||
62 | $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 64 | $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); |
63 | //var_dump($urlList);exit; | 65 | //var_dump($urlList);exit; |
64 | 66 | ||
@@ -66,34 +68,34 @@ class NewsaleData | @@ -66,34 +68,34 @@ class NewsaleData | ||
66 | } | 68 | } |
67 | 69 | ||
68 | /** | 70 | /** |
69 | - * 筛选新品到着商品 | 71 | + * 筛选新品到着、折扣专区商品 |
70 | * | 72 | * |
71 | - * @param | ||
72 | - * @param array $selectParams 筛选条件参数,可传递的条件参数有: | ||
73 | - * string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部 | ||
74 | - * integer brand 品牌Id | ||
75 | - * integer sort 品类Id | ||
76 | - * integer color 颜色Id | ||
77 | - * integer size 尺码Id | ||
78 | - * string price 价格 | ||
79 | - * string p_d 折扣 | ||
80 | - * @param string $channel 1表示男, 2表示女 | ||
81 | - * @param integer $dayLimit 限制读取多少天,默认为1天 | ||
82 | - * @param integer $limit 查询返回的最大限制数, 默认为50 | ||
83 | - * @param integer $page 分页第几页, 默认第1页 | ||
84 | - * @return array 筛选出来的新品到着商品 | 73 | + * @param string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部 |
74 | + * @param integer $brand 品牌Id | ||
75 | + * @param integer $sort 品类Id | ||
76 | + * @param integer $color 颜色Id | ||
77 | + * @param integer $size 尺码Id | ||
78 | + * @param string $price 价格 | ||
79 | + * @param string $p_d 折扣 | ||
80 | + * @param string $channel 1表示男, 2表示女 | ||
81 | + * @param integer $dayLimit 限制读取多少天,默认为1天 | ||
82 | + * @param integer $limit 查询返回的最大限制数, 默认为50 | ||
83 | + * @param integer $page 分页第几页, 默认第1页 | ||
84 | + * @return array 根据指定条件筛选出来的商品 | ||
85 | */ | 85 | */ |
86 | - public static function selectNewProducts(array $selectParams, $channel, $dayLimit = 1, $limit = 50, $page = 1) | 86 | + public static function selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit = null, $limit = 50, $page = 1) |
87 | { | 87 | { |
88 | $selectItems = array( | 88 | $selectItems = array( |
89 | - 'gender', | ||
90 | - 'brand', | ||
91 | - 'sort', | ||
92 | - 'color', | ||
93 | - 'size', | ||
94 | - 'price', | ||
95 | - 'p_d' | 89 | + 'gender' => $gender, |
90 | + 'brand' => $brand, | ||
91 | + 'sort' => $sort, | ||
92 | + 'color' => $color, | ||
93 | + 'size' => $size, | ||
94 | + 'price' => $price, | ||
95 | + 'p_d' => $p_d | ||
96 | ); | 96 | ); |
97 | + // 拉取筛选参数 | ||
98 | + $queriedParams = array_filter($selectItems, function($v) {return $v !== null;}); | ||
97 | 99 | ||
98 | $param = Yohobuy::param(); | 100 | $param = Yohobuy::param(); |
99 | $param['method'] = 'app.search.newProduct'; | 101 | $param['method'] = 'app.search.newProduct'; |
@@ -101,10 +103,8 @@ class NewsaleData | @@ -101,10 +103,8 @@ class NewsaleData | ||
101 | $param['page'] = $page; | 103 | $param['page'] = $page; |
102 | $param['limit'] = $limit; | 104 | $param['limit'] = $limit; |
103 | $param['yh_channel'] = $channel; | 105 | $param['yh_channel'] = $channel; |
104 | - | ||
105 | - // 拉取筛选参数 | ||
106 | - $queriedParams = Helpers::array_get($selectParams, $selectItems); | ||
107 | $param = array_merge($param, $queriedParams); | 106 | $param = array_merge($param, $queriedParams); |
107 | + | ||
108 | $param['client_secret'] = Sign::getSign($param); | 108 | $param['client_secret'] = Sign::getSign($param); |
109 | 109 | ||
110 | return Yohobuy::get(Yohobuy::API_URL, $param); | 110 | return Yohobuy::get(Yohobuy::API_URL, $param); |
@@ -128,19 +128,21 @@ class NewsaleData | @@ -128,19 +128,21 @@ class NewsaleData | ||
128 | $param['page'] = $page; | 128 | $param['page'] = $page; |
129 | $param['limit'] = $limit; | 129 | $param['limit'] = $limit; |
130 | $param['yh_channel'] = $channel; | 130 | $param['yh_channel'] = $channel; |
131 | - $param['client_secret'] = Sign::getSign($param); | ||
132 | 131 | ||
133 | // 构建url地址列表 | 132 | // 构建url地址列表 |
134 | $urlList = array(); | 133 | $urlList = array(); |
135 | $param['p_d'] = '0.1,0.3'; | 134 | $param['p_d'] = '0.1,0.3'; |
136 | - $urlList['new'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 135 | + $param['client_secret'] = Sign::getSign($param); |
136 | + $urlList['oneThree'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | ||
137 | $param['p_d'] = '0.4,0.6'; | 137 | $param['p_d'] = '0.4,0.6'; |
138 | - $urlList['week'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 138 | + $param['client_secret'] = Sign::getSign($param); |
139 | + $urlList['fourSix'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | ||
139 | $param['p_d'] = '0.7,0.9'; | 140 | $param['p_d'] = '0.7,0.9'; |
140 | - $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | 141 | + $param['client_secret'] = Sign::getSign($param); |
142 | + $urlList['SevenNine'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | ||
141 | $param['p_d'] = '0.1,0.9'; | 143 | $param['p_d'] = '0.1,0.9'; |
142 | - $urlList['sale'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | ||
143 | - // var_dump($urlList);exit; | 144 | + $param['client_secret'] = Sign::getSign($param); |
145 | + $urlList['OneNine'] = Yohobuy::httpBuildQuery(Yohobuy::API_URL,$param); | ||
144 | 146 | ||
145 | return Yohobuy::getMulti($urlList); | 147 | return Yohobuy::getMulti($urlList); |
146 | } | 148 | } |
@@ -148,41 +150,39 @@ class NewsaleData | @@ -148,41 +150,39 @@ class NewsaleData | ||
148 | /** | 150 | /** |
149 | * 筛选折扣专区商品 | 151 | * 筛选折扣专区商品 |
150 | * | 152 | * |
151 | - * @param | ||
152 | - * @param array $selectParams 筛选条件参数,可传递的条件参数有: | ||
153 | - * string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部 | ||
154 | - * integer brand 品牌Id | ||
155 | - * integer sort 品类Id | ||
156 | - * integer color 颜色Id | ||
157 | - * integer size 尺码Id | ||
158 | - * string price 价格 | ||
159 | - * @param string $channel 1表示男, 2表示女 | ||
160 | - * @param integer $discount 折扣 | ||
161 | - * @param integer $limit 查询返回的最大限制数, 默认为50 | ||
162 | - * @param integer $page 分页第几页, 默认第1页 | ||
163 | - * @return array 筛选出来的折扣专区商品 | 153 | + * @param string gender "1,3"表示男, "2,3"表示女, "1,2,3"表示全部 |
154 | + * @param integer brand 品牌Id | ||
155 | + * @param integer sort 品类Id | ||
156 | + * @param integer color 颜色Id | ||
157 | + * @param integer size 尺码Id | ||
158 | + * @param string price 价格 | ||
159 | + * @param string $channel 1表示男, 2表示女 | ||
160 | + * @param integer $p_d 折扣 | ||
161 | + * @param integer $limit 查询返回的最大限制数, 默认为50 | ||
162 | + * @param integer $page 分页第几页, 默认第1页 | ||
163 | + * @return array 筛选出来的折扣专区商品 | ||
164 | */ | 164 | */ |
165 | - public static function selectSaleProducts(array $selectParams, $channel, $discount, $limit = 50, $page = 1) | 165 | + public static function selectSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $limit = 50, $page = 1) |
166 | { | 166 | { |
167 | $selectItems = array( | 167 | $selectItems = array( |
168 | - 'gender', | ||
169 | - 'brand', | ||
170 | - 'sort', | ||
171 | - 'color', | ||
172 | - 'size', | ||
173 | - 'price' | 168 | + 'gender' => $gender, |
169 | + 'brand' => $brand, | ||
170 | + 'sort' => $sort, | ||
171 | + 'color' => $color, | ||
172 | + 'size' => $size, | ||
173 | + 'price' => $price | ||
174 | ); | 174 | ); |
175 | + // 拉取筛选参数 | ||
176 | + $queriedParams = array_filter($selectItems, function($v) {return $v !== null;}); | ||
175 | 177 | ||
176 | $param = Yohobuy::param(); | 178 | $param = Yohobuy::param(); |
177 | $param['method'] = 'app.search.sales'; | 179 | $param['method'] = 'app.search.sales'; |
178 | $param['yh_channel'] = $channel; | 180 | $param['yh_channel'] = $channel; |
179 | - $param['p_d'] = $discount; | 181 | + $param['p_d'] = $p_d; |
180 | $param['page'] = $page; | 182 | $param['page'] = $page; |
181 | $param['limit'] = $limit; | 183 | $param['limit'] = $limit; |
182 | - | ||
183 | - // 拉取筛选参数 | ||
184 | - $queriedParams = Helpers::array_get($selectParams, $selectItems); | ||
185 | $param = array_merge($param, $queriedParams); | 184 | $param = array_merge($param, $queriedParams); |
185 | + | ||
186 | $param['client_secret'] = Sign::getSign($param); | 186 | $param['client_secret'] = Sign::getSign($param); |
187 | 187 | ||
188 | return Yohobuy::get(Yohobuy::API_URL, $param); | 188 | return Yohobuy::get(Yohobuy::API_URL, $param); |
@@ -26,8 +26,8 @@ class Helpers | @@ -26,8 +26,8 @@ class Helpers | ||
26 | * @param array|string $keys 指定键值,数组或者字符串 | 26 | * @param array|string $keys 指定键值,数组或者字符串 |
27 | * @return array 获取的数据 | 27 | * @return array 获取的数据 |
28 | */ | 28 | */ |
29 | - public static function array_get($array, $keys) | 29 | + /*public static function array_get($array, $keys) |
30 | { | 30 | { |
31 | return array_intersect_key($array, array_flip((array) $keys)); | 31 | return array_intersect_key($array, array_flip((array) $keys)); |
32 | - } | 32 | + }*/ |
33 | } | 33 | } |
1 | <?php | 1 | <?php |
2 | + | ||
2 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use LibModels\Wap\Home\IndexData as Index; | ||
3 | /** | 5 | /** |
4 | * 男生首页 | 6 | * 男生首页 |
5 | */ | 7 | */ |
6 | class BoysController extends AbstractAction | 8 | class BoysController extends AbstractAction |
7 | { | 9 | { |
10 | + | ||
8 | public function indexAction() | 11 | public function indexAction() |
9 | { | 12 | { |
10 | - echo 'boys'; | 13 | + // 频道数据 |
14 | + $channelData = Index::getUserChannelData(0, '1,3', '201504091403001'); | ||
15 | + | ||
16 | + echo '<pre>'; | ||
17 | + print_r($channelData); | ||
18 | + | ||
19 | + $this->_view->assign('title', 'YOHO!有货'); | ||
20 | + $this->_view->display('boys', compact('channelData')); | ||
11 | } | 21 | } |
12 | } | 22 | } |
1 | <?php | 1 | <?php |
2 | + | ||
2 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use LibModels\Wap\Home\IndexData as Index; | ||
3 | /** | 5 | /** |
4 | * 女生首页 | 6 | * 女生首页 |
5 | */ | 7 | */ |
6 | class GirlsController extends AbstractAction | 8 | class GirlsController extends AbstractAction |
7 | { | 9 | { |
10 | + | ||
8 | public function indexAction() | 11 | public function indexAction() |
9 | { | 12 | { |
10 | - echo 'boys'; | 13 | + // 频道数据 |
14 | + $channelData = Index::getUserChannelData(0, '2,3', '201504091403002'); | ||
15 | + | ||
16 | + echo '<pre>'; | ||
17 | + print_r($channelData); | ||
18 | + | ||
19 | + $this->_view->assign('title', 'YOHO!有货'); | ||
20 | + $this->_view->display('girls', compact('channelData')); | ||
11 | } | 21 | } |
12 | } | 22 | } |
1 | <?php | 1 | <?php |
2 | use Action\AbstractAction; | 2 | use Action\AbstractAction; |
3 | -use LibModels\Wap\Guang\PlusstarData; | 3 | +use LibModels\Wap\Home\IndexData as Index; |
4 | 4 | ||
5 | /** | 5 | /** |
6 | * 频道选择 | 6 | * 频道选择 |
7 | */ | 7 | */ |
8 | class IndexController extends AbstractAction | 8 | class IndexController extends AbstractAction |
9 | { | 9 | { |
10 | + | ||
11 | + /** | ||
12 | + * 启动首页 | ||
13 | + */ | ||
10 | public function indexAction() | 14 | public function indexAction() |
11 | { | 15 | { |
12 | - $this->_view->assign('title', 'YOHO!有货'); | ||
13 | - $this->_view->display('index', array('test' => 'hello world')); | ||
14 | - | ||
15 | - $test = PlusstarData::brandInfo(); | ||
16 | - var_dump($test); | 16 | + // 启动滚动图 |
17 | + $startBannerData = Index::getBannerStart(); | ||
18 | + $startBanner = array(); | ||
19 | + if($startBannerData['code'] == 200) | ||
20 | + { | ||
21 | + foreach ($startBannerData['data'] as $single) | ||
22 | + { | ||
23 | + $startBanner = $single['data']; | ||
24 | + } | ||
25 | + | ||
26 | + } | ||
27 | + // 启动频道数据 | ||
28 | + $homeChannels = Index::getHomeChannels(); | ||
29 | + // 用户个人信息 | ||
30 | + $userProfile = Index::getUserProfile(0); | ||
31 | + | ||
32 | + /*echo '<pre>'; | ||
33 | + var_dump($homeChannels);exit;*/ | ||
34 | + | ||
35 | + $this->_view->assign('title', 'YOHO!有货'); | ||
36 | + $this->_view->display('index', compact('startBanner', 'homeChannels', 'userProfile')); | ||
17 | } | 37 | } |
18 | } | 38 | } |
1 | <?php | 1 | <?php |
2 | + | ||
2 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use LibModels\Wap\Home\IndexData as Index; | ||
3 | /** | 5 | /** |
4 | * 潮童首页 | 6 | * 潮童首页 |
5 | */ | 7 | */ |
6 | class KidsController extends AbstractAction | 8 | class KidsController extends AbstractAction |
7 | { | 9 | { |
10 | + | ||
8 | public function indexAction() | 11 | public function indexAction() |
9 | { | 12 | { |
10 | - echo 'kids'; | 13 | + // 频道数据 |
14 | + $channelData = Index::getUserChannelData(0, '', 'e9875682c1599a886bfbdb965b740022'); | ||
15 | + | ||
16 | + echo '<pre>'; | ||
17 | + print_r($channelData); | ||
18 | + | ||
19 | + $this->_view->assign('title', 'YOHO!有货'); | ||
20 | + $this->_view->display('kids', compact('channelData')); | ||
11 | } | 21 | } |
12 | } | 22 | } |
1 | <?php | 1 | <?php |
2 | + | ||
2 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use LibModels\Wap\Home\IndexData as Index; | ||
3 | /** | 5 | /** |
4 | * 创意生活首页 | 6 | * 创意生活首页 |
5 | */ | 7 | */ |
6 | class LifestyleController extends AbstractAction | 8 | class LifestyleController extends AbstractAction |
7 | { | 9 | { |
10 | + | ||
8 | public function indexAction() | 11 | public function indexAction() |
9 | { | 12 | { |
10 | - echo 'life style'; | 13 | + |
14 | + // 频道数据 | ||
15 | + $channelData = Index::getUserChannelData(0, '1,3', '9aa25f5133f011ec96c2045eb15ae425'); | ||
16 | + | ||
17 | + echo '<pre>'; | ||
18 | + print_r($channelData); | ||
19 | + | ||
20 | + $this->_view->assign('title', 'YOHO!有货'); | ||
21 | + $this->_view->display('lifestyle', compact('channelData')); | ||
11 | } | 22 | } |
12 | } | 23 | } |
@@ -14,12 +14,8 @@ class NewsaleController extends AbstractAction | @@ -14,12 +14,8 @@ class NewsaleController extends AbstractAction | ||
14 | 14 | ||
15 | // 新品到着顶部焦点图 | 15 | // 新品到着顶部焦点图 |
16 | $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); | 16 | $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); |
17 | - // 新品到着商品数据 | ||
18 | - // $productsData = Newsale::getNewProducts('1,3', 1, 60); | ||
19 | - | ||
20 | // 处理返回的数据 | 17 | // 处理返回的数据 |
21 | $focus = array(); | 18 | $focus = array(); |
22 | - $products = array(); | ||
23 | if($focusData['code'] == 200) | 19 | if($focusData['code'] == 200) |
24 | { | 20 | { |
25 | foreach ($focusData['data'] as $single) | 21 | foreach ($focusData['data'] as $single) |
@@ -30,24 +26,24 @@ class NewsaleController extends AbstractAction | @@ -30,24 +26,24 @@ class NewsaleController extends AbstractAction | ||
30 | } | 26 | } |
31 | } | 27 | } |
32 | } | 28 | } |
33 | - /*if($productsData['code'] == 200) | ||
34 | - { | ||
35 | - $products = $productsData['data']; | ||
36 | - foreach ($products['product_list'] as &$val) { | ||
37 | - $val['default_images'] = Helpers::getImageUrl($val['default_images'], 290, 386); | ||
38 | - } | ||
39 | - }*/ | 29 | + |
30 | + // 批量获取新品到着商品数据 | ||
31 | + $products = Newsale::getNewProducts('1,3', 1, 60); | ||
40 | var_dump($focus); | 32 | var_dump($focus); |
41 | 33 | ||
42 | $this->_view->display('new', compact('focus', 'products')); | 34 | $this->_view->display('new', compact('focus', 'products')); |
43 | } | 35 | } |
44 | 36 | ||
45 | 37 | ||
38 | + /** | ||
39 | + * Ajax方式筛选新品到着商品 | ||
40 | + * | ||
41 | + * @return array 根据指定条件筛选之后的商品 | ||
42 | + */ | ||
46 | public function selectNewAction() | 43 | public function selectNewAction() |
47 | { | 44 | { |
48 | - if($this->isAjax()) | 45 | + if($this->isAjax()) |
49 | { | 46 | { |
50 | - $data = ''; | ||
51 | $gender = $this->get('gender', '1,3'); | 47 | $gender = $this->get('gender', '1,3'); |
52 | $brand = $this->get('brand', null); | 48 | $brand = $this->get('brand', null); |
53 | $sort = $this->get('sort', null); | 49 | $sort = $this->get('sort', null); |
@@ -56,6 +52,11 @@ class NewsaleController extends AbstractAction | @@ -56,6 +52,11 @@ class NewsaleController extends AbstractAction | ||
56 | $price = $this->get('price', null); | 52 | $price = $this->get('price', null); |
57 | $p_d = $this->get('p_d', null); | 53 | $p_d = $this->get('p_d', null); |
58 | $channel = $this->get('channel', '1'); | 54 | $channel = $this->get('channel', '1'); |
55 | + $dayLimit = $this->get('dayLimit', '1'); | ||
56 | + $limit = $this->get('limit', 50); | ||
57 | + $page = $this->get('page', 1); | ||
58 | + | ||
59 | + $data = Newsale::selectNewProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page); | ||
59 | 60 | ||
60 | $this->echoJson($data); | 61 | $this->echoJson($data); |
61 | } | 62 | } |
@@ -68,12 +69,8 @@ class NewsaleController extends AbstractAction | @@ -68,12 +69,8 @@ class NewsaleController extends AbstractAction | ||
68 | 69 | ||
69 | // 折扣专区顶部焦点图 | 70 | // 折扣专区顶部焦点图 |
70 | $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); | 71 | $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); |
71 | - // 折扣专区商品数据 | ||
72 | - // $productsData = Newsale::getNewProducts('1,3', 1, 60); | ||
73 | - | ||
74 | // 处理返回的数据 | 72 | // 处理返回的数据 |
75 | $focus = array(); | 73 | $focus = array(); |
76 | - $products = array(); | ||
77 | if($focusData['code'] == 200) | 74 | if($focusData['code'] == 200) |
78 | { | 75 | { |
79 | foreach ($focusData['data'] as $single) | 76 | foreach ($focusData['data'] as $single) |
@@ -84,16 +81,38 @@ class NewsaleController extends AbstractAction | @@ -84,16 +81,38 @@ class NewsaleController extends AbstractAction | ||
84 | } | 81 | } |
85 | } | 82 | } |
86 | } | 83 | } |
87 | - /*if($productsData['code'] === 200) | ||
88 | - { | ||
89 | - $products = $productsData['data']; | ||
90 | - foreach ($products['product_list'] as &$val) { | ||
91 | - $val['default_images'] = Helpers::getImageUrl($val['default_images'], 290, 386); | ||
92 | - } | ||
93 | - }*/ | ||
94 | 84 | ||
95 | - var_dump($focus); | 85 | + // 折扣专区商品数据 |
86 | + $products = Newsale::getNewProducts('1,3', 1, 60); | ||
87 | + var_dump($products); | ||
96 | 88 | ||
97 | $this->_view->display('new', compact('focus', 'products')); | 89 | $this->_view->display('new', compact('focus', 'products')); |
98 | } | 90 | } |
91 | + | ||
92 | + /** | ||
93 | + * Ajax方式筛选折扣专区商品 | ||
94 | + * | ||
95 | + * @return array 根据指定条件筛选之后的商品 | ||
96 | + */ | ||
97 | + public function selectSaleAction() | ||
98 | + { | ||
99 | + if($this->isAjax()) | ||
100 | + { | ||
101 | + $gender = $this->get('gender', '1,3'); | ||
102 | + $brand = $this->get('brand', null); | ||
103 | + $sort = $this->get('sort', null); | ||
104 | + $color = $this->get('color', null); | ||
105 | + $size = $this->get('size', null); | ||
106 | + $price = $this->get('price', null); | ||
107 | + $p_d = $this->get('p_d', null); | ||
108 | + $channel = $this->get('channel', '1'); | ||
109 | + $dayLimit = $this->get('dayLimit', '1'); | ||
110 | + $limit = $this->get('limit', 50); | ||
111 | + $page = $this->get('page', 1); | ||
112 | + | ||
113 | + $data = Newsale::selectSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page); | ||
114 | + | ||
115 | + $this->echoJson($data); | ||
116 | + } | ||
117 | + } | ||
99 | } | 118 | } |
-
Please register or login to post a comment