VideoList.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 VideoList 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 = '',$routerPath='', $typeId = 0, $tagId = 0, $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->plateId = BlogPlateModel::VIDEO;
  33. $this->viewFile = $viewFile;
  34. $this->router_path = $params['router_path'] ?? $routerPath;
  35. }
  36. /**
  37. * 视频列表组件
  38. */
  39. public function render()
  40. {
  41. $retData = [];
  42. $retData['news_list'] = BlogRenderFacade::getPublishBlogList(
  43. $this->plateId,
  44. $this->keyword,
  45. $this->page,
  46. $this->pageSize,
  47. [],
  48. (int)$this->typeId,
  49. (int)$this->tagId
  50. );
  51. if (!empty($this->router_path)) {
  52. $pageContent = WebFacade::getStaticPageInfo(['route_path' => $this->router_path]);
  53. $retData['page_content'] = $pageContent['page_content'];
  54. }
  55. $retData['menu_data']=WebFacade::getWebMenu();
  56. return view($this->viewFile, $retData);
  57. }
  58. }