do home select channel
Showing
14 changed files
with
241 additions
and
142 deletions
@@ -293,8 +293,8 @@ class AbstractAction extends Controller_Abstract | @@ -293,8 +293,8 @@ class AbstractAction extends Controller_Abstract | ||
293 | // 未登录 | 293 | // 未登录 |
294 | else { | 294 | else { |
295 | $footer['pageFooter'] = array(); | 295 | $footer['pageFooter'] = array(); |
296 | - $footer['pageFooter']['loginUrl'] = ''; // 登录链接 | ||
297 | - $footer['pageFooter']['signupUrl'] = ''; // 注册链接 | 296 | + $footer['pageFooter']['loginUrl'] = '/signin.html'; // 登录链接 |
297 | + $footer['pageFooter']['signupUrl'] = '/login.html'; // 注册链接 | ||
298 | } | 298 | } |
299 | 299 | ||
300 | $this->_view->assign('footer', $footer); | 300 | $this->_view->assign('footer', $footer); |
@@ -95,24 +95,23 @@ class Yohobuy | @@ -95,24 +95,23 @@ class Yohobuy | ||
95 | * | 95 | * |
96 | * @param string $url 接口URL | 96 | * @param string $url 接口URL |
97 | * @param array $data 参数列表 | 97 | * @param array $data 参数列表 |
98 | - * @param mixed $cache 控制是否启用接口数据的缓存 如3600表示缓存1小时, false表示不缓存 | ||
99 | * @param bool $returnJson 控制是否返回json格式数据 | 98 | * @param bool $returnJson 控制是否返回json格式数据 |
100 | * @param int $timeout 超时时间 | 99 | * @param int $timeout 超时时间 |
101 | * @return mixed | 100 | * @return mixed |
102 | */ | 101 | */ |
103 | - public static function get($url, $data = array(), $cache = false, $returnJson = false, $timeout = 5) | 102 | + public static function get($url, $data = array(), $returnJson = false, $timeout = 5) |
104 | { | 103 | { |
105 | - // 代表是否开启缓存 | ||
106 | - $useCache = $cache && isset($data['client_secret']); | ||
107 | - | ||
108 | - /* 先尝试获取一级缓存(master), 有数据则直接返回 */ | ||
109 | - if ($useCache) { | ||
110 | - $key = md5($url . $data['client_secret']); | ||
111 | - $result = Cache::get($key, 'master'); | ||
112 | - if (!empty($result)) { | ||
113 | - return $result; | ||
114 | - } | ||
115 | - } | 104 | +// // 代表是否开启缓存 |
105 | +// $useCache = $cache && isset($data['client_secret']); | ||
106 | +// | ||
107 | +// /* 先尝试获取一级缓存(master), 有数据则直接返回 */ | ||
108 | +// if ($useCache) { | ||
109 | +// $key = md5($url . $data['client_secret']); | ||
110 | +// $result = Cache::get($key, 'master'); | ||
111 | +// if (!empty($result)) { | ||
112 | +// return $result; | ||
113 | +// } | ||
114 | +// } | ||
116 | 115 | ||
117 | // 销毁私钥参数 | 116 | // 销毁私钥参数 |
118 | if (isset($data['private_key'])) { | 117 | if (isset($data['private_key'])) { |
@@ -133,17 +132,17 @@ class Yohobuy | @@ -133,17 +132,17 @@ class Yohobuy | ||
133 | curl_close($ch); | 132 | curl_close($ch); |
134 | $data = array(); | 133 | $data = array(); |
135 | 134 | ||
136 | - /* 设置一级二级缓存 或 获取二级缓存(slave) */ | ||
137 | - if ($useCache) { | ||
138 | - // 如果接口异常没数据返回,则获取二级缓存 | ||
139 | - if (empty($result)) { | ||
140 | - $result = Cache::get($key, 'slave'); | ||
141 | - } | ||
142 | - // 如果接口正常有数据返回,则设置数据缓存 | ||
143 | - else { | ||
144 | - Cache::set($key, $result); | ||
145 | - } | ||
146 | - } | 135 | +// /* 设置一级二级缓存 或 获取二级缓存(slave) */ |
136 | +// if ($useCache) { | ||
137 | +// // 如果接口异常没数据返回,则获取二级缓存 | ||
138 | +// if (empty($result)) { | ||
139 | +// $result = Cache::get($key, 'slave'); | ||
140 | +// } | ||
141 | +// // 如果接口正常有数据返回,则设置数据缓存 | ||
142 | +// else { | ||
143 | +// Cache::set($key, $result); | ||
144 | +// } | ||
145 | +// } | ||
147 | 146 | ||
148 | return $result; | 147 | return $result; |
149 | } | 148 | } |
@@ -298,7 +297,6 @@ class Yohobuy | @@ -298,7 +297,6 @@ class Yohobuy | ||
298 | try { | 297 | try { |
299 | $result = call_user_func_array(array($client, $method), $parameters); | 298 | $result = call_user_func_array(array($client, $method), $parameters); |
300 | } catch (\Exception $e) { | 299 | } catch (\Exception $e) { |
301 | - var_dump($e); | ||
302 | $result = array(); | 300 | $result = array(); |
303 | } | 301 | } |
304 | 302 |
1 | <?php | 1 | <?php |
2 | + | ||
2 | namespace LibModels\Wap\Home; | 3 | namespace LibModels\Wap\Home; |
3 | 4 | ||
4 | use Api\Yohobuy; | 5 | use Api\Yohobuy; |
@@ -15,6 +16,7 @@ use Api\Sign; | @@ -15,6 +16,7 @@ use Api\Sign; | ||
15 | */ | 16 | */ |
16 | class IndexData | 17 | class IndexData |
17 | { | 18 | { |
19 | + | ||
18 | /** | 20 | /** |
19 | * 获取启动轮播图 | 21 | * 获取启动轮播图 |
20 | * | 22 | * |
@@ -24,11 +26,15 @@ class IndexData | @@ -24,11 +26,15 @@ class IndexData | ||
24 | { | 26 | { |
25 | // 构建必传参数 | 27 | // 构建必传参数 |
26 | $param = Yohobuy::param(); | 28 | $param = Yohobuy::param(); |
27 | - | ||
28 | $param['content_code'] = '7ba9118028f9b22090b57341487567eb'; | 29 | $param['content_code'] = '7ba9118028f9b22090b57341487567eb'; |
29 | $param['client_secret'] = Sign::getSign($param); | 30 | $param['client_secret'] = Sign::getSign($param); |
31 | + $response = Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/get', $param); | ||
30 | 32 | ||
31 | - return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/get', $param); | 33 | + $result = ''; |
34 | + if (isset($response['data'][0]['data']['list'][0]['src'])) { | ||
35 | + $result = $response['data'][0]['data']['list'][0]['src']; | ||
36 | + } | ||
37 | + return $result; | ||
32 | } | 38 | } |
33 | 39 | ||
34 | /** | 40 | /** |
@@ -40,7 +46,6 @@ class IndexData | @@ -40,7 +46,6 @@ class IndexData | ||
40 | { | 46 | { |
41 | // 构建必传参数 | 47 | // 构建必传参数 |
42 | $param = Yohobuy::param(); | 48 | $param = Yohobuy::param(); |
43 | - | ||
44 | $param['method'] = 'app.cover.getCoverStart'; | 49 | $param['method'] = 'app.cover.getCoverStart'; |
45 | $param['client_secret'] = Sign::getSign($param); | 50 | $param['client_secret'] = Sign::getSign($param); |
46 | 51 | ||
@@ -59,7 +64,6 @@ class IndexData | @@ -59,7 +64,6 @@ class IndexData | ||
59 | $param = Yohobuy::param(); | 64 | $param = Yohobuy::param(); |
60 | $param['method'] = 'app.passport.profile'; | 65 | $param['method'] = 'app.passport.profile'; |
61 | $param['uid'] = $uid; | 66 | $param['uid'] = $uid; |
62 | - | ||
63 | $param['client_secret'] = Sign::getSign($param); | 67 | $param['client_secret'] = Sign::getSign($param); |
64 | 68 | ||
65 | return Yohobuy::get(Yohobuy::API_URL, $param); | 69 | return Yohobuy::get(Yohobuy::API_URL, $param); |
@@ -82,9 +86,9 @@ class IndexData | @@ -82,9 +86,9 @@ class IndexData | ||
82 | $param['content_code'] = $contentCode; | 86 | $param['content_code'] = $contentCode; |
83 | $param['page'] = $page; | 87 | $param['page'] = $page; |
84 | $param['limit'] = $limit; | 88 | $param['limit'] = $limit; |
85 | - | ||
86 | $param['client_secret'] = Sign::getSign($param); | 89 | $param['client_secret'] = Sign::getSign($param); |
87 | 90 | ||
88 | - return Yohobuy::get(Yohobuy::SERVICE_URL.'operations/api/v5/resource/home', $param); | 91 | + return Yohobuy::get(Yohobuy::SERVICE_URL . 'operations/api/v5/resource/home', $param); |
89 | } | 92 | } |
93 | + | ||
90 | } | 94 | } |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | use LibModels\Wap\Home\IndexData; | 4 | use LibModels\Wap\Home\IndexData; |
5 | use Plugin\DataProcess\FloorProcess; | 5 | use Plugin\DataProcess\FloorProcess; |
6 | + | ||
6 | /** | 7 | /** |
7 | * 男生首页 | 8 | * 男生首页 |
8 | */ | 9 | */ |
@@ -11,6 +12,8 @@ class BoysController extends AbstractAction | @@ -11,6 +12,8 @@ class BoysController extends AbstractAction | ||
11 | 12 | ||
12 | public function indexAction() | 13 | public function indexAction() |
13 | { | 14 | { |
15 | + // 设置网站标题 | ||
16 | + $this->setTitle('男生首页'); | ||
14 | // 显示侧边栏 | 17 | // 显示侧边栏 |
15 | $this->setNavSide(); | 18 | $this->setNavSide(); |
16 | 19 | ||
@@ -19,17 +22,15 @@ class BoysController extends AbstractAction | @@ -19,17 +22,15 @@ class BoysController extends AbstractAction | ||
19 | // 设置顶部信息(搜索) | 22 | // 设置顶部信息(搜索) |
20 | $this->setHomeChannelHeader(); | 23 | $this->setHomeChannelHeader(); |
21 | 24 | ||
22 | - $data = array('boysHomePage'=>true); | 25 | + $data = array('boysHomePage' => true); |
23 | 26 | ||
24 | // 频道数据 | 27 | // 频道数据 |
25 | $channelData = IndexData::getUserChannelData(0, '1,3', '201504091403001'); | 28 | $channelData = IndexData::getUserChannelData(0, '1,3', '201504091403001'); |
26 | - $channels = array(); | ||
27 | - if($channelData['code'] == 200) | ||
28 | - { | 29 | + if (isset($channelData['code']) && $channelData['code'] == 200) { |
29 | $data['content'] = FloorProcess::getContent($channelData['data']); | 30 | $data['content'] = FloorProcess::getContent($channelData['data']); |
30 | } | 31 | } |
31 | 32 | ||
32 | - $this->_view->assign('title', '首页'); | ||
33 | $this->_view->display('index', $data); | 33 | $this->_view->display('index', $data); |
34 | } | 34 | } |
35 | + | ||
35 | } | 36 | } |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | use LibModels\Wap\Home\IndexData; | 4 | use LibModels\Wap\Home\IndexData; |
5 | use Plugin\DataProcess\FloorProcess; | 5 | use Plugin\DataProcess\FloorProcess; |
6 | + | ||
6 | /** | 7 | /** |
7 | * 女生首页 | 8 | * 女生首页 |
8 | */ | 9 | */ |
@@ -11,6 +12,8 @@ class GirlsController extends AbstractAction | @@ -11,6 +12,8 @@ class GirlsController extends AbstractAction | ||
11 | 12 | ||
12 | public function indexAction() | 13 | public function indexAction() |
13 | { | 14 | { |
15 | + // 设置网站标题 | ||
16 | + $this->setTitle('女生首页'); | ||
14 | // 显示侧边栏 | 17 | // 显示侧边栏 |
15 | $this->setNavSide(); | 18 | $this->setNavSide(); |
16 | 19 | ||
@@ -23,25 +26,10 @@ class GirlsController extends AbstractAction | @@ -23,25 +26,10 @@ class GirlsController extends AbstractAction | ||
23 | 26 | ||
24 | // 频道数据 | 27 | // 频道数据 |
25 | $channelData = IndexData::getUserChannelData(0, '2,3', '201504091403002'); | 28 | $channelData = IndexData::getUserChannelData(0, '2,3', '201504091403002'); |
26 | - $channels = array(); | ||
27 | - if($channelData['code'] == 200) | ||
28 | - { | 29 | + if (isset($channelData['code']) && $channelData['code'] == 200) { |
29 | $data['content'] = FloorProcess::getContent($channelData['data'], 2); | 30 | $data['content'] = FloorProcess::getContent($channelData['data'], 2); |
30 | } | 31 | } |
31 | 32 | ||
32 | - | ||
33 | - | ||
34 | - /*// 也许喜欢 | ||
35 | - $maybeLikeData = RecomData::mayLike('2,3', 2, false); | ||
36 | - $maybeLike = array(); | ||
37 | - if($maybeLikeData['code'] == 200) | ||
38 | - { | ||
39 | - $maybeLike = FloorProcess::maybeLike($maybeLikeData['data']['product_list']); | ||
40 | - $num = count($data['content']); | ||
41 | - $data['content'][] = array('maybeLike' =>$maybeLike); | ||
42 | - }*/ | ||
43 | - | ||
44 | - $this->_view->assign('title', 'YOHO!有货'); | ||
45 | $this->_view->display('index', $data); | 33 | $this->_view->display('index', $data); |
46 | } | 34 | } |
47 | 35 |
@@ -19,19 +19,17 @@ class IndexController extends AbstractAction | @@ -19,19 +19,17 @@ class IndexController extends AbstractAction | ||
19 | 19 | ||
20 | // 背景图获取 | 20 | // 背景图获取 |
21 | $banner = IndexData::getBannerStart(); | 21 | $banner = IndexData::getBannerStart(); |
22 | - if($banner['code'] == 200) | ||
23 | - { | ||
24 | - foreach ($banner['data'] as $item) { | ||
25 | - foreach ($item['data']['list'] as $val) { | ||
26 | - $data['background'] = Helpers::getImageUrl($val['src'], 640, 800, 1); | ||
27 | - } | ||
28 | - } | 22 | + if ($banner) { |
23 | + $data['background'] = Helpers::getImageUrl($banner, 640, 800, 1); | ||
29 | } | 24 | } |
30 | 25 | ||
31 | - echo '<pre>'; | ||
32 | - print_r($data);exit; | 26 | + // 设置底部导航信息 |
27 | + $this->setNavFooter(); | ||
28 | + | ||
29 | + // 生成HTML (index.html) | ||
30 | + $this->_view->html('index'); | ||
33 | 31 | ||
34 | - $this->_view->assign('title', 'YOHO!有货'); | 32 | + // 渲染模板 |
35 | $this->_view->display('index', $data); | 33 | $this->_view->display('index', $data); |
36 | } | 34 | } |
37 | 35 |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | use LibModels\Wap\Home\IndexData; | 4 | use LibModels\Wap\Home\IndexData; |
5 | use Plugin\DataProcess\FloorProcess; | 5 | use Plugin\DataProcess\FloorProcess; |
6 | + | ||
6 | /** | 7 | /** |
7 | * 儿童首页 | 8 | * 儿童首页 |
8 | */ | 9 | */ |
@@ -11,7 +12,8 @@ class KidsController extends AbstractAction | @@ -11,7 +12,8 @@ class KidsController extends AbstractAction | ||
11 | 12 | ||
12 | public function indexAction() | 13 | public function indexAction() |
13 | { | 14 | { |
14 | - | 15 | + // 设置网站标题 |
16 | + $this->setTitle('潮童首页'); | ||
15 | // 显示侧边栏 | 17 | // 显示侧边栏 |
16 | $this->setNavSide(); | 18 | $this->setNavSide(); |
17 | 19 | ||
@@ -20,18 +22,15 @@ class KidsController extends AbstractAction | @@ -20,18 +22,15 @@ class KidsController extends AbstractAction | ||
20 | // 设置顶部信息(搜索) | 22 | // 设置顶部信息(搜索) |
21 | $this->setHomeChannelHeader(); | 23 | $this->setHomeChannelHeader(); |
22 | 24 | ||
23 | - $data = array('kidsHomePage'=>true); | 25 | + $data = array('kidsHomePage' => true); |
24 | 26 | ||
25 | // 频道数据 | 27 | // 频道数据 |
26 | $channelData = IndexData::getUserChannelData(0, '', 'e9875682c1599a886bfbdb965b740022'); | 28 | $channelData = IndexData::getUserChannelData(0, '', 'e9875682c1599a886bfbdb965b740022'); |
27 | - $channels = array(); | ||
28 | - if($channelData['code'] == 200) | ||
29 | - { | 29 | + if (isset($channelData['code']) && $channelData['code'] == 200) { |
30 | $data['content'] = FloorProcess::getContent($channelData['data'], 3); | 30 | $data['content'] = FloorProcess::getContent($channelData['data'], 3); |
31 | } | 31 | } |
32 | 32 | ||
33 | - $this->_view->assign('title', 'YOHO!有货'); | ||
34 | - | ||
35 | $this->_view->display('index', $data); | 33 | $this->_view->display('index', $data); |
36 | } | 34 | } |
35 | + | ||
37 | } | 36 | } |
@@ -12,6 +12,8 @@ class LifestyleController extends AbstractAction | @@ -12,6 +12,8 @@ class LifestyleController extends AbstractAction | ||
12 | 12 | ||
13 | public function indexAction() | 13 | public function indexAction() |
14 | { | 14 | { |
15 | + // 设置网站标题 | ||
16 | + $this->setTitle('创意生活首页'); | ||
15 | // 显示侧边栏 | 17 | // 显示侧边栏 |
16 | $this->setNavSide(); | 18 | $this->setNavSide(); |
17 | 19 | ||
@@ -20,27 +22,14 @@ class LifestyleController extends AbstractAction | @@ -20,27 +22,14 @@ class LifestyleController extends AbstractAction | ||
20 | // 设置顶部信息(搜索) | 22 | // 设置顶部信息(搜索) |
21 | $this->setHomeChannelHeader(); | 23 | $this->setHomeChannelHeader(); |
22 | 24 | ||
23 | - $data = array('lifestyleHomePage'=>true); | 25 | + $data = array('lifestyleHomePage' => true); |
24 | 26 | ||
25 | // 频道数据 | 27 | // 频道数据 |
26 | $channelData = IndexData::getUserChannelData(0, '', '9aa25f5133f011ec96c2045eb15ae425'); | 28 | $channelData = IndexData::getUserChannelData(0, '', '9aa25f5133f011ec96c2045eb15ae425'); |
27 | - $channels = array(); | ||
28 | - if($channelData['code'] == 200) | ||
29 | - { | 29 | + if (isset($channelData['code']) && $channelData['code'] == 200) { |
30 | $data['content'] = FloorProcess::getContent($channelData['data'], 4); | 30 | $data['content'] = FloorProcess::getContent($channelData['data'], 4); |
31 | } | 31 | } |
32 | 32 | ||
33 | - /*// 也许喜欢 | ||
34 | - $maybeLikeData = RecomData::mayLike('2,3', 2, false); | ||
35 | - $maybeLike = array(); | ||
36 | - if($maybeLikeData['code'] == 200) | ||
37 | - { | ||
38 | - $maybeLike = FloorProcess::maybeLike($maybeLikeData['data']['product_list']); | ||
39 | - $num = count($data['content']); | ||
40 | - $data['content'][] = array('maybeLike' =>$maybeLike); | ||
41 | - }*/ | ||
42 | - | ||
43 | - $this->_view->assign('title', 'YOHO!有货'); | ||
44 | $this->_view->display('index', $data); | 33 | $this->_view->display('index', $data); |
45 | } | 34 | } |
46 | 35 |
@@ -206,7 +206,7 @@ class BackController extends AbstractAction | @@ -206,7 +206,7 @@ class BackController extends AbstractAction | ||
206 | $code = $this->get('code', ''); | 206 | $code = $this->get('code', ''); |
207 | 207 | ||
208 | $data = array( | 208 | $data = array( |
209 | - 'backUrl' => '/passport/login/index', | 209 | + 'backUrl' => '/signin.html', |
210 | 'headerText' => '找回密码', | 210 | 'headerText' => '找回密码', |
211 | 'isPassportPage' => true, | 211 | 'isPassportPage' => true, |
212 | 'backNewPwd' => true, | 212 | 'backNewPwd' => true, |
@@ -228,7 +228,7 @@ class RegController extends AbstractAction | @@ -228,7 +228,7 @@ class RegController extends AbstractAction | ||
228 | */ | 228 | */ |
229 | public function setpasswordAction() | 229 | public function setpasswordAction() |
230 | { | 230 | { |
231 | - $data = array('code' => 400, 'message' => '密码格式不正确!', 'data' => ''); | 231 | + $data = array('code' => 400, 'message' => '密码格式不正确', 'data' => ''); |
232 | 232 | ||
233 | do { | 233 | do { |
234 | /* 判断是不是AJAX请求 */ | 234 | /* 判断是不是AJAX请求 */ |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | -use LibModels\wap\Product\NewsaleData as Newsale; | 4 | +use LibModels\Wap\Product\NewsaleData; |
5 | use Plugin\DataProcess\NewSaleProcess; | 5 | use Plugin\DataProcess\NewSaleProcess; |
6 | + | ||
6 | /** | 7 | /** |
7 | * 新品到着 | 8 | * 新品到着 |
8 | */ | 9 | */ |
9 | class NewsaleController extends AbstractAction | 10 | class NewsaleController extends AbstractAction |
10 | { | 11 | { |
12 | + | ||
11 | public function indexAction() | 13 | public function indexAction() |
12 | { | 14 | { |
15 | + $this->setTitle('新品到着'); | ||
13 | 16 | ||
14 | $data = array( | 17 | $data = array( |
15 | 'newArrival' => true, | 18 | 'newArrival' => true, |
@@ -19,23 +22,18 @@ class NewsaleController extends AbstractAction | @@ -19,23 +22,18 @@ class NewsaleController extends AbstractAction | ||
19 | ); | 22 | ); |
20 | 23 | ||
21 | // 新品到着顶部焦点图 | 24 | // 新品到着顶部焦点图 |
22 | - $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); | 25 | + $focusData = NewsaleData::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); |
23 | // 处理返回的数据 | 26 | // 处理返回的数据 |
24 | $focus = array(); | 27 | $focus = array(); |
25 | - if($focusData['code'] == 200) | ||
26 | - { | 28 | + if (isset($focusData['code']) && $focusData['code'] == 200) { |
27 | $focus = $focusData['data']; | 29 | $focus = $focusData['data']; |
28 | } | 30 | } |
29 | 31 | ||
30 | // 批量获取新品到着商品数据 | 32 | // 批量获取新品到着商品数据 |
31 | - $products = Newsale::getNewProducts('1,3', 1, 60); | 33 | + $products = NewsaleData::getNewProducts('1,3', 1, 60); |
32 | // 添加商品数据 | 34 | // 添加商品数据 |
33 | $data += NewSaleProcess::newSaleData($focus, $products); | 35 | $data += NewSaleProcess::newSaleData($focus, $products); |
34 | 36 | ||
35 | - /*echo '<pre>'; | ||
36 | - print_r($data);exit;*/ | ||
37 | - | ||
38 | - $this->_view->assign('title', '新品到着'); | ||
39 | $this->_view->display('new', $data); | 37 | $this->_view->display('new', $data); |
40 | } | 38 | } |
41 | 39 | ||
@@ -46,8 +44,7 @@ class NewsaleController extends AbstractAction | @@ -46,8 +44,7 @@ class NewsaleController extends AbstractAction | ||
46 | */ | 44 | */ |
47 | public function selectNewSaleAction() | 45 | public function selectNewSaleAction() |
48 | { | 46 | { |
49 | - /*if($this->isAjax()) | ||
50 | - {*/ | 47 | + if ($this->isAjax()) { |
51 | $gender = $this->get('gender', '1,3'); | 48 | $gender = $this->get('gender', '1,3'); |
52 | $brand = $this->get('brand', null); | 49 | $brand = $this->get('brand', null); |
53 | $sort = $this->get('sort', null); | 50 | $sort = $this->get('sort', null); |
@@ -60,13 +57,12 @@ class NewsaleController extends AbstractAction | @@ -60,13 +57,12 @@ class NewsaleController extends AbstractAction | ||
60 | $limit = $this->get('limit', 50); | 57 | $limit = $this->get('limit', 50); |
61 | $page = $this->get('page', 1); | 58 | $page = $this->get('page', 1); |
62 | 59 | ||
63 | - $data = Newsale::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page); | 60 | + $data = NewsaleData::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page); |
64 | 61 | ||
65 | $result = NewSaleProcess::selectData($data); | 62 | $result = NewSaleProcess::selectData($data); |
66 | 63 | ||
67 | $this->_view->display('product', $result); | 64 | $this->_view->display('product', $result); |
68 | - // $this->returnJson(200, '获取成功', $data); | ||
69 | - // } | 65 | + } |
70 | } | 66 | } |
71 | 67 | ||
72 | /** | 68 | /** |
@@ -74,6 +70,8 @@ class NewsaleController extends AbstractAction | @@ -74,6 +70,8 @@ class NewsaleController extends AbstractAction | ||
74 | */ | 70 | */ |
75 | public function discountAction() | 71 | public function discountAction() |
76 | { | 72 | { |
73 | + $this->setTitle('折扣专区'); | ||
74 | + | ||
77 | $data = array( | 75 | $data = array( |
78 | 'discount' => true, | 76 | 'discount' => true, |
79 | 'header' => array( | 77 | 'header' => array( |
@@ -82,35 +80,33 @@ class NewsaleController extends AbstractAction | @@ -82,35 +80,33 @@ class NewsaleController extends AbstractAction | ||
82 | ); | 80 | ); |
83 | 81 | ||
84 | // 折扣专区顶部焦点图 | 82 | // 折扣专区顶部焦点图 |
85 | - $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); | 83 | + $focusData = NewsaleData::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); |
86 | // 处理返回的数据 | 84 | // 处理返回的数据 |
87 | $focus = array(); | 85 | $focus = array(); |
88 | - if($focusData['code'] == 200) | ||
89 | - { | 86 | + if (isset($focusData['code']) && $focusData['code'] == 200) { |
90 | $focus = $focusData['data']; | 87 | $focus = $focusData['data']; |
91 | } | 88 | } |
92 | 89 | ||
93 | // 折扣专区商品数据 | 90 | // 折扣专区商品数据 |
94 | - $products = Newsale::getSaleProducts('1,3', 1); | 91 | + $products = NewsaleData::getSaleProducts('1,3', 1); |
95 | // 更新tabs | 92 | // 更新tabs |
96 | $tabs = array(); | 93 | $tabs = array(); |
97 | foreach (array_keys($products) as $key => $value) { | 94 | foreach (array_keys($products) as $key => $value) { |
98 | $tabItem = array(); | 95 | $tabItem = array(); |
99 | $tabItem['title'] = $value; | 96 | $tabItem['title'] = $value; |
100 | - if($key === 0) | ||
101 | - { | 97 | + if ($key === 0) { |
102 | $tabItem['focus'] = true; | 98 | $tabItem['focus'] = true; |
103 | } | 99 | } |
104 | $tabs[] = $tabItem; | 100 | $tabs[] = $tabItem; |
105 | } | 101 | } |
106 | - $data += array('tabs' => $tabs); | 102 | + $data['tabs'] = $tabs; |
107 | // 添加商品数据 | 103 | // 添加商品数据 |
108 | $data += NewSaleProcess::newSaleData($focus, $products); | 104 | $data += NewSaleProcess::newSaleData($focus, $products); |
109 | 105 | ||
110 | - /*echo '<pre>'; | ||
111 | - print_r($data);exit;*/ | 106 | + /* echo '<pre>'; |
107 | + print_r($data);exit; */ | ||
112 | 108 | ||
113 | - $this->_view->assign('title', '折扣专区'); | ||
114 | $this->_view->display('sale', $data); | 109 | $this->_view->display('sale', $data); |
115 | } | 110 | } |
111 | + | ||
116 | } | 112 | } |
@@ -2,53 +2,181 @@ | @@ -2,53 +2,181 @@ | ||
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | use LibModels\Wap\Product\RecomData; | 4 | use LibModels\Wap\Product\RecomData; |
5 | +use Plugin\Helpers; | ||
5 | 6 | ||
6 | /** | 7 | /** |
7 | - * 商品推荐相关 | ||
8 | - * | ||
9 | - * @name RecomController | ||
10 | - * @package Product | ||
11 | - * @copyright yoho.inc | ||
12 | - * @version 1.0 (2015-10-8 14:43:52) | ||
13 | - * @author fei.hong <fei.hong@yoho.cn> | 8 | + * 推荐相关的控制器 |
14 | */ | 9 | */ |
15 | class RecomController extends AbstractAction | 10 | class RecomController extends AbstractAction |
16 | { | 11 | { |
17 | 12 | ||
18 | /** | 13 | /** |
19 | - * 你可能喜欢的 | ||
20 | - * | ||
21 | - * 备注: | ||
22 | - * 调用位于男生(BOYS),女生(GIRLS),潮童(KIDS),创意生活(LifeStyle)页面的底部. | ||
23 | - * 调用方式为AJAX,需要用JS遍历该数据集,替换图片URL地址中的{width},{height},{mode}. | ||
24 | - * JS替换示例: str.replace("{width}", 300).replace("{height}", 300).replace("{mode}", 2); | 14 | + * 你可能喜欢的BOYS或GIRLS的商品列表 |
25 | * | 15 | * |
26 | - * @param string gender "1,3"表示男, "2,3"表示女, 当channel为3时该参数可不传 | ||
27 | - * @param string channel 1表示男, 2表示女, 3表示潮童 | ||
28 | - * @return json | 16 | + * @param string gender 1,3表示男, 2,3表示女 |
17 | + * @param int page 分页的页码 | ||
18 | + * @return html | ||
29 | */ | 19 | */ |
30 | public function maylikeAction() | 20 | public function maylikeAction() |
31 | { | 21 | { |
32 | - if ($this->isAjax()) { | ||
33 | - $data = ''; | 22 | + do { |
23 | + /* 判断是否是AJAX请求 */ | ||
24 | + if (!$this->isAjax()) { | ||
25 | + break; | ||
26 | + } | ||
27 | + | ||
28 | + /* 判断分页参数是否有效 */ | ||
29 | + $page = $this->get('page', 1); | ||
30 | + if (!is_numeric($page)) { | ||
31 | + break; | ||
32 | + } | ||
33 | + | ||
34 | + /* 取可能喜欢的数据 */ | ||
35 | + $recom = array(); | ||
34 | $gender = $this->get('gender', '1,3'); | 36 | $gender = $this->get('gender', '1,3'); |
35 | - $channel = $this->get('channel', '1'); | 37 | + // 女 |
38 | + if ($gender === '2,3') { | ||
39 | + $recom = RecomData::mayLike('2,3', 2); | ||
40 | + } | ||
41 | + // 男 | ||
42 | + else { | ||
43 | + $recom = RecomData::mayLike('1,3', 1); | ||
44 | + } | ||
36 | 45 | ||
37 | - switch (strval($channel)) { | ||
38 | - case '1': // 男(Boys) | ||
39 | - case '2': // 女(Girls) | ||
40 | - $data = RecomData::mayLike($gender, $channel); | 46 | + /* 判断是否有内容返回 */ |
47 | + if (empty($recom['data']['product_list'])) { | ||
41 | break; | 48 | break; |
42 | - case '3': // 潮童(Kids) | ||
43 | - $data = RecomData::mayLikeKids(); | 49 | + } |
50 | + | ||
51 | + /* 构建商品数据 */ | ||
52 | + $data = array(); | ||
53 | + foreach ($recom['data']['product_list'] as $value) { | ||
54 | + $data['goods'][] = Helpers::formatProduct($value, true); | ||
55 | + } | ||
56 | + $this->_view->display('maylike', $data); | ||
57 | + } | ||
58 | + while (false); | ||
59 | + | ||
60 | + echo ' '; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * 你可能喜欢的潮童的商品列表 | ||
65 | + * | ||
66 | + * @param int page 分页的页码 | ||
67 | + * @return html | ||
68 | + */ | ||
69 | + public function maylikeKidsAction() | ||
70 | + { | ||
71 | + do { | ||
72 | + /* 判断是否是AJAX请求 */ | ||
73 | + if (!$this->isAjax()) { | ||
44 | break; | 74 | break; |
45 | - case '4': // 创意生活(LifeStyle) | ||
46 | - $data = RecomData::mayLikeLifestyle(); | 75 | + } |
76 | + | ||
77 | + /* 判断分页参数是否有效 */ | ||
78 | + $page = $this->get('page', 1); | ||
79 | + if (!is_numeric($page)) { | ||
47 | break; | 80 | break; |
48 | } | 81 | } |
49 | 82 | ||
50 | - $this->echoJson($data); | 83 | + /* 取可能喜欢的数据 */ |
84 | + $recom = RecomData::mayLikeKids(); | ||
85 | + if (empty($recom['data']['product_list'])) { | ||
86 | + break; | ||
51 | } | 87 | } |
88 | + | ||
89 | + /* 构建模板需要的商品数据 */ | ||
90 | + $data = array(); | ||
91 | + foreach ($recom['data']['product_list'] as $value) { | ||
92 | + $data['goods'][] = Helpers::formatProduct($value, true); | ||
93 | + } | ||
94 | + $this->_view->display('maylike', $data); | ||
95 | + } | ||
96 | + while (false); | ||
97 | + | ||
98 | + echo ' '; | ||
99 | + } | ||
100 | + | ||
101 | + /** | ||
102 | + * 你可能喜欢的创意生活的新品到着和人气单品列表 | ||
103 | + * | ||
104 | + * @return html | ||
105 | + */ | ||
106 | + public function maylikeLifeAction() | ||
107 | + { | ||
108 | + do { | ||
109 | + /* 判断是否是AJAX请求 */ | ||
110 | + if (!$this->isAjax()) { | ||
111 | + break; | ||
52 | } | 112 | } |
53 | 113 | ||
114 | + /* 取可能喜欢的数据 */ | ||
115 | + $recom = RecomData::mayLikeLifestyle(); | ||
116 | + if (empty($recom['data']['product_list'])) { | ||
117 | + break; | ||
118 | + } | ||
119 | + | ||
120 | + /* 构建模板需要的商品数据 */ | ||
121 | + $data = array(); | ||
122 | + $build = array(); | ||
123 | + if (!empty($recom['data']['product_list']['top'])) { | ||
124 | + $build = array(); | ||
125 | + $build['show'] = true; | ||
126 | + foreach ($recom['data']['product_list']['top'] as $value) { | ||
127 | + $build['goods'][] = Helpers::formatProduct($value, true); | ||
128 | + } | ||
129 | + $data['goodsContainer'][] = $build; | ||
130 | + } | ||
131 | + if (!empty($recom['data']['product_list']['new'])) { | ||
132 | + $build = array(); | ||
133 | + foreach ($recom['data']['product_list']['new'] as $value) { | ||
134 | + $build['show'] = false; | ||
135 | + $build['goods'][] = Helpers::formatProduct($value, true); | ||
136 | + } | ||
137 | + $data['goodsContainer'][] = $build; | ||
138 | + } | ||
139 | + $this->_view->display('maylikelife', $data); | ||
140 | + } | ||
141 | + while (false); | ||
142 | + | ||
143 | + echo ' '; | ||
144 | + } | ||
145 | + | ||
146 | +// /** | ||
147 | +// * 你可能喜欢的 | ||
148 | +// * | ||
149 | +// * 备注: | ||
150 | +// * 调用位于男生(BOYS),女生(GIRLS),潮童(KIDS),创意生活(LifeStyle)页面的底部. | ||
151 | +// * 调用方式为AJAX,需要用JS遍历该数据集,替换图片URL地址中的{width},{height},{mode}. | ||
152 | +// * JS替换示例: str.replace("{width}", 300).replace("{height}", 300).replace("{mode}", 2); | ||
153 | +// * | ||
154 | +// * @param string gender "1,3"表示男, "2,3"表示女, 当channel为3时该参数可不传 | ||
155 | +// * @param string channel 1表示男, 2表示女, 3表示潮童 | ||
156 | +// * @return json | ||
157 | +// */ | ||
158 | +// public function maylikeAction() | ||
159 | +// { | ||
160 | +// if ($this->isAjax()) { | ||
161 | +// $data = ''; | ||
162 | +// $gender = $this->get('gender', '1,3'); | ||
163 | +// $channel = $this->get('channel', '1'); | ||
164 | +// | ||
165 | +// switch (strval($channel)) { | ||
166 | +// case '1': // 男(Boys) | ||
167 | +// case '2': // 女(Girls) | ||
168 | +// $data = RecomData::mayLike($gender, $channel); | ||
169 | +// break; | ||
170 | +// case '3': // 潮童(Kids) | ||
171 | +// $data = RecomData::mayLikeKids(); | ||
172 | +// break; | ||
173 | +// case '4': // 创意生活(LifeStyle) | ||
174 | +// $data = RecomData::mayLikeLifestyle(); | ||
175 | +// break; | ||
176 | +// } | ||
177 | +// | ||
178 | +// $this->echoJson($data); | ||
179 | +// } | ||
180 | +// } | ||
181 | + | ||
54 | } | 182 | } |
-
Please register or login to post a comment