|
|
<?php
|
|
|
|
|
|
use Action\AbstractAction;
|
|
|
use Guang\StarClassModel;
|
|
|
use LibModels\Wap\Guang\StarClassData;
|
|
|
use Plugin\Helpers;
|
|
|
|
|
|
/**
|
|
|
* 星潮教室
|
|
|
* Class StarClassController
|
|
|
*/
|
|
|
class StarClassController extends AbstractAction
|
|
|
{
|
|
|
//定义是否APP变量
|
|
|
protected $_isApp = false;
|
|
|
|
|
|
/**
|
|
|
* 星潮教室首页
|
|
|
*/
|
|
|
public function indexAction()
|
|
|
{
|
|
|
//设置头部公共导航
|
|
|
$this->setNavHeader('星潮教室', true, false);
|
|
|
//获取uid
|
|
|
$uid = $this->getLoggedUid();
|
|
|
//调用模型获得星潮教室首页数据
|
|
|
$data = StarClassModel::getStarClass($uid);
|
|
|
//渲染模板
|
|
|
$this->_view->display('index', array(
|
|
|
'trendClassHome' => $data,
|
|
|
'trendClassHomePage' => true
|
|
|
)
|
|
|
);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 星潮教室-星专题
|
|
|
*/
|
|
|
public function specialAction()
|
|
|
{
|
|
|
//设置头部公共导航
|
|
|
$this->setNavHeader('星潮教室', true, false);
|
|
|
|
|
|
//调用模型获得星专题数据
|
|
|
$data = StarClassModel::getspecial();
|
|
|
|
|
|
//渲染模板
|
|
|
$this->_view->display('subject', array(
|
|
|
'trendClassSubject' => $data,
|
|
|
'trendClassHomePage' => true
|
|
|
));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 星潮教室-星搭配
|
|
|
*/
|
|
|
public function collocationAction()
|
|
|
{
|
|
|
//设置头部公共导航
|
|
|
$this->setNavHeader('星潮教室', true, false);
|
|
|
|
|
|
//调用模板获得星搭配数据
|
|
|
$data = StarClassModel::getCollocation();
|
|
|
|
|
|
//渲染模板
|
|
|
$this->_view->display('collocation', array(
|
|
|
'trendClassCollocation' => $data,
|
|
|
'trendClassCollocationPage' => true
|
|
|
));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 星潮教室-星搭配文章 ajax请求
|
|
|
*/
|
|
|
public function ajaxCollocationAction()
|
|
|
{
|
|
|
if (!$this->isAjax()) {
|
|
|
return;
|
|
|
}
|
|
|
//获得必要参数
|
|
|
$page = $this->get('page',1);
|
|
|
$uid = $this->getLoggedUid();
|
|
|
$isApp = $this->_isApp;
|
|
|
|
|
|
//调取模型获得星搭配文章
|
|
|
$data = StarClassModel::ajaxCollocation($page, $uid, $isApp, $limit = 20);
|
|
|
|
|
|
//返回数据到页面,没有数据返回空格
|
|
|
if (isset($data) && !empty($data)) {
|
|
|
$this->_view->display('collocation-list',$data);
|
|
|
}else{
|
|
|
echo ' ';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 星潮教室-签到-Top100排行榜
|
|
|
*/
|
|
|
public function topAction()
|
|
|
{
|
|
|
//设置头部公共导航(此处返回键调转星潮教室首页)
|
|
|
$url = Helpers::url('/guang/starclass/index');
|
|
|
$this->setNavHeader('星潮粉丝榜', $url, false);
|
|
|
|
|
|
//根据客户端类型,进行未登录跳转
|
|
|
$uid = $this->getLoggedUid();
|
|
|
if (!$uid) {
|
|
|
$refer = Helpers::url('/guang/starclass/top');
|
|
|
if (!$this->_isApp) {
|
|
|
$this->go(Helpers::url('/signin.html', array('refer' => $refer)));
|
|
|
} else {
|
|
|
$referEncode = strtr($refer, array('/' => '\\/'));
|
|
|
$this->go($refer . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $referEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}');
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//调取模型获得Top100数据
|
|
|
$data = StarClassModel::getTop($uid);
|
|
|
|
|
|
//渲染模板
|
|
|
$this->_view->display('check-in',array(
|
|
|
'trendClassCheckIn'=>$data,
|
|
|
'trendClassTopPage' => true
|
|
|
));
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 星潮教室-签到
|
|
|
*/
|
|
|
public function signAction()
|
|
|
{
|
|
|
if(!$this->isAjax()){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//根据客户端类型,进行未登录跳转
|
|
|
$uid = $this->getLoggedUid();
|
|
|
if (!$uid) {
|
|
|
$refer = Helpers::url('/guang/starclass/index');
|
|
|
if (!$this->_isApp) {
|
|
|
$this->echoJson(array('code'=>201,'data'=>Helpers::url('/signin.html', array('refer' => $refer))));
|
|
|
} else {
|
|
|
$referEncode = strtr($refer, array('/' => '\\/'));
|
|
|
$this->echoJson(array('code'=>201,'data'=>$refer . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $referEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'));
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
//调取模型完成签到,并返回数据
|
|
|
$res = StarClassModel::sign($uid);
|
|
|
|
|
|
//输出签到结果到页面
|
|
|
$this->echoJson($res);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 星鲜事-点赞
|
|
|
*/
|
|
|
public function setPraiseAction()
|
|
|
{
|
|
|
if(!$this->isAjax()){
|
|
|
return;
|
|
|
}
|
|
|
//获得客户端ID(点赞不需要登录)
|
|
|
$udid = $this->getUdid();
|
|
|
//获得文章ID
|
|
|
$articleId = $this->post('articleId');
|
|
|
|
|
|
//调取接口点赞
|
|
|
$result = StarClassData::setPraise($articleId, $udid);
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 星搭配-文章分享
|
|
|
*/
|
|
|
public function forwardAction()
|
|
|
{
|
|
|
if(!$this->isAjax()){
|
|
|
return;
|
|
|
}
|
|
|
$result = array();
|
|
|
|
|
|
//根据客户端类型,进行未登录跳转
|
|
|
$uid = $this->getLoggedUid();
|
|
|
if (!$uid) {
|
|
|
$refer = Helpers::url('/guang/starclass/collocation');
|
|
|
if (!$this->_isApp) {
|
|
|
$this->echoJson(array('code'=>201,'data'=>Helpers::url('/signin.html', array('refer' => $refer))));
|
|
|
} else {
|
|
|
$referEncode = strtr($refer, array('/' => '\\/'));
|
|
|
$this->echoJson(array('code'=>201,'data'=>$refer . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $referEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'));
|
|
|
}
|
|
|
return;
|
|
|
}else{
|
|
|
//调取接口分享文章
|
|
|
$result = StarClassData::forward($uid);
|
|
|
}
|
|
|
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 星搭配-收藏资讯文章
|
|
|
*/
|
|
|
public function setFavoriteAction()
|
|
|
{
|
|
|
if (!$this->isAjax()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//根据客户端类型,进行未登录跳转
|
|
|
$uid = $this->getLoggedUid();
|
|
|
if (!$uid) {
|
|
|
$refer = Helpers::url('/guang/starclass/collocation');;
|
|
|
if (!$this->_isApp) {
|
|
|
$this->echoJson(array('code'=>201,'data'=>Helpers::url('/signin.html', array('refer' => $refer))));
|
|
|
} else {
|
|
|
$referEncode = strtr($refer, array('/' => '\\/'));
|
|
|
$this->echoJson(array('code'=>201,'data'=>$refer . '?openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"' . $referEncode . '","param":{"from":"app"}},"requesturl":{"url":"","param":{}},"priority":"N"}}'));
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//获取文章ID,接口Type(fav调取收藏接口,del调取取消收藏接口)
|
|
|
$articleId = $this->post('articleId');
|
|
|
$type = $this->post('type');
|
|
|
|
|
|
if (!isset($articleId) || !isset($type)) {
|
|
|
$this->echoJson(array('code'=>400,'message'=>'参数错误!'));
|
|
|
}
|
|
|
$result = array();
|
|
|
//调取接口进行收藏
|
|
|
$result = StarClassData::setFavorite($articleId, $uid, $type);
|
|
|
|
|
|
if (!empty($result)) {
|
|
|
$this->echoJson($result);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 检测登录状态
|
|
|
*
|
|
|
* @return int
|
|
|
*/
|
|
|
private function getLoggedUid()
|
|
|
{
|
|
|
// 判断是否是应用访问, 拼接APP需要的URL参数
|
|
|
$this->_isApp = (null !== $this->get('app_version') || null !== $this->get('uid'));
|
|
|
$uid = false;
|
|
|
if ($this->_isApp) {
|
|
|
$uid = $this->get('uid');
|
|
|
} else {
|
|
|
$uid = $this->getUid();
|
|
|
}
|
|
|
|
|
|
return $uid;
|
|
|
}
|
|
|
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|