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.
397 lines
14 KiB
PHTML
397 lines
14 KiB
PHTML
5 years ago
|
<?php
|
||
|
|
||
|
namespace Media\Controller;
|
||
|
use OT\DataDictionary;
|
||
|
use User\Api\MemberApi;
|
||
|
|
||
|
/**
|
||
|
* 前台首页控制器
|
||
|
* 主要获取首页聚合数据
|
||
|
*/
|
||
|
class IndexController extends BaseController {
|
||
|
|
||
|
//系统首页
|
||
|
public function index(){
|
||
|
$this->slide();//轮播图
|
||
|
$this->recommend();
|
||
|
$this->hot();
|
||
|
$this->area();
|
||
|
$this->slide(2);//中部广告
|
||
|
$this->newzixun();
|
||
|
$this->slide(4);//资讯广告
|
||
|
$this->gift();
|
||
|
|
||
|
$user_id=session('member_auth.mid');
|
||
|
$user=get_user_entity($user_id)==false?session('member_auth'):get_user_entity($user_id);
|
||
|
C(api('Config/lists'));
|
||
|
if (C('UC_SET') == 1 && session('member_auth.nickname') == 'Uc用户') {
|
||
|
$user_play = null;
|
||
|
$sqltype = 2;
|
||
|
$ucuser = M('User','tab_',C('DB_CONFIG2'))->where(array('account'=>session('member_auth.account')))->find();
|
||
|
if($ucuser==''){
|
||
|
$sqltype = 3;
|
||
|
$ucuser = M('User','tab_',C('DB_CONFIG3'))->where(array('account'=>session('member_auth.account')))->find();
|
||
|
}
|
||
|
$this->assign('uc_balance', $ucuser['balance']);
|
||
|
} else{
|
||
|
$user_play=M('User_play as u','tab_')
|
||
|
->field('g.relation_game_id,g.relation_game_name,u.server_name,icon')
|
||
|
->join('tab_game g on u.game_id = g.id ')
|
||
|
->where(array('user_id'=>$user['id']))
|
||
|
->group('g.relation_game_id')
|
||
|
->limit(2)
|
||
|
->select();
|
||
|
}
|
||
|
$this->assign('user_play',$user_play);
|
||
|
$this->assign('user',$user);
|
||
|
$this->display();
|
||
|
}
|
||
|
|
||
|
|
||
|
public function slide($pos_id=1){
|
||
|
$adv = M("Adv","tab_");
|
||
|
$map['status'] = 1;
|
||
|
$map['pos_id'] = $pos_id; #首页轮播图广告id
|
||
|
$map['start_time']=array(array('lt',time()),array('eq',0), 'or') ;
|
||
|
$map['end_time']=array(array('gt',time()),array('eq',0), 'or') ;
|
||
|
$carousel = $adv->where($map)->order('sort desc,id desc')->select();
|
||
|
if($pos_id==2){
|
||
|
// 设置媒体中部广告为一张 随机显示
|
||
|
$carousel = $adv->where($map)->limit(1)->select();
|
||
|
$this->assign("midcarousel",$carousel);
|
||
|
}elseif($pos_id==4){
|
||
|
$data[0] = array('url'=>'javascript:','title'=>'暂无广告','data'=>'0');
|
||
|
$carousel = empty($carousel)?$data:$carousel;
|
||
|
$this->assign("zixuncarousel",$carousel);
|
||
|
}else{
|
||
|
$this->assign("carousel",$carousel);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
/***
|
||
|
*推荐游戏
|
||
|
*/
|
||
|
public function recommend(){
|
||
|
$model = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>1,'display_site'=>['like','%' . DISPLAY_SITE . '%']),
|
||
|
'field' =>'*,min(id) as id',
|
||
|
'order' =>'sort desc,id desc',
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>'0,9',
|
||
|
);
|
||
|
if(is_cache() && S('index_reco')){
|
||
|
$reco=S('index_reco');
|
||
|
}else{
|
||
|
$reco = parent::list_data($model);
|
||
|
if(is_cache() ){
|
||
|
S('index_reco',$reco);
|
||
|
}
|
||
|
}
|
||
|
$reco=game_merge($reco,$model['map']);
|
||
|
// var_dump($reco);die;
|
||
|
$this->assign('recommend',$reco);
|
||
|
}
|
||
|
/***
|
||
|
*推荐游戏
|
||
|
*/
|
||
|
public function recommend1(){
|
||
|
$shunxu = I('shunxu');
|
||
|
$shuzu = M('Game','tab_')->where(array('game_status'=>1,'recommend_status'=>1))->field('relation_game_id')->group('relation_game_id')->select();
|
||
|
$count = count($shuzu);
|
||
|
if ($count <= 4){
|
||
|
$this->ajaxReturn(array('status'=>0,'data'=>"没有更多了~"));
|
||
|
}
|
||
|
$arr = array();
|
||
|
foreach ($shuzu as $k => $v){
|
||
|
$arr[] = $shuzu[$k]['relation_game_id'];
|
||
|
}
|
||
|
|
||
|
$shunxu1 = $shunxu*4;
|
||
|
$shunxu2 = $shunxu*4+4;
|
||
|
|
||
|
|
||
|
if (floor($shunxu1/$count) == floor($shunxu2/$count) && floor($shunxu1/$count) == 0){
|
||
|
$shunxu_x = $shunxu1.",".($shunxu2-$shunxu1);
|
||
|
}elseif(floor($shunxu1/$count) == floor($shunxu2/$count) && floor($shunxu1/$count) != 0){
|
||
|
$floor = floor($shunxu1/$count);
|
||
|
$shunxu_x = ($shunxu1-$floor*$count).",".(($shunxu2-$floor*$count)-($shunxu1-$floor*$count));
|
||
|
}elseif (floor($shunxu1/$count) == 0 && floor($shunxu2/$count)!=0){
|
||
|
$floor = floor($shunxu2/$count);
|
||
|
$shunxu_x1 = $shunxu1.",".($count-$shunxu1);
|
||
|
$shunxu_x2 = '0'.",".($shunxu2-$floor*$count);
|
||
|
}elseif(floor($shunxu1/$count) != 0 && floor($shunxu2/$count)!=0 && floor($shunxu1/$count) != floor($shunxu2/$count)){
|
||
|
$floor1 = floor($shunxu1/$count);
|
||
|
$floor2 = floor($shunxu2/$count);
|
||
|
|
||
|
$shunxu_x1 = ($shunxu1-$floor1*$count).",".($count-($shunxu1-$floor1*$count));
|
||
|
$shunxu_x2 = '0'.",".($shunxu2-$floor2*$count);
|
||
|
}
|
||
|
|
||
|
|
||
|
if ($shunxu_x){
|
||
|
$model = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>1),
|
||
|
'field' =>'*,min(id) as id',
|
||
|
'order' =>'id desc',
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>$shunxu_x,
|
||
|
);
|
||
|
$reco = parent::list_data($model);
|
||
|
}else{
|
||
|
$model1 = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>1),
|
||
|
'field' =>'*,min(id) as id',
|
||
|
'order' =>'id desc',
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>$shunxu_x1,
|
||
|
);
|
||
|
$reco1 = parent::list_data($model1);
|
||
|
|
||
|
if ($shunxu_x2 != '0,0'){
|
||
|
$model2 = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>1),
|
||
|
'field' =>'*,min(id) as id',
|
||
|
'order' =>'id desc',
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>$shunxu_x2,
|
||
|
);
|
||
|
$reco2 = parent::list_data($model2);
|
||
|
$reco = array_merge($reco1,$reco2);
|
||
|
}else{
|
||
|
$reco = $reco1;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
$reco=game_merge($reco,$model['map']);
|
||
|
foreach ($reco as $key=>$value){
|
||
|
$reco[$key]['game_detail']=U('Game/game_detail',array('id'=>$value['relation_game_id']));
|
||
|
$reco[$key]['dow_url_generate_and']=U('Game/dow_url_generate',array('id'=>$value['relation_game_id'],'type'=>1));
|
||
|
$reco[$key]['dow_url_generate_ios']=U('Game/dow_url_generate',array('id'=>$value['relation_game_id'],'type'=>2));
|
||
|
$reco[$key]['relation_game_id']=U('Game/game_detail',array('id'=>$value['relation_game_id']));
|
||
|
$reco[$key]['cover']=get_cover($value['cover'],'path');
|
||
|
$reco[$key]['percent']=$value['game_score']*10;
|
||
|
$reco[$key]['down_total']=$value['anddow']+$value['iosdow'];
|
||
|
$reco[$key]['game_type_name'] = msubstr2($reco[$key]['game_type_name'],0,10);
|
||
|
$reco[$key]['relation_game_name'] = msubstr2($reco[$key]['relation_game_name'],0,10);
|
||
|
}
|
||
|
if($reco){
|
||
|
$this->ajaxReturn(array('status'=>1,'data'=>$reco));
|
||
|
}else{
|
||
|
$this->ajaxReturn(array('status'=>0,'data'=>"没有更多了~"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/***
|
||
|
*热门游戏
|
||
|
*/
|
||
|
public function hot($limit=8){
|
||
|
$model = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>2,'display_site'=>['like','%' . DISPLAY_SITE . '%']),
|
||
|
'field' =>'*,min(id) as id',
|
||
|
'order' =>'sort desc,id desc',
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>8,
|
||
|
);
|
||
|
if(is_cache() && S('index_hot')){
|
||
|
$hot=S('index_hot');
|
||
|
}else{
|
||
|
$hot = parent::list_data($model);
|
||
|
if(is_cache() ){
|
||
|
S('index_hot',$hot);
|
||
|
}
|
||
|
}
|
||
|
$hot = game_merge($hot,$model['map']);
|
||
|
$this->assign('hot',$hot);
|
||
|
}
|
||
|
|
||
|
/***
|
||
|
*最新游戏
|
||
|
*/
|
||
|
public function newgame($recommend_status=3,$order='sort desc,id desc'){
|
||
|
$model = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>$recommend_status,'display_site'=>['like','%' . DISPLAY_SITE . '%']),
|
||
|
'field' =>'*,min(id) as id,@counter:=@counter+1 AS Rank',
|
||
|
'order' =>$order,
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>9,
|
||
|
);
|
||
|
$newgame = parent::list_data($model);
|
||
|
$newgame = array_order(game_merge($newgame,$model['map']));
|
||
|
$this->assign('new',$newgame);
|
||
|
}
|
||
|
|
||
|
/***
|
||
|
*游戏礼包
|
||
|
*/
|
||
|
public function gift(){
|
||
|
$map['game_status']=1;
|
||
|
$map['end_time']=array(array('gt',time()),array('eq',0),'or');
|
||
|
//$map['giftbag_type']=2;
|
||
|
$map['status'] = 1;
|
||
|
$map['display_site'] = ['like','%'. DISPLAY_SITE .'%'];
|
||
|
$model = array(
|
||
|
'm_name'=>'Giftbag',
|
||
|
'prefix'=>'tab_',
|
||
|
'field' =>'tab_giftbag.id as gift_id,relation_game_name,game_id,tab_giftbag.game_name,giftbag_name,giftbag_type,tab_game.icon,tab_giftbag.create_time',
|
||
|
'join' =>'tab_game on tab_giftbag.game_id = tab_game.id',
|
||
|
'map' =>$map,
|
||
|
'order' =>'create_time desc',
|
||
|
'limit' =>10,
|
||
|
);
|
||
|
if(is_cache() && S('index_gift')){
|
||
|
$gift=S('index_gift');
|
||
|
}else{
|
||
|
$gift = parent::join_data($model);
|
||
|
if(is_cache() ){
|
||
|
S('index_gift',$gift);
|
||
|
}
|
||
|
}
|
||
|
foreach ($gift as $key => $value) {
|
||
|
$gift[$key]['gift_num']=gift_recorded($value['game_id'],$value['gift_id']);
|
||
|
}
|
||
|
$this->assign('gift',$gift);
|
||
|
}
|
||
|
|
||
|
/***
|
||
|
*游戏区服
|
||
|
*/
|
||
|
public function area(){
|
||
|
$model = array(
|
||
|
'm_name'=>'server',
|
||
|
'prefix'=>'tab_',
|
||
|
'field' =>'tab_server.*,tab_game.relation_game_name,tab_game.relation_game_id,tab_game.icon,tab_game.cover,tab_giftbag.id as gift_id',
|
||
|
'join' =>' left join tab_game on tab_server.game_id = tab_game.id left join tab_giftbag on tab_server.game_id = tab_giftbag.game_id',
|
||
|
'map' =>array('game_status'=>1,'show_status'=>1,'tab_server.start_time'=>array('lt',time()),'display_site'=>['like','%' . DISPLAY_SITE . '%']),
|
||
|
'group' =>'tab_server.id',
|
||
|
'order' =>'start_time desc',
|
||
|
'limit'=>10000,
|
||
|
);
|
||
|
$area = parent::join_data($model);
|
||
|
$this->assign('area',$area);
|
||
|
}
|
||
|
|
||
|
|
||
|
public function newzixun($limit=''){
|
||
|
$map['sys_category.name']=array('in','media_gg,media_activity,media_zx');//显示公告和资讯
|
||
|
$map['sys_document.status']=1;
|
||
|
$map['sys_document.display']=1;
|
||
|
$map['deadline']=array(array('gt',time()),array('eq',0),'or');
|
||
|
$data=M('document')
|
||
|
->field('sys_category.name,cover_id,category_id,sys_document.description,sys_document.title,sys_document.update_time,sys_document.id')
|
||
|
->join('sys_category on sys_document.category_id = sys_category.id and sys_category.pid = 84')
|
||
|
->where($map)
|
||
|
->limit($limit)
|
||
|
->limit(0,20)
|
||
|
->order('level desc,id desc')
|
||
|
->select();
|
||
|
foreach ($data as $key => $value) {
|
||
|
if($value['name']=='media_activity'){
|
||
|
$huodong[]=$value;
|
||
|
unset($data[$key]);
|
||
|
}
|
||
|
if($value['name']=='media_gg'){
|
||
|
$media_gg[]=$value;
|
||
|
unset($data[$key]);
|
||
|
}
|
||
|
if($value['name']=='media_zx'){
|
||
|
$media_zx[]=$value;
|
||
|
unset($data[$key]);
|
||
|
}
|
||
|
}
|
||
|
$this->assign('firhuodong',$huodong[0]);
|
||
|
unset($huodong[0]);
|
||
|
$this->assign('huodong',$huodong);
|
||
|
$this->assign('media_gg',$media_gg);
|
||
|
$this->assign('media_zx',$media_zx);
|
||
|
$this->assign('newzixun',$data);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
public function download(){
|
||
|
$app_map['name'] = ['like','%游戏盒子%'];
|
||
|
$app_map['version'] = 1;
|
||
|
$android = M('app', 'tab_')->where($app_map)->find();
|
||
|
$android_url = file_exists($android['file_url'])?$android['file_url']:"javascript:";
|
||
|
$this->assign('android',$android_url);
|
||
|
|
||
|
$app_map['version'] = 2;
|
||
|
$ios = M('app', 'tab_')->where($app_map)->find();
|
||
|
$ios['url'] = file_exists($ios['file_url'])?$ios['file_url']:"javascript:";
|
||
|
$ios['plist_url'] = "https://".$_SERVER['HTTP_HOST'].substr($ios['plist_url'],1);
|
||
|
if(is_mobile_request()){
|
||
|
$devices = get_devices_type();
|
||
|
$this->assign("devices",$devices);
|
||
|
}
|
||
|
$this->assign('ios',$ios);
|
||
|
$this->display();
|
||
|
}
|
||
|
|
||
|
public function qrcode($url='pc.vlcms.com',$level=3,$size=4){
|
||
|
$url = base64_decode(base64_decode($url));
|
||
|
Vendor('phpqrcode.phpqrcode');
|
||
|
$errorCorrectionLevel =intval($level) ;//容错级别
|
||
|
$matrixPointSize = intval($size);//生成图片大小
|
||
|
//生成二维码图片
|
||
|
//echo $_SERVER['REQUEST_URI'];
|
||
|
ob_clean();
|
||
|
$object = new \QRcode();
|
||
|
echo $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2);
|
||
|
}
|
||
|
|
||
|
public function down_app(){
|
||
|
|
||
|
}
|
||
|
|
||
|
public function business(){
|
||
|
|
||
|
$model = array(
|
||
|
'm_name'=>'Game',
|
||
|
'prefix'=>'tab_',
|
||
|
'map' =>array('game_status'=>1,'recommend_status'=>1,'display_site'=>['like','%' . DISPLAY_SITE . '%']),
|
||
|
'field' =>'*,min(id) as id',
|
||
|
'order' =>'sort desc,id desc',
|
||
|
'group' =>'relation_game_id',
|
||
|
'limit' =>'0,9',
|
||
|
);
|
||
|
if(is_cache() && S('index_reco')){
|
||
|
$reco=S('index_reco');
|
||
|
}else{
|
||
|
$reco = parent::list_data($model);
|
||
|
if(is_cache() ){
|
||
|
S('index_reco',$reco);
|
||
|
}
|
||
|
}
|
||
|
$reco=game_merge($reco,$model['map']);
|
||
|
$this->assign('recommend',$reco);
|
||
|
|
||
|
|
||
|
$this->display();
|
||
|
|
||
|
}
|
||
|
|
||
|
public function join(){
|
||
|
|
||
|
$this->display();
|
||
|
}
|
||
|
|
||
|
public function hezuo(){
|
||
|
|
||
|
|
||
|
$this->display();
|
||
|
}
|
||
|
}
|