* @version : HUOSDK 8.0 */ namespace h5wap\wap\controller; use h5wap\common\controller\V2BaseController; use huo\controller\game\Game; use huo\controller\game\GameList; use huo\controller\wap\Option; use huo\logic\game\GameLogic; use huo\model\game\CategoryModel; use huolib\constant\CategoryConst; use huolib\constant\FormatConst; use huolib\constant\GameConst; use huolib\status\GameStatus; class GameController extends V2BaseController { public function _initialize() { parent::_initialize(); } /** * H5WAP游戏列表 * http://doc.1tsdk.com/138?page_id=3217 * 【域名】/wap/game/list */ public function index() { $_param = $this->request->param(); $_page = $this->request->param('page/d', 1); $_offset = $this->request->param('offset/d', 10); $_played = $this->request->param('played'); $_gl_class = new GameList(); $_map['classify'] = GameConst::GAME_H5; $_page = $_page.','.$_offset; if (GameConst::GAME_PLAYED == $_played) { if (empty($this->mem_id)) { $_data = null; $_code = GameStatus::NO_ERROR; $this->success(GameStatus::getMsg($_code), $_data, $_code); } $_rdata = $_gl_class->getPlayedList($this->mem_id, $_map['classify'], $_page); $this->returnData($_rdata); } $_rdata = $_gl_class->getList($_param, $_page, $_map); $this->returnData($_rdata); } public function gameList() { return $this->fetch('game/index'); } public function getTypes() { $_type = CategoryConst::CATE_TYPE_TAG_1; $_field = ['id', 'name', 'image', 'status', 'list_order', 'game_cnt', 'item_cnt']; $_tags = (new CategoryModel())->getList(0, '-list_order', $_type, $_field, false); $_rdata['data'] = $_tags; $_rdata['code'] = GameStatus::NO_ERROR; $_rdata['msg'] = GameStatus::getMsg(GameStatus::NO_ERROR); $this->returnData($_rdata); } /** * H5-WAP开服游戏列表 * http://doc.1tsdk.com/138?page_id=3233 * 【域名】/wap/gameserver/index */ public function server() { $_page = $this->request->param('page/d', 1); $_offset = $this->request->param('offset/d', 10); $_gl_class = new GameList(); $_from = GameConst::GAME_H5; $_page = $_page.','.$_offset; $_server_type = $this->request->param('server_type/d', GameConst::GAME_SERVER_ALL); $_rdata = $_gl_class->getServerList($_server_type, $_from, $_page); $this->returnData($_rdata); } /** * http://doc.1tsdk.com/138?page_id=3111 * 游戏详情页 * 【域名】/wap/game/detail * * @return mixed * @throws \think\Exception */ public function detail() { $_game_id = $this->request->param('game_id/d', 0); $_game_data = (new Game())->getDetail($_game_id, $this->mem_id); if (FormatConst::FORMAT_HTML == $this->response_type) { $this->assign($_game_data['data']); //添加seo优化信息 $_seo_data = Option::ins()->getSeoValue('h5_wap_gamedetails_seo', $_game_id); $this->assign('seo', $_seo_data); return $this->fetch('game/detail'); } return $this->returnData($_game_data); } }