* @version : HUOSDK 8.0 */ namespace api\wapapp\controller\v8; use api\common\controller\V2ApiBaseController; use huo\controller\game\Game; use huo\controller\game\GameList; use huo\controller\game\GameServer; use huolib\constant\CommonConst; use huolib\constant\GameConst; class GameController extends V2ApiBaseController { public function __construct() { parent::__construct(); } /** * 游戏列表 * http://doc.huosdk.com/138?page_id=3525 * 【域名】/game/list */ public function index() { $_channel_rq = $this->setChannelData(); $_device_rq = $this->setDeviceData(); $_agent_id = $_channel_rq->getAgentId(); $_page = get_val($this->rq_data, 'page', 1); /* 页码 默认为1 代表第一页 1 */ $_offset = get_val($this->rq_data, 'offset', 10); /* 每页显示数量 默认为10 */ $_hot = get_val($this->rq_data, 'hot', 0); /* 是否热门 2 热门 1 普通 */ $_is_single = get_val($this->rq_data, 'is_single', 0); /* 是否单机 1 单机 2 网游 0 所有 */ $_is_new = get_val($this->rq_data, 'is_new', 0); /* 是否新游 2 新游 0 所有 默认为0 */ $_remd = get_val($this->rq_data, 'remd', 0); /* 2 推荐 1 普通 */ $_type = get_val($this->rq_data, 'type', ''); /* 游戏类型 可以逗号隔开 类型id */ $_hasgift = get_val($this->rq_data, 'hasgift', 0); /* 是否有礼包 2 有礼包 其他 无礼包 */ $_rank_type = get_val($this->rq_data, 'rank_type', 0); /* 排行类型,1为下载榜,2为畅销榜,3为热搜榜(取推荐)*/ $_keywords = get_val($this->rq_data, 'keywords', ''); /* 搜索关键词 */ $_is_fine = get_val($this->rq_data, 'is_fine', 0); /* 是否精品 2 精品 1 普通 */ $_is_rate = get_val($this->rq_data, 'is_rate', 0); /* 是否折扣 2 折扣 1 其他 */ $_is_bt = get_val($this->rq_data, 'is_bt ', 0); /* 是否BT 2 BT 1 其他 */ $_classify = $_device_rq->getFrom(); $_page = $_page.','.$_offset; if (!empty($_hasgift)) { $_datas = (new GameList())->getHasGiftList($_page); } elseif (!empty($_rank_type)) { $_datas = (new GameList())->getRankList($_rank_type, $_page); } else { $_param = []; !empty($_hot) && $_param['hot'] = $_hot; !empty($_is_single) && $_param['is_single'] = $_is_single; !empty($_is_new) && $_param['is_new'] = $_is_new; !empty($_remd) && $_param['remd'] = $_remd; !empty($_type) && $_param['type'] = $_type; !empty($_keywords) && $_param['keywords'] = $_keywords; !empty($_is_fine) && $_param['is_fine'] = $_is_fine; !empty($_classify) && $_param['classify'] = $_classify; !empty($_is_rate) && $_param['is_rate'] = $_is_rate; !empty($_is_bt) && $_param['is_bt'] = $_is_bt; $_rs = (new GameList())->getList($_param, $_page); $_datas = isset($_rs['data']) ? $_rs['data'] : []; } $this->success(lang('SUCCESS'), $_datas); } /** * 游戏详情 * http://doc.1tsdk.com/138?page_id=3527 * 【域名】/game/detail */ public function read() { $_device_rq = $this->setDeviceData(); $_app_id = get_val($this->rq_data, 'game_id'); /* 游戏id */ if (empty($_app_id)) { $this->error(lang('app_id is null')); } $_rs = (new Game())->getDetail($_app_id, $this->mem_id, $_device_rq->getFrom()); $_data = isset($_rs['data']) ? $_rs['data'] : []; $this->success(lang('SUCCESS'), $_data); } /** * 开服游戏列表 * http://doc.1tsdk.com/138?page_id=3368 * 【域名】/gameserver/list */ public function getServerList() { $_page = get_val($this->rq_data, 'page', 1); /* 页码 默认为1 代表第一页 1 */ $_offset = get_val($this->rq_data, 'offset', 10); /* 每页显示数量 默认为10 */ $_server_type = get_val($this->rq_data, 'server_type', GameConst::GAME_SERVER_ALL); /*开服类型*/ $_app_id = get_val($this->rq_data, 'game_id'); /* 游戏id */ $_page = $_page.','.$_offset; $_device_rq = $this->setDeviceData(); $_server_list = (new GameList())->getServerList($_server_type, $_device_rq->getFrom(), $_page, $_app_id); $this->returnData($_server_list); } /** * 获取游戏下载地址 * http://doc.1tsdk.com/138?page_id=3528 * 【域名】/game/down */ public function down() { $_channel_rq = $this->setChannelData(); $_agent_id = $_channel_rq->getAgentId(); $_app_id = get_val($this->rq_data, 'game_id'); /* 游戏id */ if (empty($_app_id)) { $this->error(lang('app_id is null')); } $_data = (new Game())->getDownUrl($_app_id, $_agent_id); $this->returnData($_data); } }