修复调用PID为0时无法调用顶级分类

pull/245/head
simon429 2020-09-29 15:46:49 +08:00
parent 32f256f3fa
commit 908039c13d
1 changed files with 9 additions and 10 deletions

View File

@ -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);
}