<?php
// +----------------------------------------------------------------------
// | WANCMS游戏平台管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://www.wancms.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 顽皮蛋 <shf_l@163.com> <http://www.wancms.com>
// +----------------------------------------------------------------------
// | 修改时间: 2015/12/15
// +----------------------------------------------------------------------
namespace Phonegame\Controller;
use Common\Controller\PhonegameController;
/**
 * 游戏大厅控制器
 * @author 顽皮蛋 <shf_l@163.com>
 */
class GameController extends PhonegameController{
	public function index(){
		$gametype = (int)I('type');
        $gamename = I('gamename');
		$title=trim(I('title'));
		
        $map['status']  = 1;
        $map['gamename'] =   array('like', '%'.(string)$title.'%');
       
	    if($gametype)$map['gametype'] = $gametype;
        $count=M("m_game")->where($map)->count();
        $page = $this->page($count, 8);
       	//修改时间：2016-01-14 15:20:41 yu 
	    $lists = M("m_game")
        ->where($map)
        ->order("downloadnum DESC")
        ->limit($page->firstRow . ',' . $page->listRows)
        ->select();
        $this->assign('lists', $lists);
        $this->assign('title', $title);
        $this->assign("page", $page->show('Admin'));
       
	    /*游戏类型 */
        $type  = array('1'=>'休闲益智','2'=>'网络游戏','3'=>'体育竞速','4'=>'角色扮演','5'=>'飞行射击','6'=>'策略经营','7'=>'卡片棋牌','8'=>'动作冒险');
		$lan  = array('1'=>'中文','0'=>'英文');
		$this->assign ('lan',$lan);
    	$this->assign ('type', $type);
		$this->display($this->template.'/template1'.'/Game'.'/index');
        

	}
    
	public function history(){
		if(sp_is_user_login()){
			$history['status'] = 1;
			//用户信息
    		$info = sp_get_current_user();
            /*获取用户登录记录*/
            $history['username'] = $info["user_login"];
            $history['avatar'] = $info["avatar"]?$info["avatar"]:'headicon_128.png';
            
    	}else{
    		$history['status'] = 0;
    		$history['info'] = "此用户未登录！";
    	}
    	$this->ajaxReturn($history);
	}
}