Report.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 意见反馈
  7. */
  8. class Report extends Api
  9. {
  10. protected $noNeedLogin = ['typelist'];
  11. protected $noNeedRight = ['*'];
  12. //类型列表
  13. /*public function typelist(){
  14. $list = Db::name('report_type')->order('id asc')->select();
  15. $this->success('success',$list);
  16. }*/
  17. //新增举报
  18. public function addone(){
  19. $type = input('type','');
  20. $content = input('content','');
  21. $images = input('images','');
  22. $mobile = input('mobile','');
  23. if(empty($content)){
  24. $this->error('内容不能为空');
  25. }
  26. if(!empty($images) && strpos($images,',')){
  27. if(count(explode(',',$images)) > 8){
  28. $this->error('一次最多只能上传9张图片');
  29. }
  30. }
  31. $data = [
  32. 'user_id' => $this->auth->id,
  33. 'type' => $type,
  34. 'content' => $content,
  35. 'images' => $images,
  36. 'mobile' => $mobile,
  37. 'createtime' => time(),
  38. 'updatetime' => time(),
  39. ];
  40. $id = Db::name('report')->insertGetId($data);
  41. $this->success();
  42. }
  43. }