12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- namespace app\home\controller;
- use think\Controller;
- use app\user\model\UserComment;
- class Comment extends Controller {
-
- private $commentModel;
-
- public function _initialize(){
- parent::_initialize();
-
- $this->commentModel = new UserComment();
- }
-
- public function index(){
- $data = decode($this->request->post());
-
- $user = $data['u'];
- $page = $data['p'];
- $type = $data['t'];
-
- $info = $this->commentModel->getInfo($user, $type, $page);
-
- return json(["l"=>$info]);
- }
-
- public function comment(){
- $data = decode($this->request->post());
-
- $user = $data['u'];
- $comment = $data['c'];
- $content = $data['i'];
- $type = $data['t'];
-
- $data = ['id'=>getId(), 'user_id'=>$user, 'comment_id'=>$comment, 'content'=>$content, 'type'=>$type];
- $this->commentModel->add($data);
-
- return json(['error'=>0]);
- }
-
- }
|