You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
1.4 KiB
PHTML

2 years ago
<?php
namespace Site\Controller;
use Think\Controller;
/**
* 首页 控制器
* lwx
*/
class IndexController extends BaseController {
public function index(){
// 精品推荐
$this->game(1,4);
if (is_mobile_request()) {
// 轮播
$this->carousel('union_index_wap');
// 新游上线
$this->game(3,4);
// 热门礼包
$this->gift(2,4);
} else {
// 轮播
$this->carousel();
// 新游上线
$this->game(3,12);
// 开服
$this->open();
// 热门礼包
$this->gift(2,5);
}
$this->display();
}
/**
* 轮播图
*/
private function carousel($name='union_index_pc') {
$this->assign('slider',D('SiteAdv')->lists(['name'=>$name]));
}
/**
* 游戏
*/
public function game($recommend_status=0,$limit=10) {
$map['recommend_status']=array('like','%'.$recommend_status.'%');
$this->assign(($recommend_status==1?'rec':($recommend_status==2?'hot':($recommend_status==3?'news':'no'))).'game',D('SiteGame')->limits($map,$limit));
}
/**
* 开服
*/
public function open() {
$this->assign('open',D('SiteServer')->limits([],8));
}
/**
* 礼包
*/
public function gift($recommend_status=0,$limit=10) {
$map['tab_site_gift.recommend_status']=$recommend_status;
$this->assign('hotgift',D('SiteGift')->limits($map,$limit));
}
}