Partners.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Web\Components\Blog;
  3. use App\Exceptions\ApiException;
  4. use App\Web\Facades\BlogRenderFacade;
  5. use App\Web\Facades\WebFacade;
  6. use App\Web\Models\BlogPlateModel;
  7. use App\Web\Services\WebService;
  8. use Illuminate\View\Component;
  9. class Partners extends Component
  10. {
  11. protected $page; //这是参数
  12. protected $pageSize;
  13. protected $viewFile; //视图地址
  14. protected $typeId;
  15. protected $plateId;
  16. protected $router_path;
  17. /**
  18. * @throws ApiException
  19. */
  20. public function __construct($viewFile = '', $params = [], $typeId = 0, $page = 1, $pageSize = 10,$routerPath='')
  21. {
  22. if (empty($viewFile)) {
  23. throw new ApiException('common.page_none', '您访问的地址不存在~');
  24. }
  25. $this->page = $params['page'] ?? $page;
  26. $this->pageSize = $params['page_size'] ?? $pageSize;
  27. $this->typeId = $params['type_id'] ?? $typeId;
  28. $this->plateId = BlogPlateModel::PARTNERS;
  29. $this->router_path = $params['router_path'] ?? $routerPath;
  30. $this->viewFile = $viewFile;
  31. }
  32. /**
  33. * 合作伙伴列表组件
  34. */
  35. public function render()
  36. {
  37. $retData['partners'] = BlogRenderFacade::getPublishBlogList(
  38. $this->plateId,
  39. '',
  40. $this->page,
  41. $this->pageSize,
  42. [],
  43. (int)$this->typeId,
  44. 0,
  45. 'a.id,a.title,a.image_url,a.image_alt'
  46. );
  47. $retData['areas'] = BlogRenderFacade::getPublishedTypeList($this->plateId);
  48. if (!empty($this->router_path)) {
  49. $pageContent = WebFacade::getStaticPageInfo(['route_path' => $this->router_path]);
  50. $retData['page_content'] = $pageContent['page_content'];
  51. }
  52. $retData['menu_data']=WebFacade::getWebMenu();
  53. //dd($retData);
  54. return view($this->viewFile, $retData);
  55. }
  56. }