model = new \app\common\model\DownloadLink; } /** * 查看 * * @return string|Json * @throws \think\Exception * @throws DbException */ public function index() { if ($this->request->isPost()) { $row = $this->request->post("row/a"); if(count($row) == 2){ $alteration = ['name','image']; }else{ $alteration = ['name','image','content']; } $res = array_combine($alteration,$row); try { $this->model->save($res,['name'=>$res['name']]); } catch (Exception $e) { $this->error($e->getMessage()); } $this->success("提交成功", null, ['data' => json_encode($this->request->post("row/a"), JSON_UNESCAPED_UNICODE)]); }else{ if (false === $this->request->isAjax()) { $this->assign('iantern_slide',$this->model->get(['name'=>'下载地址'])); return $this->view->fetch(); } } } }