diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 8ea11e044b4d84ac6ea7dbb36f0e9c84b95efa16..8fa3adc6e800c597daf120800294dcca740fabdf 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -220,17 +220,16 @@ class Ajax extends Backend $type = $this->request->get('type'); $pid = $this->request->get('pid'); $where = ['status' => 'normal']; - $categorylist = null; - if ($pid !== '') { - if ($type) { - $where['type'] = $type; - } - if ($pid) { - $where['pid'] = $pid; - } - - $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select(); + $categorylist = null; + if ($pid || $pid === '0') { + $where['pid'] = $pid; + } + if ($type) { + $where['type'] = $type; } + + $categorylist = Db::name('category')->where($where)->field('id as value,name')->order('weigh desc,id desc')->select(); + $this->success('', null, $categorylist); }