Index.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. */
  20. public function home(){
  21. //轮播图
  22. $banner = Db::name('banner')->field('id, title, image, url')->where(['status' => 1])->order('weigh', 'desc')->select();
  23. $banner = list_domain_image($banner, ['image']);
  24. //四个顶部分类
  25. $top_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 1])->order('weigh', 'asc')->limit(4)->select();
  26. $top_category = list_domain_image($top_category, ['image']);
  27. foreach($top_category as $key => $val){
  28. $val['type'] = 'product';
  29. if($key == 3){
  30. $val['type'] = 'news';
  31. }
  32. $top_category[$key] = $val;
  33. }
  34. //底部所有分类
  35. $buttom_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 0])->order('weigh', 'asc')->select();
  36. $buttom_category = list_domain_image($buttom_category, ['image']);
  37. //
  38. $result = [
  39. 'banner' => $banner,
  40. 'top_category' => $top_category,
  41. 'buttom_category' => $buttom_category,
  42. ];
  43. $this->success(1,$result);
  44. }
  45. //吃喝玩乐
  46. //列表
  47. public function chihewanle_list(){
  48. $list = Db::name('chihewanle')->field('id, title, info, image')->where(['status' => 1])->order('weigh', 'desc')->select();
  49. $list = list_domain_image($list, ['image']);
  50. $this->success(1,$list);
  51. }
  52. //吃喝玩乐
  53. //详情
  54. public function chihewanle_info(){
  55. $id = input('id',0);
  56. $info = Db::name('chihewanle')->field('id, title, info, image, content')->where('id',$id)->order('weigh', 'desc')->find();
  57. $info = info_domain_image($info, ['image']);
  58. $this->success(1,$info);
  59. }
  60. }