1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-20 19:07:03 +08:00
koogua cbc2e5762a !11 阶段性合并
* 根据app需要作出相应调整
* 路由增加命名name,增加app应用管理
* 完成基本API,增加h5和小程序支付定义
2020-11-10 10:25:16 +08:00

68 lines
1.8 KiB
PHP

<?php
namespace App\Http\Home\Controllers;
use App\Http\Home\Services\Index as IndexService;
use App\Traits\Client as ClientTrait;
use Phalcon\Mvc\Dispatcher;
class IndexController extends Controller
{
use ClientTrait;
public function beforeExecuteRoute(Dispatcher $dispatcher)
{
if ($this->isMobileBrowser()) {
$this->response->redirect('/h5', true);
return false;
}
return parent::beforeExecuteRoute($dispatcher);
}
/**
* @Get("/", name="home.index")
*/
public function indexAction()
{
$this->seo->setKeywords($this->siteInfo['keywords']);
$this->seo->setDescription($this->siteInfo['description']);
$type = $this->siteInfo['index_tpl_type'] ?? 'full';
if ($type == 'full') {
$this->fullIndex();
} else {
$this->simpleIndex();
}
}
protected function fullIndex()
{
$service = new IndexService();
$this->view->pick('index/full');
$this->view->setVar('lives', $service->getLives());
$this->view->setVar('slides', $service->getSlides());
$this->view->setVar('new_courses', $service->getNewCourses());
$this->view->setVar('free_courses', $service->getFreeCourses());
$this->view->setVar('vip_courses', $service->getVipCourses());
}
protected function simpleIndex()
{
$service = new IndexService();
$this->view->pick('index/simple');
$this->view->setVar('lives', $service->getLives());
$this->view->setVar('slides', $service->getSlides());
$this->view->setVar('new_courses', $service->getSimpleNewCourses());
$this->view->setVar('free_courses', $service->getSimpleFreeCourses());
$this->view->setVar('vip_courses', $service->getSimpleVipCourses());
}
}