bianjunhui hai 1 ano
pai
achega
2d06a4a2ed
Modificáronse 1 ficheiros con 44 adicións e 3 borrados
  1. 44 3
      application/api/controller/Appindex.php

+ 44 - 3
application/api/controller/Appindex.php

@@ -17,11 +17,52 @@ class Appindex extends Api
      * 首页
      *
      */
-    public function getBanner()
+    public function getIndexOne()
     {
+        $topUrl =$this->getTopUrl();
+        $data['topUrl']=$topUrl;
+        $banner =$this->getBanner('轮播图');
+        $data['banner']=$banner;
+        $category =$this->getBanner('分类');
+        $data['category']=$category;
+        $this->success('',$data);
+    }
 
+    public function getBanner($code)
+    {
+        $banner=$this->getBlockDetail($code);
+        $new=array();
+        $url=input('server.REQUEST_SCHEME') . '://' . input('server.SERVER_NAME');
+        foreach ($banner as $k=> $v){
+            $new[$k]['title'] = $v['title'];
+            $new[$k]['link'] = $v['link'];
+            $new[$k]['type'] = $v['type'];
+            $new[$k]['image'] =$url. $v['image'];
+        }
+        return $new;
+    }
+    public function getTopUrl()
+    {
+        $block =$this->getBlock('顶部链接');
+        $new['title'] = $block['title'];
+        $new['name'] = $block['name'];
+        $new['link'] = $block['link'];
+        $new['type'] = $block['type'];
+        return $new;
+    }
+    public function getBlock($code)
+    {
+        $where['status']=1;
+        $where['title']=$code;
+        return Db::name('appindex')->where($where)->find();
+    }
+    public function getBlockDetail($code)
+    {
         $where['status']=1;
-        $banner = Db::name('message_read')->where($where)->select();
-        $this->success('',$banner);
+        $where['title']=$code;
+        $block= Db::name('appindex')->where($where)->find();
+        unset($where);
+        $where['pid']=$block['id'];
+        return Db::name('appindexdes')->where($where)->select();
     }
 }