You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
1.7 KiB
83 lines
1.7 KiB
<?php
|
|
|
|
namespace app\api\controller;
|
|
|
|
use app\common\controller\Api;
|
|
use app\admin\model\Navigation;
|
|
|
|
/**
|
|
* 首页接口
|
|
*/
|
|
class Index extends Api
|
|
{
|
|
protected $noNeedLogin = ['*'];
|
|
protected $noNeedRight = ['*'];
|
|
protected $nav = null;
|
|
protected $share = null;
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->nav = new \app\admin\model\Navigation;
|
|
$this->share = new \app\admin\model\Share;
|
|
}
|
|
|
|
/**
|
|
* get nav
|
|
*
|
|
*/
|
|
public function getNav()
|
|
{
|
|
$parent = $this->nav->where(['pid'=>0])->order('id asc')->select();
|
|
|
|
foreach ($parent as $k=>$v){
|
|
$children = $this->nav->where(['pid'=>$v['id']])->order('sort asc')->select();
|
|
$parent[$k]['children'] = $children;
|
|
}
|
|
$this->success('Request succeeded',$parent);
|
|
}
|
|
|
|
/**
|
|
* get nav Info
|
|
*
|
|
*/
|
|
public function getNavInfo()
|
|
{
|
|
$title = htmlspecialchars_decode($this->request->request('title',''));
|
|
|
|
$info = $this->nav->where(['title'=>$title])->find();
|
|
|
|
$this->success('Request succeeded',$info);
|
|
}
|
|
|
|
/**
|
|
* get nav
|
|
*
|
|
*/
|
|
public function getConfig()
|
|
{
|
|
$key = (string)$this->request->request('key',0);
|
|
if(!$key){
|
|
$this->error('Parameter error');
|
|
}
|
|
|
|
$site = config('site');
|
|
if(!isset($site[$key])){
|
|
$this->error($key.' does not exist');
|
|
}
|
|
|
|
$this->success('Request succeeded',$site[$key]);
|
|
}
|
|
|
|
/**
|
|
* get nav
|
|
*
|
|
*/
|
|
public function getShare()
|
|
{
|
|
$list = $this->share->order('id asc')->select();
|
|
|
|
$this->success('Request succeeded',$list);
|
|
}
|
|
}
|