Showing
5 changed files
with
163 additions
and
18 deletions
library/LibModels/Wap/Home/GuangData.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace LibModels\Wap\Home; | ||
4 | + | ||
5 | +use Api\Sign; | ||
6 | +use Api\Yohobuy; | ||
7 | + | ||
8 | +/** | ||
9 | + * 我的逛数据模型 | ||
10 | + * | ||
11 | + * @name GuangData | ||
12 | + * @package LibModels/Wap/Home | ||
13 | + * @copyright yoho.inc | ||
14 | + * @version 1.0 (2015-11-13) | ||
15 | + * @author xiaowei | ||
16 | + */ | ||
17 | +class GuangData | ||
18 | +{ | ||
19 | + | ||
20 | + const GUANG_URI = 'guang/api/v1/favorite/'; | ||
21 | + | ||
22 | + //我的guang | ||
23 | + public static function getGuangInfo($uid, $page, $yh_channel = 1, $gender = '1,3', $limit = 10) | ||
24 | + { | ||
25 | + $param = Yohobuy::param(); | ||
26 | + $param['uid'] = $uid; | ||
27 | + $param['page'] = $page; | ||
28 | + $param['gender'] = $gender; | ||
29 | + $param['limit'] = $limit; | ||
30 | + $param['yh_channel'] = $yh_channel; | ||
31 | + $param['client_secret'] = Sign::getSign($param); | ||
32 | +// return Yohobuy::post(Yohobuy::API_URL, $param); | ||
33 | + return Yohobuy::post(Yohobuy::SERVICE_URL . self::GUANG_URI . 'getUserFavArticleList', $param); | ||
34 | + } | ||
35 | + | ||
36 | +} |
@@ -2,7 +2,6 @@ | @@ -2,7 +2,6 @@ | ||
2 | 2 | ||
3 | namespace LibModels\Wap\Home; | 3 | namespace LibModels\Wap\Home; |
4 | 4 | ||
5 | -use Api\Sign; | ||
6 | use Api\Yohobuy; | 5 | use Api\Yohobuy; |
7 | 6 | ||
8 | /** | 7 | /** |
@@ -18,16 +17,23 @@ class OnlineData | @@ -18,16 +17,23 @@ class OnlineData | ||
18 | { | 17 | { |
19 | const ONLINE_URI = 'operations/api/v1/help/'; | 18 | const ONLINE_URI = 'operations/api/v1/help/'; |
20 | 19 | ||
21 | - //获取帮助列表(分类) | 20 | + /* |
21 | + * 获取帮助列表(分类),缓存1h | ||
22 | + * clientType客户端 | ||
23 | + */ | ||
22 | public static function getOnlineServiceInfo($clientType='iphone') | 24 | public static function getOnlineServiceInfo($clientType='iphone') |
23 | { | 25 | { |
24 | - return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType)); | 26 | + return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getCategory', array('client_type'=>$clientType),3600); |
25 | } | 27 | } |
26 | 28 | ||
27 | - //获取问题详情 | 29 | + /* |
30 | + * 获取问题详情,缓存1h | ||
31 | + * cateId问题分类ID | ||
32 | + * clientType客户端 | ||
33 | + */ | ||
28 | public static function getOnlineServiceDetail($cateId, $clientType = 'iphone') | 34 | public static function getOnlineServiceDetail($cateId, $clientType = 'iphone') |
29 | { | 35 | { |
30 | - return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType)); | 36 | + return Yohobuy::get(Yohobuy::SERVICE_URL .self::ONLINE_URI.'getHelp', array('category_id'=>$cateId,'client_type'=>$clientType),3600); |
31 | } | 37 | } |
32 | 38 | ||
33 | } | 39 | } |
@@ -314,7 +314,14 @@ class HomeController extends AbstractAction | @@ -314,7 +314,14 @@ class HomeController extends AbstractAction | ||
314 | */ | 314 | */ |
315 | public function myGuangAction() | 315 | public function myGuangAction() |
316 | { | 316 | { |
317 | - echo 'My Guang'; | 317 | + $page = $this->get('page', 1); |
318 | + $limit = $this->get('limit', 10); | ||
319 | + $uid = $this->getUid(); | ||
320 | + $yh_channel = Helpers::getChannelByCookie(); | ||
321 | + $uid=5687179; | ||
322 | + $gender = Helpers::getGenderByCookie(); | ||
323 | + $guangInfo = \home\GuangModel::getMyGuang($uid, $page,$yh_channel,$gender, $limit); | ||
324 | + $this->_view->display('my-guang', array('myGuang'=>$guangInfo)); | ||
318 | } | 325 | } |
319 | 326 | ||
320 | /** | 327 | /** |
1 | +<?php | ||
2 | + | ||
3 | +namespace Home; | ||
4 | + | ||
5 | +use LibModels\Wap\Home\GuangData; | ||
6 | +use Action\AbstractAction; | ||
7 | +use Plugin\Helpers; | ||
8 | + | ||
9 | +/** | ||
10 | + * 我的逛数据处理 | ||
11 | + */ | ||
12 | +class GuangModel | ||
13 | +{ | ||
14 | + | ||
15 | + //获取我的逛列表 | ||
16 | + public static function getMyGuang($uid, $page,$yh_channel=1, $gender = '1,3', $limit = 10) | ||
17 | + { | ||
18 | + $result = array(); | ||
19 | + //调用接口获取数据 | ||
20 | + $res = GuangData::getGuangInfo($uid, $page, $yh_channel,$gender, $limit); | ||
21 | + $guangInfo = $res['data']['data']; | ||
22 | + if ($guangInfo) | ||
23 | + { | ||
24 | + foreach ($guangInfo as $k => $v) | ||
25 | + { | ||
26 | + $result[$k]['id'] = $v['id']; | ||
27 | + $result[$k]['author'] = $v['author']; | ||
28 | + $tag = self::getTag(TRUE, intval($v['category_id'])); | ||
29 | + $result[$k]['url'] = $v['url']; | ||
30 | + $result[$k]['img'] = $v['src']; | ||
31 | + $result[$k]['title'] = $v['title']; | ||
32 | + $result[$k]['text'] = $v['intro']; | ||
33 | + $result[$k]['pageView'] = $v['views_num']; | ||
34 | + $result[$k]['publish_time'] = $v['publish_time']; | ||
35 | + $like = ($v['isPraise'] == "Y") ? true : false; | ||
36 | + $collect = ($v['isFavor'] == "Y") ? true : false; | ||
37 | + $result[$k]['like'] = array('isLiked' => $like, 'count' => $v['praise_num']); | ||
38 | + $result[$k]['collect'] = array('isCollected' => $collect, 'url' => $v['url']); | ||
39 | + $result[$k] += $tag; | ||
40 | + $result[$k]['share'] = $v['url']; | ||
41 | + } | ||
42 | + } | ||
43 | + | ||
44 | + return $result; | ||
45 | + } | ||
46 | + | ||
47 | + //【标签】isTip-小贴士;isCollocation-搭配 isFashionMan-潮人 isFashionGood-潮品 isTopic-话题 | ||
48 | + private static function getTag($isShow, $tagId) | ||
49 | + { | ||
50 | + $ret['showTags'] = $isShow; | ||
51 | + $ret['isTopic'] = false; | ||
52 | + $ret['isCollocation'] = false; | ||
53 | + $ret['isFashionMan'] = false; | ||
54 | + $ret['isFashionGood'] = false; | ||
55 | + $ret['isTip'] = false; | ||
56 | + switch ($tagId) | ||
57 | + { | ||
58 | + case 1: | ||
59 | + $ret['isTopic'] = true; | ||
60 | + break; | ||
61 | + case 2: | ||
62 | + $ret['isCollocation'] = true; | ||
63 | + break; | ||
64 | + case 3: | ||
65 | + $ret['isFashionMan'] = true; | ||
66 | + break; | ||
67 | + case 4: | ||
68 | + $ret['isFashionGood'] = true; | ||
69 | + break; | ||
70 | + case 5: | ||
71 | + $ret['isTip'] = true; | ||
72 | + break; | ||
73 | + default: | ||
74 | + $ret['showTags'] = FALSE; | ||
75 | + break; | ||
76 | + } | ||
77 | + return $ret; | ||
78 | + } | ||
79 | + | ||
80 | +} |
@@ -11,7 +11,10 @@ use Plugin\Helpers; | @@ -11,7 +11,10 @@ use Plugin\Helpers; | ||
11 | class OnlineModel | 11 | class OnlineModel |
12 | { | 12 | { |
13 | 13 | ||
14 | - //获取在线帮助分类 | 14 | + /* |
15 | + * 获取在线帮助分类 | ||
16 | + * $clientType客户端类型 | ||
17 | + */ | ||
15 | public static function getOnlineServiceInfo($clientType = 'iphone') | 18 | public static function getOnlineServiceInfo($clientType = 'iphone') |
16 | { | 19 | { |
17 | //调用接口获取数据 | 20 | //调用接口获取数据 |
@@ -19,10 +22,13 @@ class OnlineModel | @@ -19,10 +22,13 @@ class OnlineModel | ||
19 | $cateInfo = $res['data']; | 22 | $cateInfo = $res['data']; |
20 | $question = array(); | 23 | $question = array(); |
21 | $tab = array(); | 24 | $tab = array(); |
22 | - if ($cateInfo) { | ||
23 | - foreach ($cateInfo as $key => $value) { | 25 | + if ($cateInfo) |
26 | + { | ||
27 | + foreach ($cateInfo as $key => $value) | ||
28 | + { | ||
24 | //强制截成3个tab | 29 | //强制截成3个tab |
25 | - if ($key > 2) { | 30 | + if ($key > 2) |
31 | + { | ||
26 | break; | 32 | break; |
27 | } | 33 | } |
28 | $tab[$key]['tabid'] = 'tab' . $value['id']; | 34 | $tab[$key]['tabid'] = 'tab' . $value['id']; |
@@ -33,10 +39,12 @@ class OnlineModel | @@ -33,10 +39,12 @@ class OnlineModel | ||
33 | $question[$key]['current'] = (!$key) ? TRUE : FALSE; | 39 | $question[$key]['current'] = (!$key) ? TRUE : FALSE; |
34 | $sub = $value['sub']; | 40 | $sub = $value['sub']; |
35 | $qTmp = array(); | 41 | $qTmp = array(); |
36 | - if ($sub) { | ||
37 | - foreach ($sub as $sk => $sv) { | 42 | + if ($sub) |
43 | + { | ||
44 | + foreach ($sub as $sk => $sv) | ||
45 | + { | ||
38 | $qTmp[$sk]['title'] = $sv['category_name']; | 46 | $qTmp[$sk]['title'] = $sv['category_name']; |
39 | - $qTmp[$sk]['link'] = '/home/onlineservicedetail?cateId=' . $sv['id'] . '&cateName=' . $sv['category_name']; | 47 | + $qTmp[$sk]['link'] = Helpers::url('/home/onlineservicedetail',array('cateId'=>$sv['id'],'cateName'=>$sv['category_name'])); |
40 | } | 48 | } |
41 | } | 49 | } |
42 | $question[$key]['list'] = $qTmp; | 50 | $question[$key]['list'] = $qTmp; |
@@ -54,19 +62,27 @@ class OnlineModel | @@ -54,19 +62,27 @@ class OnlineModel | ||
54 | return $result; | 62 | return $result; |
55 | } | 63 | } |
56 | 64 | ||
57 | - //加载分类下的问题和解决方法 | 65 | + /* |
66 | + * 加载分类下的问题和解决方法 | ||
67 | + * cateId问题分类ID | ||
68 | + * clientType客户端 | ||
69 | + */ | ||
58 | public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone') | 70 | public static function getOnlineServiceDetail($cateId, $clinetType = 'iphone') |
59 | { | 71 | { |
60 | $result = array(); | 72 | $result = array(); |
61 | - if (!$cateId) { | 73 | + if (!$cateId) |
74 | + { | ||
62 | return $result; | 75 | return $result; |
63 | } | 76 | } |
64 | $res = OnlineData::getOnlineServiceDetail($cateId, $clinetType); | 77 | $res = OnlineData::getOnlineServiceDetail($cateId, $clinetType); |
65 | $questionInfo = $res['data']; | 78 | $questionInfo = $res['data']; |
66 | - if ($questionInfo) { | 79 | + if ($questionInfo) |
80 | + { | ||
67 | $list = array(); | 81 | $list = array(); |
68 | - if ($questionInfo) { | ||
69 | - foreach ($questionInfo as $qk => $qv) { | 82 | + if ($questionInfo) |
83 | + { | ||
84 | + foreach ($questionInfo as $qk => $qv) | ||
85 | + { | ||
70 | $list[$qk]['q'] = $qv['title']; | 86 | $list[$qk]['q'] = $qv['title']; |
71 | $list[$qk]['a'] = $qv['content']; | 87 | $list[$qk]['a'] = $qv['content']; |
72 | } | 88 | } |
-
Please register or login to post a comment