Index.php 2.3 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. /**
  13. * 默认
  14. */
  15. public function index()
  16. {
  17. $this->success('请求成功');
  18. }
  19. /**
  20. * 首页
  21. */
  22. public function home(){
  23. //轮播
  24. $banner = Db::name('banner')->field('id, title, image, url')
  25. ->where('company_id',$this->auth->company_id)
  26. ->where(['status' => 1])
  27. ->order(['weigh' => 'desc', 'id' => 'desc'])
  28. ->select();
  29. $banner = list_domain_image($banner, ['image']);
  30. //负责人
  31. $header = Db::name('user_company')->field('header,header_mobile,header_avatar')
  32. ->where('user_id',$this->auth->id)->find();
  33. $header = info_domain_image($header,['header_avatar']);
  34. //关于我们
  35. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  36. ->where('id',$this->auth->company_id)->find();
  37. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  38. //最新动态
  39. $zgs_id = 0;
  40. $dongtai = Db::name('dongtai')->field('id,title,image,updatetime')
  41. ->where('company_id','IN',[$this->auth->company_id,$zgs_id])
  42. ->order('id' , 'desc')
  43. ->limit(3)
  44. ->select();
  45. $dongtai = list_domain_image($dongtai, ['image']);
  46. //
  47. $result = [
  48. 'banner' => $banner,
  49. 'header' => $header,
  50. 'aboutus' => $aboutus,
  51. 'dongtai' => $dongtai,
  52. '119' => 119,
  53. ];
  54. $this->success(1, $result);
  55. }
  56. /**
  57. * 关于我们
  58. */
  59. public function aboutus(){
  60. //关于我们
  61. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  62. ->where('id',$this->auth->company_id)->find();
  63. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  64. $this->success(1, $aboutus);
  65. }
  66. /**
  67. * 维保信息
  68. */
  69. public function weiboinfo(){
  70. $info = Db::name('user_company')->where('user_id',$this->auth->id)->find();
  71. $info = info_domain_image($info,['header_avatar']);
  72. $info['weituo_info'] = $info['weituo'].'消防设施维护保养';
  73. $this->success(1, $info);
  74. }
  75. }