SolutionList.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 SolutionList extends Component
  10. {
  11. protected $page; //这是参数
  12. protected $pageSize;
  13. protected $viewFile; //视图地址
  14. protected $typeId;
  15. protected $tagId;
  16. protected $plateId;
  17. protected $keyword;
  18. protected $router_path;
  19. /**
  20. * @throws ApiException
  21. */
  22. public function __construct($viewFile = '', $params = [], $keyword = '', $typeId = 0, $tagId = 0,$routerPath='', $page = 1, $pageSize = 10)
  23. {
  24. if (empty($viewFile)) {
  25. throw new ApiException('common.page_none', '您访问的地址不存在~');
  26. }
  27. $this->keyword = $params['keyword'] ?? $keyword;
  28. $this->page = $params['page'] ?? $page;
  29. $this->pageSize = $params['page_size'] ?? $pageSize;
  30. $this->typeId = $params['type_id'] ?? $typeId;
  31. $this->tagId = $params['tag_id'] ?? $tagId;
  32. $this->router_path = $params['router_path'] ?? $routerPath;
  33. $this->plateId = BlogPlateModel::SOLUTION;
  34. $this->viewFile = $viewFile;
  35. }
  36. /**
  37. * 资讯列表组件
  38. */
  39. public function render()
  40. {
  41. $retData = BlogRenderFacade::getPublishBlogList(
  42. $this->plateId,
  43. $this->keyword,
  44. $this->page,
  45. $this->pageSize,
  46. ['pub_date'],
  47. (int)$this->typeId,
  48. (int)$this->tagId
  49. );
  50. if (!empty($this->router_path)) {
  51. $pageContent = WebFacade::getStaticPageInfo(['route_path' => $this->router_path]);
  52. $retData['page_content'] = $pageContent['page_content'];
  53. }
  54. $retData['menu_data']=WebFacade::getWebMenu();
  55. //dd($retData);
  56. return view($this->viewFile, $retData);
  57. }
  58. }