GameController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * GameController.php UTF-8
  4. * H5 WAP 游戏
  5. *
  6. * @date : 2018/4/27 17:39
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : liuhongliang <lhl@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace h5wap\wap\controller;
  13. use h5wap\common\controller\V2BaseController;
  14. use huo\controller\game\Game;
  15. use huo\controller\game\GameList;
  16. use huo\controller\wap\Option;
  17. use huo\logic\game\GameLogic;
  18. use huo\model\game\CategoryModel;
  19. use huolib\constant\CategoryConst;
  20. use huolib\constant\FormatConst;
  21. use huolib\constant\GameConst;
  22. use huolib\status\GameStatus;
  23. class GameController extends V2BaseController {
  24. public function _initialize() {
  25. parent::_initialize();
  26. }
  27. /**
  28. * H5WAP游戏列表
  29. * http://doc.1tsdk.com/138?page_id=3217
  30. * 【域名】/wap/game/list
  31. */
  32. public function index() {
  33. $_param = $this->request->param();
  34. $_page = $this->request->param('page/d', 1);
  35. $_offset = $this->request->param('offset/d', 10);
  36. $_played = $this->request->param('played');
  37. $_gl_class = new GameList();
  38. $_map['classify'] = GameConst::GAME_H5;
  39. $_page = $_page.','.$_offset;
  40. if (GameConst::GAME_PLAYED == $_played) {
  41. if (empty($this->mem_id)) {
  42. $_data = null;
  43. $_code = GameStatus::NO_ERROR;
  44. $this->success(GameStatus::getMsg($_code), $_data, $_code);
  45. }
  46. $_rdata = $_gl_class->getPlayedList($this->mem_id, $_map['classify'], $_page);
  47. $this->returnData($_rdata);
  48. }
  49. $_rdata = $_gl_class->getList($_param, $_page, $_map);
  50. $this->returnData($_rdata);
  51. }
  52. public function gameList() {
  53. return $this->fetch('game/index');
  54. }
  55. public function getTypes() {
  56. $_type = CategoryConst::CATE_TYPE_TAG_1;
  57. $_field = ['id', 'name', 'image', 'status', 'list_order', 'game_cnt', 'item_cnt'];
  58. $_tags = (new CategoryModel())->getList(0, '-list_order', $_type, $_field, false);
  59. $_rdata['data'] = $_tags;
  60. $_rdata['code'] = GameStatus::NO_ERROR;
  61. $_rdata['msg'] = GameStatus::getMsg(GameStatus::NO_ERROR);
  62. $this->returnData($_rdata);
  63. }
  64. /**
  65. * H5-WAP开服游戏列表
  66. * http://doc.1tsdk.com/138?page_id=3233
  67. * 【域名】/wap/gameserver/index
  68. */
  69. public function server() {
  70. $_page = $this->request->param('page/d', 1);
  71. $_offset = $this->request->param('offset/d', 10);
  72. $_gl_class = new GameList();
  73. $_from = GameConst::GAME_H5;
  74. $_page = $_page.','.$_offset;
  75. $_server_type = $this->request->param('server_type/d', GameConst::GAME_SERVER_ALL);
  76. $_rdata = $_gl_class->getServerList($_server_type, $_from, $_page);
  77. $this->returnData($_rdata);
  78. }
  79. /**
  80. * http://doc.1tsdk.com/138?page_id=3111
  81. * 游戏详情页
  82. * 【域名】/wap/game/detail
  83. *
  84. * @return mixed
  85. * @throws \think\Exception
  86. */
  87. public function detail() {
  88. $_game_id = $this->request->param('game_id/d', 0);
  89. $_game_data = (new Game())->getDetail($_game_id, $this->mem_id);
  90. if (FormatConst::FORMAT_HTML == $this->response_type) {
  91. $this->assign($_game_data['data']);
  92. //添加seo优化信息
  93. $_seo_data = Option::ins()->getSeoValue('h5_wap_gamedetails_seo', $_game_id);
  94. $this->assign('seo', $_seo_data);
  95. return $this->fetch('game/detail');
  96. }
  97. return $this->returnData($_game_data);
  98. }
  99. }