Index.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\mobile\controller;
  3. use app\common\model\ArticleModel;
  4. use app\common\model\NavigationModel;
  5. use app\common\model\SinglePageModel;
  6. use app\common\model\SlideModel;
  7. use app\mobile\MobileBaseController;
  8. class Index extends MobileBaseController
  9. {
  10. public function index()
  11. {
  12. //轮播图
  13. $slide = SlideModel::where('tab', SlideModel::TAB_INDEX)
  14. ->where('status', SlideModel::STATUS_SHOW)
  15. ->order(['priority' => 'desc', 'id' => 'desc'])
  16. ->select();
  17. //导航图
  18. $navigation = NavigationModel::where('tab', NavigationModel::TAB_INDEX)
  19. ->where('status', SlideModel::STATUS_SHOW)
  20. ->order(['priority' => 'desc', 'id' => 'desc'])
  21. ->select();
  22. //文章
  23. $article = ArticleModel::where('status', ArticleModel::STATUS_PUBLISH)
  24. ->order(['priority' => 'desc', 'update_time' => 'desc'])
  25. ->limit(5)
  26. ->select();
  27. return view('', [
  28. 'slide' => $slide,
  29. 'navigation' => $navigation,
  30. 'article' => $article,
  31. ]);
  32. }
  33. public function singlePage()
  34. {
  35. $field = input('get.field', 'about');
  36. if (!in_array($field, SinglePageModel::CODE)) {
  37. jump('文章不存在');
  38. }
  39. $value = SinglePageModel::getConfigValue($field);
  40. $value = explode("\n", $value);
  41. $content = '';
  42. foreach ($value as $v) {
  43. $content .= "<p>{$v}</p>";
  44. }
  45. return view('', [
  46. 'content' => $content,
  47. 'title' => SinglePageModel::CODE_TITLE[$field],
  48. ]);
  49. }
  50. }