Authored by yangyang

save

@@ -113,14 +113,20 @@ class StarClassData @@ -113,14 +113,20 @@ class StarClassData
113 /** 113 /**
114 * 收藏资讯文章 114 * 收藏资讯文章
115 */ 115 */
116 - public static function setFavorite($articleId, $uid) 116 + public static function setFavorite($articleId, $uid, $type)
117 { 117 {
  118 + if (!empty($type) && $type == 'fav') {
  119 + $url = '/guang/api/v5/favorite/setFavorite';
  120 + }elseif($type == 'del'){
  121 + $url = '/guang/api/v5/favorite/cancelFavorite';
  122 + }
  123 +
118 $param = Yohobuy::param(); 124 $param = Yohobuy::param();
119 $param['articleId'] = $articleId; 125 $param['articleId'] = $articleId;
120 $param['uid'] = $uid; 126 $param['uid'] = $uid;
121 $param['client_secret'] = Sign::getSign($param); 127 $param['client_secret'] = Sign::getSign($param);
122 128
123 - return Yohobuy::get(Yohobuy::DEV_SERVICE_URL . '/guang/api/v5/favorite/setFavorite', $param); 129 + return Yohobuy::get(Yohobuy::DEV_SERVICE_URL . $url, $param);
124 } 130 }
125 131
126 132
@@ -25,7 +25,6 @@ class StarClassModel @@ -25,7 +25,6 @@ class StarClassModel
25 public static function getStarClass($uid) 25 public static function getStarClass($uid)
26 { 26 {
27 $result = array(); 27 $result = array();
28 - $result['title'] = '星潮教室';  
29 $result['headTab'] = self::getHeadTab('index'); 28 $result['headTab'] = self::getHeadTab('index');
30 29
31 //组装资源位获取星潮教室首页数据URL 30 //组装资源位获取星潮教室首页数据URL
@@ -33,14 +32,11 @@ class StarClassModel @@ -33,14 +32,11 @@ class StarClassModel
33 $res['starClassIndex'] = StarClassData::getResourceDataUrl($contentCode); 32 $res['starClassIndex'] = StarClassData::getResourceDataUrl($contentCode);
34 33
35 //组装获得每日签到数据接口URL 34 //组装获得每日签到数据接口URL
36 -// echo $uid;  
37 $res['rankInfo'] = StarClassData::rankInfoDataUrl($uid); 35 $res['rankInfo'] = StarClassData::rankInfoDataUrl($uid);
38 -//print_r($res['rankInfo']);exit; 36 +
39 //批量调接口 37 //批量调接口
40 $data = Yohobuy::getMulti($res); 38 $data = Yohobuy::getMulti($res);
41 39
42 -// print_r($data['starClassIndex']);  
43 -// print_r($data);exit;  
44 40
45 //调用成功封装数据 41 //调用成功封装数据
46 if (isset($data['starClassIndex']) && !empty($data['starClassIndex'])) { 42 if (isset($data['starClassIndex']) && !empty($data['starClassIndex'])) {
@@ -90,12 +86,12 @@ class StarClassModel @@ -90,12 +86,12 @@ class StarClassModel
90 public static function getspecial() 86 public static function getspecial()
91 { 87 {
92 $result = array(); 88 $result = array();
93 - $result['title'] = '星潮教室';  
94 $result['headTab'] = self::getHeadTab('special'); 89 $result['headTab'] = self::getHeadTab('special');
95 90
96 //组装资源位获取星潮教室首页数据URL 91 //组装资源位获取星潮教室首页数据URL
97 $contentCode = '89cc20483ee2cbc8a716dcfe2b6c7603'; 92 $contentCode = '89cc20483ee2cbc8a716dcfe2b6c7603';
98 $data = StarClassData::getResourceData($contentCode); 93 $data = StarClassData::getResourceData($contentCode);
  94 +
99 if (isset($data['code']) && $data['code'] == 200) { 95 if (isset($data['code']) && $data['code'] == 200) {
100 $build = array(); 96 $build = array();
101 foreach ($data['data'] as $value) { 97 foreach ($data['data'] as $value) {
@@ -114,7 +110,7 @@ class StarClassModel @@ -114,7 +110,7 @@ class StarClassModel
114 } 110 }
115 $build = array(); 111 $build = array();
116 } 112 }
117 - 113 +//print_r($result);
118 return $result; 114 return $result;
119 } 115 }
120 116
@@ -125,7 +121,6 @@ class StarClassModel @@ -125,7 +121,6 @@ class StarClassModel
125 public static function getCollocation() 121 public static function getCollocation()
126 { 122 {
127 $result = array(); 123 $result = array();
128 - $result['title'] = '星潮教室';  
129 $result['headTab'] = self::getHeadTab('collocation'); 124 $result['headTab'] = self::getHeadTab('collocation');
130 125
131 return $result; 126 return $result;
@@ -137,7 +132,7 @@ class StarClassModel @@ -137,7 +132,7 @@ class StarClassModel
137 public static function ajaxCollocation($page) 132 public static function ajaxCollocation($page)
138 { 133 {
139 $data = StarClassData::collocationData($page); 134 $data = StarClassData::collocationData($page);
140 -//print_r($data); 135 +
141 $result = array(); 136 $result = array();
142 $collocationList = array(); 137 $collocationList = array();
143 if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) { 138 if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) {
@@ -149,9 +144,9 @@ class StarClassModel @@ -149,9 +144,9 @@ class StarClassModel
149 $collocationList[$key]['time'] = $value['publish_time']; 144 $collocationList[$key]['time'] = $value['publish_time'];
150 $collocationList[$key]['seeNum'] = $value['views_num']; 145 $collocationList[$key]['seeNum'] = $value['views_num'];
151 $collocationList[$key]['zanNum'] = $value['praise_num']; 146 $collocationList[$key]['zanNum'] = $value['praise_num'];
152 - $collocationList[$key]['isLiked '] = $value['isPraise'];  
153 - $collocationList[$key]['articleId '] = $value['id'];  
154 - $collocationList[$key]['isCollected'] = $value['isFavor']; 147 + $collocationList[$key]['articleId'] = $value['id'];
  148 + $collocationList[$key]['isLiked'] = $value['isPraise'] == 'Y' ? true : false;
  149 + $collocationList[$key]['isCollected'] = $value['isFavor'] == 'Y' ? true : false;
155 } 150 }
156 $result['collocationList'] = $collocationList; 151 $result['collocationList'] = $collocationList;
157 } 152 }
@@ -163,7 +158,7 @@ class StarClassModel @@ -163,7 +158,7 @@ class StarClassModel
163 public static function sign($uid) 158 public static function sign($uid)
164 { 159 {
165 $data = StarClassData::sign($uid); 160 $data = StarClassData::sign($uid);
166 -//print_r($data);exit; 161 +
167 $result = array(); 162 $result = array();
168 if (isset($data['code']) && $data['code'] == 200) { 163 if (isset($data['code']) && $data['code'] == 200) {
169 foreach ($data['data']['logs'] as $key => $value) { 164 foreach ($data['data']['logs'] as $key => $value) {
@@ -186,6 +181,7 @@ class StarClassModel @@ -186,6 +181,7 @@ class StarClassModel
186 } 181 }
187 182
188 183
  184 +
189 /** 185 /**
190 * 获取headTab 186 * 获取headTab
191 */ 187 */
@@ -267,7 +263,7 @@ class StarClassModel @@ -267,7 +263,7 @@ class StarClassModel
267 $result = array(); 263 $result = array();
268 264
269 $result['title']['title'] = $data['title']; 265 $result['title']['title'] = $data['title'];
270 - $result['title']['moreUrl'] = $data['more_url']; 266 + $result['title']['more_url'] = $data['more_url'];
271 $result['title']['moreName'] = $data['more_name']; 267 $result['title']['moreName'] = $data['more_name'];
272 $result['subjectBanner']['url'] = $data['image']['url']; 268 $result['subjectBanner']['url'] = $data['image']['url'];
273 $result['subjectBanner']['img'] = Helpers::getOriginalImg($data['image']['src']); 269 $result['subjectBanner']['img'] = Helpers::getOriginalImg($data['image']['src']);
@@ -283,6 +279,8 @@ class StarClassModel @@ -283,6 +279,8 @@ class StarClassModel
283 279
284 $result['videoImg'] = Helpers::getOriginalImg($data[0]['src']); 280 $result['videoImg'] = Helpers::getOriginalImg($data[0]['src']);
285 $result['videoUrl'] = $data[0]['url']; 281 $result['videoUrl'] = $data[0]['url'];
  282 + $result['alt'] = $data[0]['alt'];
  283 + $result['title'] = $data[0]['title'];
286 $result['video'] = true; 284 $result['video'] = true;
287 return $result; 285 return $result;
288 } 286 }
@@ -294,7 +292,7 @@ class StarClassModel @@ -294,7 +292,7 @@ class StarClassModel
294 292
295 //title 293 //title
296 $result['title']['title'] = $data['title']['name']; 294 $result['title']['title'] = $data['title']['name'];
297 - $result['title']['moreUrl'] = $data['title']['more_url']; 295 + $result['title']['more_url'] = $data['title']['more_url'];
298 $result['title']['moreName'] = $data['title']['more_name']; 296 $result['title']['moreName'] = $data['title']['more_name'];
299 297
300 //两张大图 298 //两张大图
@@ -313,9 +311,6 @@ class StarClassModel @@ -313,9 +311,6 @@ class StarClassModel
313 311
314 return $result; 312 return $result;
315 } 313 }
316 -  
317 -  
318 -  
319 - 314 +
320 315
321 } 316 }
@@ -13,11 +13,11 @@ class StarClassController extends AbstractAction @@ -13,11 +13,11 @@ class StarClassController extends AbstractAction
13 */ 13 */
14 public function indexAction() 14 public function indexAction()
15 { 15 {
16 - //判断登录 16 + $this->setNavHeader('星潮教室', true, false);
  17 + //获取uid
17 $uid = $this->getUid(); 18 $uid = $this->getUid();
18 -  
19 $data = StarClassModel::getStarClass($uid); 19 $data = StarClassModel::getStarClass($uid);
20 -//print_r($data); 20 +
21 $this->_view->display('index', array( 21 $this->_view->display('index', array(
22 'trendClassHome' => $data, 22 'trendClassHome' => $data,
23 'trendClassHomePage' => true 23 'trendClassHomePage' => true
@@ -29,8 +29,10 @@ class StarClassController extends AbstractAction @@ -29,8 +29,10 @@ class StarClassController extends AbstractAction
29 //星潮教室-星专题 29 //星潮教室-星专题
30 public function specialAction() 30 public function specialAction()
31 { 31 {
  32 + $this->setNavHeader('星潮教室', true, false);
  33 +
32 $data = StarClassModel::getspecial(); 34 $data = StarClassModel::getspecial();
33 -//print_r($data); 35 +
34 $this->_view->display('subject', array( 36 $this->_view->display('subject', array(
35 'trendClassSubject' => $data 37 'trendClassSubject' => $data
36 )); 38 ));
@@ -40,6 +42,8 @@ class StarClassController extends AbstractAction @@ -40,6 +42,8 @@ class StarClassController extends AbstractAction
40 //星潮教室-星搭配 42 //星潮教室-星搭配
41 public function collocationAction() 43 public function collocationAction()
42 { 44 {
  45 + $this->setNavHeader('星潮教室', true, false);
  46 +
43 $data = StarClassModel::getCollocation(); 47 $data = StarClassModel::getCollocation();
44 48
45 $this->_view->display('collocation', array( 49 $this->_view->display('collocation', array(
@@ -51,9 +55,9 @@ class StarClassController extends AbstractAction @@ -51,9 +55,9 @@ class StarClassController extends AbstractAction
51 //星潮教室-星搭配文章请求 55 //星潮教室-星搭配文章请求
52 public function ajaxCollocationAction() 56 public function ajaxCollocationAction()
53 { 57 {
54 -// if (!$this->isAjax()) {  
55 -// return;  
56 -// } 58 + if (!$this->isAjax()) {
  59 + return;
  60 + }
57 $page = $this->get('page',1); 61 $page = $this->get('page',1);
58 $data = StarClassModel::ajaxCollocation($page); 62 $data = StarClassModel::ajaxCollocation($page);
59 63
@@ -67,11 +71,11 @@ class StarClassController extends AbstractAction @@ -67,11 +71,11 @@ class StarClassController extends AbstractAction
67 //签到 71 //签到
68 public function signAction() 72 public function signAction()
69 { 73 {
70 -// if(!$this->isAjax()){  
71 -// return;  
72 -// } 74 + if(!$this->isAjax()){
  75 + return;
  76 + }
73 $uid = $this->getUid(); 77 $uid = $this->getUid();
74 -//echo $uid; 78 +
75 if ($uid) { 79 if ($uid) {
76 $res = StarClassModel::sign($uid); 80 $res = StarClassModel::sign($uid);
77 $this->echoJson($res); 81 $this->echoJson($res);
@@ -85,9 +89,9 @@ class StarClassController extends AbstractAction @@ -85,9 +89,9 @@ class StarClassController extends AbstractAction
85 //点赞 89 //点赞
86 public function setPraiseAction() 90 public function setPraiseAction()
87 { 91 {
88 -// if(!$this->isAjax()){  
89 -// return;  
90 -// } 92 + if(!$this->isAjax()){
  93 + return;
  94 + }
91 $udid = $this->getUdid(); 95 $udid = $this->getUdid();
92 $articleId = $this->post('articleId'); 96 $articleId = $this->post('articleId');
93 97
@@ -99,15 +103,16 @@ class StarClassController extends AbstractAction @@ -99,15 +103,16 @@ class StarClassController extends AbstractAction
99 //转发 103 //转发
100 public function forwardAction() 104 public function forwardAction()
101 { 105 {
102 -// if(!$this->isAjax()){  
103 -// return;  
104 -// } 106 + if(!$this->isAjax()){
  107 + return;
  108 + }
105 //未登录跳转登录页 109 //未登录跳转登录页
106 $this->auditJumpLogin(); 110 $this->auditJumpLogin();
107 $uid = $this->getUid(); 111 $uid = $this->getUid();
108 112
109 } 113 }
110 114
  115 + //收藏资讯文章
111 public function setFavoriteAction() 116 public function setFavoriteAction()
112 { 117 {
113 if (!$this->isAjax()) { 118 if (!$this->isAjax()) {
@@ -115,13 +120,14 @@ class StarClassController extends AbstractAction @@ -115,13 +120,14 @@ class StarClassController extends AbstractAction
115 } 120 }
116 $uid = $this->getUid(); 121 $uid = $this->getUid();
117 $articleId = $this->post('articleId','3'); 122 $articleId = $this->post('articleId','3');
  123 + $type = $this->post('type');
118 124
119 - if (!$uid || !isset($articleId)) { 125 + if (!$uid || !isset($articleId) || !isset($type)) {
120 $this->echoJson(array('code'=>400,'message'=>'参数错误!')); 126 $this->echoJson(array('code'=>400,'message'=>'参数错误!'));
121 } 127 }
122 128
123 $result = array(); 129 $result = array();
124 - $result = StarClassData::setFavorite($articleId, $uid); 130 + $result = StarClassData::setFavorite($articleId, $uid, $type);
125 if (!empty($result)) { 131 if (!empty($result)) {
126 $this->echoJson($result); 132 $this->echoJson($result);
127 } 133 }