field('id,name,ismenu') ->where('company_id',$this->auth->company_id) ->where('pid',0) ->order('id' , 'asc') ->select(); $this->success(1, $list); } //二级 public function lists(){ $tid = input('id',0); $list = Db::name('jishuguifan')->field('id,pid,name,ismenu') ->where('company_id',$this->auth->company_id) ->where('tid',$tid) ->select(); $tree = Tree::instance(); $tree->init($list, 'pid'); $tree->icon = ['a','a','a']; // $tree->icon = ['','','']; $tree->nbsp = 'a'; $treedata = $tree->getTreeList($tree->getTreeArray($tid), 'name'); /*$result = []; foreach ($treedata as $k => $v) { $result[$v['id']] = $v; }*/ $this->success(1, $treedata); } //详情 public function info(){ $id = input('id',0); $info = Db::name('jishuguifan') ->where('id',$id) ->find(); //上一篇 $up_id = 0; $up = Db::name('jishuguifan')->where('pid',$info['pid'])->where('ismenu',0)->where('id','<',$info['id'])->order('id desc')->value('id'); if($up){ $up_id = $up; } //下一篇 $down_id = 0; $down = Db::name('jishuguifan')->where('pid',$info['pid'])->where('ismenu',0)->where('id','>',$info['id'])->order('id asc')->value('id'); if($down){ $down_id = $down; } $rs = [ 'info' => $info, 'up_id' => $up_id, 'down_id' => $down_id, ]; $this->success(1, $rs); } }