Index.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 首页接口
  7. */
  8. class Index extends Api
  9. {
  10. protected $noNeedLogin = ['*'];
  11. protected $noNeedRight = ['*'];
  12. public function index()
  13. {
  14. $this->success();
  15. }
  16. /**
  17. * 首页
  18. */
  19. public function home(){
  20. //
  21. $home = Db::name('home')->order('id asc')->select();
  22. $home = list_domain_image($home,['image','remark_image']);
  23. $home_top = [];
  24. $home_button = [];
  25. foreach ($home as $k => $v){
  26. if($v['category'] == 1){
  27. $home_top[] = $v;
  28. }else{
  29. $home_button[] = $v;
  30. }
  31. }
  32. $zhengwu = Db::name('zhengwufuwu')->where('status',1)->order('weigh','desc')->select();
  33. $gonggao = Db::name('message_sys')->field('id,title,info,updatetime')->order('weigh','desc')->find();
  34. $zhengce = Db::name('zhengcejiedu')->field('id,title,image,audio_file,video_file,updatetime')->order('weigh','desc')->find();
  35. $zhengce = info_domain_image($zhengce,['image','audio_file','video_file']);
  36. //
  37. $result = [
  38. 'index_logo' => localpath_to_netpath(config('site.index_logo')),
  39. 'index_title' => config('site.index_title'),
  40. 'index_title_info' => config('site.index_title_info'),
  41. 'ysszd_logo' => localpath_to_netpath(config('site.ysszd_logo')),
  42. 'ysszd_title' => config('site.ysszd_title'),
  43. 'ysszd_title_info' => config('site.ysszd_title_info'),
  44. 'ysszd_icon' => localpath_to_netpath(config('site.ysszd_icon')),
  45. 'ysszd_url' => config('site.ysszd_url'),
  46. 'home_top' => $home_top,
  47. 'home_button' => $home_button,
  48. 'zhengwu' => $zhengwu,
  49. 'gonggao' => $gonggao,
  50. 'zhengce' => $zhengce,
  51. ];
  52. $this->success(1,$result);
  53. }
  54. //便民页
  55. public function bianmin(){
  56. $cate = Db::name('bianmin_category')->order('id', 'asc')->select();
  57. $bianmin = Db::name('bianmin')->order('id', 'asc')->select();
  58. $bianmin = list_domain_image($bianmin, ['image','remark_image']);
  59. foreach ($cate as $key => $item) {
  60. foreach ($bianmin as $value) {
  61. if($item['id'] == $value['category_id']){
  62. $cate[$key]['child'][] = $value;
  63. }
  64. }
  65. }
  66. $rs = [
  67. 'index_logo' => localpath_to_netpath(config('site.index_logo')),
  68. 'index_title' => config('site.index_title'),
  69. 'index_title_info' => config('site.index_title_info'),
  70. 'bianmin' => $cate,
  71. ];
  72. $this->success(1,$rs);
  73. }
  74. }