StarClass.php 3.02 KB
<?php

use Action\AbstractAction;
use Guang\StarClassModel;
use LibModels\Wap\Guang\StarClassData;
/**
 * 星潮教室
 */
class StarClassController extends AbstractAction
{
    /**
     * 星潮教室首页
     */
    public function indexAction()
    {
        $this->setNavHeader('星潮教室', true, false);
        //获取uid
        $uid = $this->getUid();
        $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
        ));
    }


    //星潮教室-星搭配
    public function collocationAction()
    {
        $this->setNavHeader('星潮教室', true, false);

        $data = StarClassModel::getCollocation();

        $this->_view->display('collocation', array(
            'trendClassCollocation' => $data,
            'trendClassCollocationPage' => true
        ));
    }

    //星潮教室-星搭配文章请求
    public function ajaxCollocationAction()
    {
        if (!$this->isAjax()) {
            return;
        }
        $page = $this->get('page',1);
        $data = StarClassModel::ajaxCollocation($page);

        if (isset($data) && !empty($data)) {
            $this->_view->display('collocation-list',$data);
        }else{
            echo ' ';
        }
    }

    //签到
    public function signAction()
    {
        if(!$this->isAjax()){
            return;
        }
        $uid = $this->getUid();

        if ($uid) {
            $res = StarClassModel::sign($uid);
            $this->echoJson($res);
        }else{
            $this->echoJson(array('code'=>201, 'message'=>'未登录'));
        }


    }

    //点赞
    public function setPraiseAction()
    {
        if(!$this->isAjax()){
            return;
        }
        $udid = $this->getUdid();
        $articleId = $this->post('articleId');

        $result = StarClassData::setPraise($articleId, $udid);

        $this->echoJson($result);
    }

    //转发
    public function forwardAction()
    {
        if(!$this->isAjax()){
            return;
        }
        //未登录跳转登录页
        $this->auditJumpLogin();
        $uid = $this->getUid();

    }

    //收藏资讯文章
    public function setFavoriteAction()
    {
        if (!$this->isAjax()) {
            return;
        }
        $uid = $this->getUid();
        $articleId = $this->post('articleId','3');
        $type = $this->post('type');

        if (!$uid || !isset($articleId) || !isset($type)) {
            $this->echoJson(array('code'=>400,'message'=>'参数错误!'));
        }

        $result = array();
        $result = StarClassData::setFavorite($articleId, $uid, $type);
        if (!empty($result)) {
            $this->echoJson($result);
        }
    }

}