+ 留言建议
+有什么想说的,可以在本页面说
+From 9072821d7a00788f2a8699e4e795be26d44d925d Mon Sep 17 00:00:00 2001 From: liyukun <1099438829@qq.com> Date: Sun, 17 Oct 2021 23:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=95=99=E8=A8=80=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Index.php | 43 +++- app/index/controller/Messageform.php | 38 --- public/template/default/pc/index/msg.html | 220 ++++++++++++++++++ public/template/default/pc/public/footer.html | 2 +- 4 files changed, 263 insertions(+), 40 deletions(-) delete mode 100644 app/index/controller/Messageform.php create mode 100644 public/template/default/pc/index/msg.html diff --git a/app/index/controller/Index.php b/app/index/controller/Index.php index 905dd02..d96211e 100644 --- a/app/index/controller/Index.php +++ b/app/index/controller/Index.php @@ -3,6 +3,7 @@ namespace app\index\controller; use app\admin\service\UtilService as Util; use app\common\model\FriendLink as friendLinkModel; +use app\common\validate\MessageForm as MessageformValidate; use app\Request; /** @@ -56,7 +57,7 @@ class Index extends Base //判断下用户是否存在 $info = friendLinkModel::where('url',$data['url'])->find(); if ($info){ - return app("json")->fail("记录已存在"); + $this->error("记录已存在"); } $data['status'] = 0; $res = friendLinkModel::create($data); @@ -74,4 +75,44 @@ class Index extends Base return $this->fetch(); } } + + /** + * 友链申请 + * @param Request $request + * @return string + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author 李玉坤 + * @date 2021-10-17 1:03 + */ + public function msg(Request $request) + { + if(request()->isPost()){ + $data = Util::postMore([ + ['name',''], + ['tel',''], + ['email',''], + ['content',''], + ]); + $data['create_time']=time(); + $messageFormValidate=new MessageFormValidate(); + if (!$messageFormValidate->check($data)) { + $this->error($messageFormValidate->getError()); + } + $res = friendLinkModel::create($data); + if($res){ + $this->success('留言成功'); + } else { + $this->error('留言失败'); + } + } else { + //清除可能存在的栏目分类树id + cache('curr_category_patent_id',false); + //模板兼容性标签 + $this->assign('id',false); + $this->assign('cid',false); + return $this->fetch(); + } + } } \ No newline at end of file diff --git a/app/index/controller/Messageform.php b/app/index/controller/Messageform.php deleted file mode 100644 index 17f40d3..0000000 --- a/app/index/controller/Messageform.php +++ /dev/null @@ -1,38 +0,0 @@ -isPost()){ - $data=$_POST; - $model=new MessageFormModel(); - $postData=$this->request->param(); - //验证器 - $messageFormValidate=new MessageFormValidate(); - if (!$messageFormValidate->check($postData)) { - $this->error($messageFormValidate->getError()); - } - $msgData['name']=isset($postData['name'])?$postData['name']:''; - $msgData['tel']=isset($postData['tel'])?$postData['tel']:''; - $msgData['email']=isset($postData['email'])?$postData['email']:''; - $msgData['content']=$postData['content']; - $msgData['create_time']=time(); - $re=$model->add($msgData); - if($re){ - $this->success('留言成功'); - } else { - $this->error('留言失败'); - } - } else { - return $this->fetch(); - } - } - -} diff --git a/public/template/default/pc/index/msg.html b/public/template/default/pc/index/msg.html new file mode 100644 index 0000000..bdc2d63 --- /dev/null +++ b/public/template/default/pc/index/msg.html @@ -0,0 +1,220 @@ + + +
+有什么想说的,可以在本页面说
+