model = new \app\admin\model\service\order\Comment; $this->view->assign("stateList", $this->model->getStateList()); } public function index() { //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if (false === $this->request->isAjax()) { return $this->view->fetch(); } //如果发送的来源是 Selectpage,则转发到 Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } [$where, $sort, $order, $offset, $limit] = $this->buildparams(); $list = $this->model ->where($where) ->order($sort, $order) ->paginate($limit); foreach ($list as &$val) { $val->user = db('user')->where('id',$val->user_id)->field('avatar,nickname,mobile')->find(); $val->skill = $val->skill_id?db('service_skill')->field('name,mobile,image')->where('id',$val->skill_id)->find():''; $val->shop = $val->shop_id?db('service_shop')->where('id',$val->shop_id)->field('name,abbr,logo_image,leader_name,leader_mobile')->find():''; $val->goodsname = db('service_order_detail')->where('order_id',$val->order_id)->value('name'); } $result = ['total' => $list->total(), 'rows' => $list->items()]; return json($result); } }