ApiTemplate.Class.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * 前台模版
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/12/2
  7. * Time: 12:15
  8. */
  9. namespace JinDouYun\Controller\System;
  10. use JinDouYun\Controller\BaseController;
  11. use JinDouYun\Model\System\MPage;
  12. use Mall\Framework\Core\ErrorCode;
  13. use JinDouYun\Model\System\MEnterpriseBindTemplate;
  14. use Mall\Framework\Core\StatusCode;
  15. class ApiTemplate extends BaseController
  16. {
  17. private $objMEnterpriseBindTemplate;
  18. /**
  19. * ApiTemplate constructor.
  20. * @param bool $isCheckAcl
  21. * @param bool $isMustLogin
  22. * @param bool $checkToken
  23. * @param bool $getAreaCode
  24. */
  25. public function __construct($isCheckAcl = false, $isMustLogin = false, $checkToken = true,$getAreaCode=true)
  26. {
  27. parent::__construct($isCheckAcl, $isMustLogin, $checkToken,$getAreaCode);
  28. $authorization = $this->request->getServerParam('HTTP_AUTHORIZATION');
  29. if (!empty($authorization)) {
  30. self::getUserIdByAuthorization();
  31. }
  32. $this->objMEnterpriseBindTemplate = new MEnterpriseBindTemplate($this->onlineUserId, $this->onlineEnterpriseId,$this->areaCode);
  33. }
  34. /**
  35. * 获取首页模版及数据 废弃
  36. * @throws \Exception
  37. * @deprecated
  38. */
  39. public function getTemplate()
  40. {
  41. $params = $this->request->getRawJson();
  42. $dbResult = $this->objMEnterpriseBindTemplate->getTemplate();
  43. if ($dbResult->isSuccess()) {
  44. $returnData = $dbResult->getData();
  45. parent::sendOutput($returnData['data'], 0);
  46. }
  47. parent::sendOutput($dbResult->getData(), ErrorCode::$dberror);
  48. }
  49. /**
  50. * @throws \Exception
  51. */
  52. public function homePage()
  53. {
  54. $params = $this->request->getRawJson();
  55. $pageType = isset($params['pageType']) ? $params['pageType'] : StatusCode::$pageType['home'];//默认获取首页
  56. $dbResult = $this->objMEnterpriseBindTemplate->homePage($pageType,$this->shopId);
  57. if ($dbResult->isSuccess()) {
  58. $returnData = $dbResult->getData();
  59. parent::sendOutput($returnData['data'], 0);
  60. }
  61. parent::sendOutput($dbResult->getData(), ErrorCode::$dberror);
  62. }
  63. /**
  64. * Doc: (des="")
  65. * User: XMing
  66. * Date: 2020/12/28
  67. * Time: 4:25 下午
  68. * @throws \Exception
  69. */
  70. public function shopHome()
  71. {
  72. $params = (array)$this->request->getRawJson();
  73. $pageType = isset($params['pageType']) ? $params['pageType'] : StatusCode::$pageType['home'];//默认获取首页
  74. $shopId = getArrayItem($params,'merchantId',0);
  75. $objMPage = new MPage($this->onlineUserId,$this->onlineEnterpriseId);
  76. $dbResult = $objMPage->shopHome($shopId,$pageType);
  77. if ($dbResult->isSuccess()) {
  78. $returnData = $dbResult->getData();
  79. parent::sendOutput($returnData, 0);
  80. }
  81. parent::sendOutput($dbResult->getData(), ErrorCode::$dberror);
  82. }
  83. }