service = new SpecsService(['mall_id' => $this->mall_id]); } /** * 首页 * * @return void */ public function actionIndex() { if ($this->request->isAjax) { return $this->success( 'ok', $this->service->getPageList($this->request->get()) ); } return $this->render($this->action->id); } /** * 添加规格 * * @return void */ public function actionAdd() { if ($this->request->isAjax) { $id = $this->request->post('id', null); $params = $this->request->post(); if (Yii::$app->services->validate->validate($params, [ [['name'], 'string'], [['values', 'name'], 'required'] ])) { $res = empty($id) ? $this->service->add($params['name'], $params['values']) : $this->service->edit($id, $params['name'], $params['values']); return $res ? $this->success('ok') : $this->error($this->service->error); } } } /** * 删除规格 * * @return void */ public function actionDel() { if ($this->request->isAjax) { $id = $this->request->get('id', null); return $this->service->del($id) ? $this->success('ok') : $this->error($this->service->error); } } }