类别联动的时候无法选择顶级类别

andiff 3月前 74

在示例中,类别联动第一个下拉框里面不是顶级类别。

public function category()
    {
        $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();
        }
        $this->success('', null, $categorylist);
    }```
代码里面我看没法选择顶级类别,一旦pid传0,那么不会查询顶级类别。
最新回复 (1)
返回
发表回复