request->isPost()) { $this->error('请求方式异常'); } //$uid = $this->auth->isLogin()?$this->auth->id:''; $post = input('post.','','trim,strip_tags'); $post['limit'] = 10; $post['page'] = input('page/d',1); $list = \app\api\model\service\Comment::searchComment($post); $this->success('信息列表返回成功',$list); } public function commentLabel() { $list = \app\api\model\service\CommentLabel::where(['state'=>1])->field('id,name')->select(); $this->success('信息返回成功',$list); } /** * 统计评论数据 * @return void */ public function totalComment() { if (!$this->request->isPost()) { $this->error('请求方式异常'); } $post = input('post.','','trim,strip_tags'); $data = ''; try{ $data = \app\api\model\service\Comment::totalComment($post); } catch (Exception $e) { $this->error('获取统计信息失败',$e->getMessage()); } $this->success('信息列表返回成功',$data); } public function commentAdd() { if (!$this->request->isPost()) { $this->error('请求方式异常'); } $post = input('post.','','trim,strip_tags,htmlspecialchars,xss_clean'); $post['user_id'] = $this->auth->id; Db::startTrans(); try{ \app\api\model\service\Comment::commentAdd($post); Db::commit(); } catch (Exception $e) { Db::rollback(); $this->error($e->getMessage()); } $this->success('订单已评论'); } public function getInfo() { if (!$this->request->isPost()) { $this->error('请求方式异常'); } $id = input('order_id',''); $comment = \app\api\model\service\Comment::where('order_id',$id)->field('score,comment_label_ids,comment_label,content,images')->find(); $comment['images'] = $comment['images']?explode(',',$comment['images']):''; $this->success('信息返回成功',$comment); } }