SuccessCaseList.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 SuccessCaseList extends Component
  10. {
  11. protected $page; //这是参数
  12. protected $pageSize;
  13. protected $viewFile; //视图地址
  14. protected $plateId;
  15. protected $router_path;
  16. /**
  17. * @throws ApiException
  18. */
  19. public function __construct($viewFile = '', $params = [], $page = 1, $pageSize = 6,$routerPath='')
  20. {
  21. if (empty($viewFile)) {
  22. throw new ApiException('common.page_none', '您访问的地址不存在~');
  23. }
  24. $this->page = $params['page'] ?? $page;
  25. $this->pageSize = $params['page_size'] ?? $pageSize;
  26. $this->plateId = BlogPlateModel::SUCCESSCASES;
  27. $this->viewFile = $viewFile;
  28. $this->router_path = $params['router_path'] ?? $routerPath;
  29. }
  30. /**
  31. * 成功案例列表组件
  32. */
  33. public function render()
  34. {
  35. $retData['recommend_case_list'] = [];
  36. $recommend = BlogRenderFacade::getPublishBlogList(
  37. $this->plateId,
  38. '',
  39. 1,
  40. 3,
  41. ['is_recommend','pub_date'],
  42. 0,
  43. 0,
  44. 'a.id,a.title,a.image_url,a.image_alt,a.total_view,b.urla'
  45. );
  46. if(!empty($recommend['data'])) {
  47. $retData['recommend_case_list'] = $recommend['data'];
  48. }
  49. $retData['case_list'] = BlogRenderFacade::getPublishBlogList(
  50. $this->plateId,
  51. '',
  52. $this->page,
  53. $this->pageSize,
  54. [],
  55. 0,
  56. 0,
  57. 'a.id,a.title,a.image_url,a.image_alt,a.description,b.urla'
  58. );
  59. if (!empty($this->router_path)) {
  60. $pageContent = WebFacade::getStaticPageInfo(['route_path' => $this->router_path]);
  61. $retData['page_content'] = $pageContent['page_content'];
  62. }
  63. $retData['menu_data']=WebFacade::getWebMenu();
  64. //dd($retData);
  65. return view($this->viewFile, $retData);
  66. }
  67. }