Index.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. $header['jishuguifan'] = localpath_to_netpath(config('site.user_index_jishuguifan'));
  35. $header['caozuoguifan'] = localpath_to_netpath(config('site.user_index_caozuoguifan'));
  36. //关于我们
  37. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  38. ->where('id',$this->auth->company_id)->find();
  39. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  40. //最新动态
  41. $zgs_id = 0;
  42. $dongtai = Db::name('dongtai')->field('id,title,image,updatetime')
  43. ->where('company_id','IN',[$this->auth->company_id,$zgs_id])
  44. ->order('id' , 'desc')
  45. ->limit(3)
  46. ->select();
  47. $dongtai = list_domain_image($dongtai, ['image']);
  48. //
  49. $result = [
  50. 'banner' => $banner,
  51. 'header' => $header,
  52. 'aboutus' => $aboutus,
  53. 'dongtai' => $dongtai,
  54. '119' => 119,
  55. ];
  56. $this->success(1, $result);
  57. }
  58. /**
  59. * 关于我们
  60. */
  61. public function aboutus(){
  62. //关于我们
  63. $aboutus = Db::name('company')->field('aboutus,aboutus_image')
  64. ->where('id',$this->auth->company_id)->find();
  65. $aboutus = info_domain_image($aboutus,['aboutus_image']);
  66. $this->success(1, $aboutus);
  67. }
  68. /**
  69. * 维保信息
  70. */
  71. public function weiboinfo(){
  72. $info = Db::name('user_company')->where('user_id',$this->auth->id)->find();
  73. $info = info_domain_image($info,['header_avatar']);
  74. $info['weituo_info'] = $info['weituo'].'消防设施维护保养';
  75. $this->success(1, $info);
  76. }
  77. }