do home select channel
Showing
14 changed files
with
385 additions
and
286 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,35 +16,39 @@ use Api\Sign; | @@ -15,35 +16,39 @@ use Api\Sign; | ||
15 | */ | 16 | */ |
16 | class IndexData | 17 | class IndexData |
17 | { | 18 | { |
18 | - /** | ||
19 | - * 获取启动轮播图 | ||
20 | - * | ||
21 | - * @return array 轮播图有关数据 | ||
22 | - */ | 19 | + |
20 | + /** | ||
21 | + * 获取启动轮播图 | ||
22 | + * | ||
23 | + * @return array 轮播图有关数据 | ||
24 | + */ | ||
23 | public static function getBannerStart() | 25 | public static function getBannerStart() |
24 | { | 26 | { |
25 | - // 构建必传参数 | ||
26 | - $param = Yohobuy::param(); | ||
27 | - | ||
28 | - $param['content_code'] = '7ba9118028f9b22090b57341487567eb'; | 27 | + // 构建必传参数 |
28 | + $param = Yohobuy::param(); | ||
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 | - /** | ||
35 | - * 获取启动封面图 | ||
36 | - * | ||
37 | - * @return array 封面图有关数据 | ||
38 | - */ | 40 | + /** |
41 | + * 获取启动封面图 | ||
42 | + * | ||
43 | + * @return array 封面图有关数据 | ||
44 | + */ | ||
39 | public static function getCoverStart() | 45 | public static function getCoverStart() |
40 | { | 46 | { |
41 | - // 构建必传参数 | ||
42 | - $param = Yohobuy::param(); | ||
43 | - | ||
44 | - $param['method'] = 'app.cover.getCoverStart'; | 47 | + // 构建必传参数 |
48 | + $param = Yohobuy::param(); | ||
49 | + $param['method'] = 'app.cover.getCoverStart'; | ||
45 | $param['client_secret'] = Sign::getSign($param); | 50 | $param['client_secret'] = Sign::getSign($param); |
46 | - | 51 | + |
47 | return Yohobuy::get(Yohobuy::API_URL, $param); | 52 | return Yohobuy::get(Yohobuy::API_URL, $param); |
48 | } | 53 | } |
49 | 54 | ||
@@ -55,13 +60,12 @@ class IndexData | @@ -55,13 +60,12 @@ class IndexData | ||
55 | */ | 60 | */ |
56 | public static function getUserProfile($uid) | 61 | public static function getUserProfile($uid) |
57 | { | 62 | { |
58 | - // 构建必传参数 | ||
59 | - $param = Yohobuy::param(); | ||
60 | - $param['method'] = 'app.passport.profile'; | ||
61 | - $param['uid'] = $uid; | ||
62 | - | 63 | + // 构建必传参数 |
64 | + $param = Yohobuy::param(); | ||
65 | + $param['method'] = 'app.passport.profile'; | ||
66 | + $param['uid'] = $uid; | ||
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); |
66 | } | 70 | } |
67 | 71 | ||
@@ -76,15 +80,15 @@ class IndexData | @@ -76,15 +80,15 @@ class IndexData | ||
76 | */ | 80 | */ |
77 | public static function getUserChannelData($uid, $gender, $contentCode, $limit = 20, $page = 1) | 81 | public static function getUserChannelData($uid, $gender, $contentCode, $limit = 20, $page = 1) |
78 | { | 82 | { |
79 | - $param = Yohobuy::param(); | ||
80 | - $param['uid'] = $uid; | ||
81 | - $param['gender'] = $gender; | ||
82 | - $param['content_code'] = $contentCode; | ||
83 | - $param['page'] = $page; | ||
84 | - $param['limit'] = $limit; | 83 | + $param = Yohobuy::param(); |
84 | + $param['uid'] = $uid; | ||
85 | + $param['gender'] = $gender; | ||
86 | + $param['content_code'] = $contentCode; | ||
87 | + $param['page'] = $page; | ||
88 | + $param['limit'] = $limit; | ||
89 | + $param['client_secret'] = Sign::getSign($param); | ||
85 | 90 | ||
86 | - $param['client_secret'] = Sign::getSign($param); | ||
87 | - | ||
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,33 +3,34 @@ | @@ -3,33 +3,34 @@ | ||
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 | */ |
9 | class BoysController extends AbstractAction | 10 | class BoysController extends AbstractAction |
10 | { | 11 | { |
11 | 12 | ||
12 | - public function indexAction() | ||
13 | - { | ||
14 | - // 显示侧边栏 | ||
15 | - $this->setNavSide(); | 13 | + public function indexAction() |
14 | + { | ||
15 | + // 设置网站标题 | ||
16 | + $this->setTitle('男生首页'); | ||
17 | + // 显示侧边栏 | ||
18 | + $this->setNavSide(); | ||
16 | 19 | ||
17 | - // 显示顶部下载 | 20 | + // 显示顶部下载 |
18 | $this->setHeaderDownload(); | 21 | $this->setHeaderDownload(); |
19 | // 设置顶部信息(搜索) | 22 | // 设置顶部信息(搜索) |
20 | $this->setHomeChannelHeader(); | 23 | $this->setHomeChannelHeader(); |
21 | 24 | ||
22 | - $data = array('boysHomePage'=>true); | 25 | + $data = array('boysHomePage' => true); |
26 | + | ||
27 | + // 频道数据 | ||
28 | + $channelData = IndexData::getUserChannelData(0, '1,3', '201504091403001'); | ||
29 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
30 | + $data['content'] = FloorProcess::getContent($channelData['data']); | ||
31 | + } | ||
23 | 32 | ||
24 | - // 频道数据 | ||
25 | - $channelData = IndexData::getUserChannelData(0, '1,3', '201504091403001'); | ||
26 | - $channels = array(); | ||
27 | - if($channelData['code'] == 200) | ||
28 | - { | ||
29 | - $data['content'] = FloorProcess::getContent($channelData['data']); | ||
30 | - } | 33 | + $this->_view->display('index', $data); |
34 | + } | ||
31 | 35 | ||
32 | - $this->_view->assign('title', '首页'); | ||
33 | - $this->_view->display('index', $data); | ||
34 | - } | ||
35 | -} | ||
36 | +} |
@@ -3,14 +3,17 @@ | @@ -3,14 +3,17 @@ | ||
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 | */ |
9 | class GirlsController extends AbstractAction | 10 | class GirlsController extends AbstractAction |
10 | { | 11 | { |
11 | 12 | ||
12 | - public function indexAction() | ||
13 | - { | 13 | + public function indexAction() |
14 | + { | ||
15 | + // 设置网站标题 | ||
16 | + $this->setTitle('女生首页'); | ||
14 | // 显示侧边栏 | 17 | // 显示侧边栏 |
15 | $this->setNavSide(); | 18 | $this->setNavSide(); |
16 | 19 | ||
@@ -19,30 +22,15 @@ class GirlsController extends AbstractAction | @@ -19,30 +22,15 @@ class GirlsController extends AbstractAction | ||
19 | // 设置顶部信息(搜索) | 22 | // 设置顶部信息(搜索) |
20 | $this->setHomeChannelHeader(); | 23 | $this->setHomeChannelHeader(); |
21 | 24 | ||
22 | - $data = array('grilsHomePage' => true); | ||
23 | - | ||
24 | - // 频道数据 | ||
25 | - $channelData = IndexData::getUserChannelData(0, '2,3', '201504091403002'); | ||
26 | - $channels = array(); | ||
27 | - if($channelData['code'] == 200) | ||
28 | - { | ||
29 | - $data['content'] = FloorProcess::getContent($channelData['data'], 2); | ||
30 | - } | ||
31 | - | ||
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); | ||
46 | - } | 25 | + $data = array('grilsHomePage' => true); |
26 | + | ||
27 | + // 频道数据 | ||
28 | + $channelData = IndexData::getUserChannelData(0, '2,3', '201504091403002'); | ||
29 | + if (isset($channelData['code']) && $channelData['code'] == 200) { | ||
30 | + $data['content'] = FloorProcess::getContent($channelData['data'], 2); | ||
31 | + } | ||
32 | + | ||
33 | + $this->_view->display('index', $data); | ||
34 | + } | ||
47 | 35 | ||
48 | } | 36 | } |
@@ -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; | ||
33 | - | ||
34 | - $this->_view->assign('title', 'YOHO!有货'); | 26 | + // 设置底部导航信息 |
27 | + $this->setNavFooter(); | ||
28 | + | ||
29 | + // 生成HTML (index.html) | ||
30 | + $this->_view->html('index'); | ||
31 | + | ||
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 | } |
37 | -} | ||
35 | + | ||
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,28 +22,15 @@ class LifestyleController extends AbstractAction | @@ -20,28 +22,15 @@ 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 | ||
47 | -} | ||
36 | +} |
@@ -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 | { |
11 | - public function indexAction() | ||
12 | - { | ||
13 | - | ||
14 | - $data = array( | ||
15 | - 'newArrival' => true, | ||
16 | - 'header' => array( | ||
17 | - 'title' => '新品到着' | ||
18 | - ) | ||
19 | - ); | ||
20 | - | ||
21 | - // 新品到着顶部焦点图 | ||
22 | - $focusData = Newsale::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); | ||
23 | - // 处理返回的数据 | ||
24 | - $focus = array(); | ||
25 | - if($focusData['code'] == 200) | ||
26 | - { | ||
27 | - $focus = $focusData['data']; | ||
28 | - } | ||
29 | - | ||
30 | - // 批量获取新品到着商品数据 | ||
31 | - $products = Newsale::getNewProducts('1,3', 1, 60); | ||
32 | - // 添加商品数据 | ||
33 | - $data += NewSaleProcess::newSaleData($focus, $products); | ||
34 | - | ||
35 | - /*echo '<pre>'; | ||
36 | - print_r($data);exit;*/ | ||
37 | - | ||
38 | - $this->_view->assign('title', '新品到着'); | ||
39 | - $this->_view->display('new', $data); | ||
40 | - } | ||
41 | - | ||
42 | - /** | ||
43 | - * Ajax方式筛选新品到着、折扣专区商品 | ||
44 | - * | ||
45 | - * @return array 根据指定条件筛选之后的商品 | ||
46 | - */ | ||
47 | - public function selectNewSaleAction() | ||
48 | - { | ||
49 | - /*if($this->isAjax()) | ||
50 | - {*/ | ||
51 | - $gender = $this->get('gender', '1,3'); | ||
52 | - $brand = $this->get('brand', null); | ||
53 | - $sort = $this->get('sort', null); | ||
54 | - $color = $this->get('color', null); | ||
55 | - $size = $this->get('size', null); | ||
56 | - $price = $this->get('price', null); | ||
57 | - $p_d = $this->get('p_d', null); | ||
58 | - $channel = $this->get('channel', '1'); | ||
59 | - $dayLimit = $this->get('dayLimit', '1'); | ||
60 | - $limit = $this->get('limit', 50); | ||
61 | - $page = $this->get('page', 1); | ||
62 | - | ||
63 | - $data = Newsale::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page); | ||
64 | - | ||
65 | - $result = NewSaleProcess::selectData($data); | ||
66 | - | ||
67 | - $this->_view->display('product', $result); | ||
68 | - // $this->returnJson(200, '获取成功', $data); | ||
69 | - // } | ||
70 | - } | ||
71 | - | ||
72 | - /** | ||
73 | - * 折扣专区 | ||
74 | - */ | ||
75 | - public function discountAction() | ||
76 | - { | ||
77 | - $data = array( | ||
78 | - 'discount' => true, | ||
79 | - 'header' => array( | ||
80 | - 'title' => 'SALE' | ||
81 | - ) | ||
82 | - ); | ||
83 | - | ||
84 | - // 折扣专区顶部焦点图 | ||
85 | - $focusData = Newsale::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); | ||
86 | - // 处理返回的数据 | ||
87 | - $focus = array(); | ||
88 | - if($focusData['code'] == 200) | ||
89 | - { | ||
90 | - $focus = $focusData['data']; | ||
91 | - } | ||
92 | - | ||
93 | - // 折扣专区商品数据 | ||
94 | - $products = Newsale::getSaleProducts('1,3', 1); | ||
95 | - // 更新tabs | ||
96 | - $tabs = array(); | ||
97 | - foreach (array_keys($products) as $key => $value) { | ||
98 | - $tabItem = array(); | ||
99 | - $tabItem['title'] = $value; | ||
100 | - if($key === 0) | ||
101 | - { | ||
102 | - $tabItem['focus'] = true; | ||
103 | - } | ||
104 | - $tabs[] = $tabItem; | ||
105 | - } | ||
106 | - $data += array('tabs' => $tabs); | ||
107 | - // 添加商品数据 | ||
108 | - $data += NewSaleProcess::newSaleData($focus, $products); | ||
109 | - | ||
110 | - /*echo '<pre>'; | ||
111 | - print_r($data);exit;*/ | ||
112 | - | ||
113 | - $this->_view->assign('title', '折扣专区'); | ||
114 | - $this->_view->display('sale', $data); | ||
115 | - } | ||
116 | -} | ||
12 | + | ||
13 | + public function indexAction() | ||
14 | + { | ||
15 | + $this->setTitle('新品到着'); | ||
16 | + | ||
17 | + $data = array( | ||
18 | + 'newArrival' => true, | ||
19 | + 'header' => array( | ||
20 | + 'title' => '新品到着' | ||
21 | + ) | ||
22 | + ); | ||
23 | + | ||
24 | + // 新品到着顶部焦点图 | ||
25 | + $focusData = NewsaleData::getNewsaleFocus('a7989369aa86681c678bc40f171b8f1d'); | ||
26 | + // 处理返回的数据 | ||
27 | + $focus = array(); | ||
28 | + if (isset($focusData['code']) && $focusData['code'] == 200) { | ||
29 | + $focus = $focusData['data']; | ||
30 | + } | ||
31 | + | ||
32 | + // 批量获取新品到着商品数据 | ||
33 | + $products = NewsaleData::getNewProducts('1,3', 1, 60); | ||
34 | + // 添加商品数据 | ||
35 | + $data += NewSaleProcess::newSaleData($focus, $products); | ||
36 | + | ||
37 | + $this->_view->display('new', $data); | ||
38 | + } | ||
39 | + | ||
40 | + /** | ||
41 | + * Ajax方式筛选新品到着、折扣专区商品 | ||
42 | + * | ||
43 | + * @return array 根据指定条件筛选之后的商品 | ||
44 | + */ | ||
45 | + public function selectNewSaleAction() | ||
46 | + { | ||
47 | + if ($this->isAjax()) { | ||
48 | + $gender = $this->get('gender', '1,3'); | ||
49 | + $brand = $this->get('brand', null); | ||
50 | + $sort = $this->get('sort', null); | ||
51 | + $color = $this->get('color', null); | ||
52 | + $size = $this->get('size', null); | ||
53 | + $price = $this->get('price', null); | ||
54 | + $p_d = $this->get('p_d', null); | ||
55 | + $channel = $this->get('channel', '1'); | ||
56 | + $dayLimit = $this->get('dayLimit', '1'); | ||
57 | + $limit = $this->get('limit', 50); | ||
58 | + $page = $this->get('page', 1); | ||
59 | + | ||
60 | + $data = NewsaleData::selectNewSaleProducts($gender, $brand, $sort, $color, $size, $price, $p_d, $channel, $dayLimit, $limit, $page); | ||
61 | + | ||
62 | + $result = NewSaleProcess::selectData($data); | ||
63 | + | ||
64 | + $this->_view->display('product', $result); | ||
65 | + } | ||
66 | + } | ||
67 | + | ||
68 | + /** | ||
69 | + * 折扣专区 | ||
70 | + */ | ||
71 | + public function discountAction() | ||
72 | + { | ||
73 | + $this->setTitle('折扣专区'); | ||
74 | + | ||
75 | + $data = array( | ||
76 | + 'discount' => true, | ||
77 | + 'header' => array( | ||
78 | + 'title' => 'SALE' | ||
79 | + ) | ||
80 | + ); | ||
81 | + | ||
82 | + // 折扣专区顶部焦点图 | ||
83 | + $focusData = NewsaleData::getNewsaleFocus('e9c9be32d72e2906d404a72ee24cb523'); | ||
84 | + // 处理返回的数据 | ||
85 | + $focus = array(); | ||
86 | + if (isset($focusData['code']) && $focusData['code'] == 200) { | ||
87 | + $focus = $focusData['data']; | ||
88 | + } | ||
89 | + | ||
90 | + // 折扣专区商品数据 | ||
91 | + $products = NewsaleData::getSaleProducts('1,3', 1); | ||
92 | + // 更新tabs | ||
93 | + $tabs = array(); | ||
94 | + foreach (array_keys($products) as $key => $value) { | ||
95 | + $tabItem = array(); | ||
96 | + $tabItem['title'] = $value; | ||
97 | + if ($key === 0) { | ||
98 | + $tabItem['focus'] = true; | ||
99 | + } | ||
100 | + $tabs[] = $tabItem; | ||
101 | + } | ||
102 | + $data['tabs'] = $tabs; | ||
103 | + // 添加商品数据 | ||
104 | + $data += NewSaleProcess::newSaleData($focus, $products); | ||
105 | + | ||
106 | + /* echo '<pre>'; | ||
107 | + print_r($data);exit; */ | ||
108 | + | ||
109 | + $this->_view->display('sale', $data); | ||
110 | + } | ||
111 | + | ||
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 | - * 你可能喜欢的 | 14 | + * 你可能喜欢的BOYS或GIRLS的商品列表 |
20 | * | 15 | * |
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); | ||
25 | - * | ||
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'); | ||
36 | - | ||
37 | - switch (strval($channel)) { | ||
38 | - case '1': // 男(Boys) | ||
39 | - case '2': // 女(Girls) | ||
40 | - $data = RecomData::mayLike($gender, $channel); | ||
41 | - break; | ||
42 | - case '3': // 潮童(Kids) | ||
43 | - $data = RecomData::mayLikeKids(); | ||
44 | - break; | ||
45 | - case '4': // 创意生活(LifeStyle) | ||
46 | - $data = RecomData::mayLikeLifestyle(); | ||
47 | - break; | ||
48 | - } | ||
49 | - | ||
50 | - $this->echoJson($data); | 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 | + } | ||
45 | + | ||
46 | + /* 判断是否有内容返回 */ | ||
47 | + if (empty($recom['data']['product_list'])) { | ||
48 | + break; | ||
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()) { | ||
74 | + break; | ||
75 | + } | ||
76 | + | ||
77 | + /* 判断分页参数是否有效 */ | ||
78 | + $page = $this->get('page', 1); | ||
79 | + if (!is_numeric($page)) { | ||
80 | + break; | ||
81 | + } | ||
82 | + | ||
83 | + /* 取可能喜欢的数据 */ | ||
84 | + $recom = RecomData::mayLikeKids(); | ||
85 | + if (empty($recom['data']['product_list'])) { | ||
86 | + break; | ||
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); | ||
51 | } | 95 | } |
96 | + while (false); | ||
97 | + | ||
98 | + echo ' '; | ||
52 | } | 99 | } |
53 | 100 | ||
101 | + /** | ||
102 | + * 你可能喜欢的创意生活的新品到着和人气单品列表 | ||
103 | + * | ||
104 | + * @return html | ||
105 | + */ | ||
106 | + public function maylikeLifeAction() | ||
107 | + { | ||
108 | + do { | ||
109 | + /* 判断是否是AJAX请求 */ | ||
110 | + if (!$this->isAjax()) { | ||
111 | + break; | ||
112 | + } | ||
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