1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 首页接口
- */
- class Appindex extends Api
- {
- protected $noNeedLogin = ['*'];
- protected $noNeedRight = ['*'];
- /**
- * 首页
- *
- */
- 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($code)
- {
- $block =$this->getBlock($code);
- $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;
- $where['title']=$code;
- $block= Db::name('appindex')->where($where)->find();
- unset($where);
- $where['pid']=$block['id'];
- return Db::name('appindexdes')->where($where)->select();
- }
- }
|