TaskCenterController.class.php 1.61 KB
<?php
/**
 * Created by PhpStorm.
 * User: liyifei2012it
 * Date: 17/9/5
 * Time: 15:18
 */
namespace Frontend\Controller\Index;

use Common\Common\Constant;
use Common\Service\ArticleService;

class TaskCenterController extends AbstractController
{
    /**
     * 任务中心手机端从任务内容跳转至手机端课程详情页
     */
    public function Index()
    {
        $app_data_id = I('get.app_data_id', 0, 'intval');
        $customtask_id = I('get.customtask_id', 0, 'intval');

        // 跳转至前端详情页,详情页请求详情接口时会报出此错误
        if ($app_data_id == 0 || $customtask_id == 0) {

            redirectFront('/app/page/course/detail/detail', ['article_id' => $app_data_id]);
        }

        // 跳转至前端详情页,详情页请求详情接口时会报出此错误
        $articleServ = new ArticleService();
        $article = $articleServ->get($app_data_id);
        if (empty($article)) {

            redirectFront('/app/page/course/detail/detail', ['article_id' => $app_data_id]);
        }

        // 前端所需参数
        $param = [
            'data_id' => $article['data_id'],
            'article_id' => $app_data_id,
            'customtask_id' => $customtask_id,
        ];

        // 根据单课程、系列课程,跳转至前端不同页面
        if (Constant::ARTICLE_TYPE_SINGLE == $article['article_type']) {
            // 单课程详情
            redirectFront('/app/page/course/detail/detail', $param);
        } else {
            // 系列课程详情
            redirectFront('/app/page/course/detail/course-detail', $param);
        }
    }
}