Authored by yangyang

save

... ... @@ -113,14 +113,20 @@ class StarClassData
/**
* 收藏资讯文章
*/
public static function setFavorite($articleId, $uid)
public static function setFavorite($articleId, $uid, $type)
{
if (!empty($type) && $type == 'fav') {
$url = '/guang/api/v5/favorite/setFavorite';
}elseif($type == 'del'){
$url = '/guang/api/v5/favorite/cancelFavorite';
}
$param = Yohobuy::param();
$param['articleId'] = $articleId;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::DEV_SERVICE_URL . '/guang/api/v5/favorite/setFavorite', $param);
return Yohobuy::get(Yohobuy::DEV_SERVICE_URL . $url, $param);
}
... ...
... ... @@ -25,7 +25,6 @@ class StarClassModel
public static function getStarClass($uid)
{
$result = array();
$result['title'] = '星潮教室';
$result['headTab'] = self::getHeadTab('index');
//组装资源位获取星潮教室首页数据URL
... ... @@ -33,14 +32,11 @@ class StarClassModel
$res['starClassIndex'] = StarClassData::getResourceDataUrl($contentCode);
//组装获得每日签到数据接口URL
// echo $uid;
$res['rankInfo'] = StarClassData::rankInfoDataUrl($uid);
//print_r($res['rankInfo']);exit;
//批量调接口
$data = Yohobuy::getMulti($res);
// print_r($data['starClassIndex']);
// print_r($data);exit;
//调用成功封装数据
if (isset($data['starClassIndex']) && !empty($data['starClassIndex'])) {
... ... @@ -90,12 +86,12 @@ class StarClassModel
public static function getspecial()
{
$result = array();
$result['title'] = '星潮教室';
$result['headTab'] = self::getHeadTab('special');
//组装资源位获取星潮教室首页数据URL
$contentCode = '89cc20483ee2cbc8a716dcfe2b6c7603';
$data = StarClassData::getResourceData($contentCode);
if (isset($data['code']) && $data['code'] == 200) {
$build = array();
foreach ($data['data'] as $value) {
... ... @@ -114,7 +110,7 @@ class StarClassModel
}
$build = array();
}
//print_r($result);
return $result;
}
... ... @@ -125,7 +121,6 @@ class StarClassModel
public static function getCollocation()
{
$result = array();
$result['title'] = '星潮教室';
$result['headTab'] = self::getHeadTab('collocation');
return $result;
... ... @@ -137,7 +132,7 @@ class StarClassModel
public static function ajaxCollocation($page)
{
$data = StarClassData::collocationData($page);
//print_r($data);
$result = array();
$collocationList = array();
if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) {
... ... @@ -149,9 +144,9 @@ class StarClassModel
$collocationList[$key]['time'] = $value['publish_time'];
$collocationList[$key]['seeNum'] = $value['views_num'];
$collocationList[$key]['zanNum'] = $value['praise_num'];
$collocationList[$key]['isLiked '] = $value['isPraise'];
$collocationList[$key]['articleId '] = $value['id'];
$collocationList[$key]['isCollected'] = $value['isFavor'];
$collocationList[$key]['articleId'] = $value['id'];
$collocationList[$key]['isLiked'] = $value['isPraise'] == 'Y' ? true : false;
$collocationList[$key]['isCollected'] = $value['isFavor'] == 'Y' ? true : false;
}
$result['collocationList'] = $collocationList;
}
... ... @@ -163,7 +158,7 @@ class StarClassModel
public static function sign($uid)
{
$data = StarClassData::sign($uid);
//print_r($data);exit;
$result = array();
if (isset($data['code']) && $data['code'] == 200) {
foreach ($data['data']['logs'] as $key => $value) {
... ... @@ -186,6 +181,7 @@ class StarClassModel
}
/**
* 获取headTab
*/
... ... @@ -267,7 +263,7 @@ class StarClassModel
$result = array();
$result['title']['title'] = $data['title'];
$result['title']['moreUrl'] = $data['more_url'];
$result['title']['more_url'] = $data['more_url'];
$result['title']['moreName'] = $data['more_name'];
$result['subjectBanner']['url'] = $data['image']['url'];
$result['subjectBanner']['img'] = Helpers::getOriginalImg($data['image']['src']);
... ... @@ -283,6 +279,8 @@ class StarClassModel
$result['videoImg'] = Helpers::getOriginalImg($data[0]['src']);
$result['videoUrl'] = $data[0]['url'];
$result['alt'] = $data[0]['alt'];
$result['title'] = $data[0]['title'];
$result['video'] = true;
return $result;
}
... ... @@ -294,7 +292,7 @@ class StarClassModel
//title
$result['title']['title'] = $data['title']['name'];
$result['title']['moreUrl'] = $data['title']['more_url'];
$result['title']['more_url'] = $data['title']['more_url'];
$result['title']['moreName'] = $data['title']['more_name'];
//两张大图
... ... @@ -315,7 +313,4 @@ class StarClassModel
}
}
\ No newline at end of file
... ...
... ... @@ -13,11 +13,11 @@ class StarClassController extends AbstractAction
*/
public function indexAction()
{
//判断登录
$this->setNavHeader('星潮教室', true, false);
//获取uid
$uid = $this->getUid();
$data = StarClassModel::getStarClass($uid);
//print_r($data);
$this->_view->display('index', array(
'trendClassHome' => $data,
'trendClassHomePage' => true
... ... @@ -29,8 +29,10 @@ class StarClassController extends AbstractAction
//星潮教室-星专题
public function specialAction()
{
$this->setNavHeader('星潮教室', true, false);
$data = StarClassModel::getspecial();
//print_r($data);
$this->_view->display('subject', array(
'trendClassSubject' => $data
));
... ... @@ -40,6 +42,8 @@ class StarClassController extends AbstractAction
//星潮教室-星搭配
public function collocationAction()
{
$this->setNavHeader('星潮教室', true, false);
$data = StarClassModel::getCollocation();
$this->_view->display('collocation', array(
... ... @@ -51,9 +55,9 @@ class StarClassController extends AbstractAction
//星潮教室-星搭配文章请求
public function ajaxCollocationAction()
{
// if (!$this->isAjax()) {
// return;
// }
if (!$this->isAjax()) {
return;
}
$page = $this->get('page',1);
$data = StarClassModel::ajaxCollocation($page);
... ... @@ -67,11 +71,11 @@ class StarClassController extends AbstractAction
//签到
public function signAction()
{
// if(!$this->isAjax()){
// return;
// }
if(!$this->isAjax()){
return;
}
$uid = $this->getUid();
//echo $uid;
if ($uid) {
$res = StarClassModel::sign($uid);
$this->echoJson($res);
... ... @@ -85,9 +89,9 @@ class StarClassController extends AbstractAction
//点赞
public function setPraiseAction()
{
// if(!$this->isAjax()){
// return;
// }
if(!$this->isAjax()){
return;
}
$udid = $this->getUdid();
$articleId = $this->post('articleId');
... ... @@ -99,15 +103,16 @@ class StarClassController extends AbstractAction
//转发
public function forwardAction()
{
// if(!$this->isAjax()){
// return;
// }
if(!$this->isAjax()){
return;
}
//未登录跳转登录页
$this->auditJumpLogin();
$uid = $this->getUid();
}
//收藏资讯文章
public function setFavoriteAction()
{
if (!$this->isAjax()) {
... ... @@ -115,13 +120,14 @@ class StarClassController extends AbstractAction
}
$uid = $this->getUid();
$articleId = $this->post('articleId','3');
$type = $this->post('type');
if (!$uid || !isset($articleId)) {
if (!$uid || !isset($articleId) || !isset($type)) {
$this->echoJson(array('code'=>400,'message'=>'参数错误!'));
}
$result = array();
$result = StarClassData::setFavorite($articleId, $uid);
$result = StarClassData::setFavorite($articleId, $uid, $type);
if (!empty($result)) {
$this->echoJson($result);
}
... ...