| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- use think\Db;
 
- /**
 
-  * 首页接口
 
-  */
 
- class Index extends Api
 
- {
 
-     protected $noNeedLogin = ['*'];
 
-     protected $noNeedRight = ['*'];
 
-     public function index()
 
-     {
 
-         $this->success();
 
-     }
 
-     /**
 
-      * 首页
 
-      *
 
-      */
 
-     public function home(){
 
-         //轮播图
 
-         $banner = Db::name('banner')->field('id, title, image, url')->where(['status' => 1])->order('weigh', 'desc')->select();
 
-         $banner = list_domain_image($banner, ['image']);
 
-         //四个顶部分类
 
-         $top_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 1])->order('weigh', 'asc')->limit(4)->select();
 
-         $top_category = list_domain_image($top_category, ['image']);
 
-         foreach($top_category as $key => $val){
 
-             $val['type'] = 'product';
 
-             if($key == 3){
 
-                 $val['type'] = 'news';
 
-             }
 
-             $top_category[$key] = $val;
 
-         }
 
-         //底部所有分类
 
-         $buttom_category = Db::name('unishop_category')->field('id, name, image')->where(['status' => 'normal','is_top' => 0])->order('weigh', 'asc')->select();
 
-         $buttom_category = list_domain_image($buttom_category, ['image']);
 
-         //
 
-         $result = [
 
-             'banner' => $banner,
 
-             'top_category' => $top_category,
 
-             'buttom_category' => $buttom_category,
 
-         ];
 
-         $this->success(1,$result);
 
-     }
 
- }
 
 
  |