Service.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace app\api\controller;
  3. use app\admin\model\policy\Type;
  4. use app\common\controller\Api;
  5. use app\common\model\Activity;
  6. use app\common\model\City;
  7. use app\common\model\Message;
  8. use app\common\model\Park;
  9. use app\common\model\PolicyModel;
  10. use app\common\model\Protable;
  11. use app\common\model\ServiiceModel;
  12. use think\Db;
  13. /**
  14. * 在线客服
  15. */
  16. class Service extends Api
  17. {
  18. protected $noNeedLogin = ['lists', 'info', 'listInfo', 'gg', 'parkMessage', 'type', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
  19. protected $noNeedRight = ['*'];
  20. /**
  21. * 常见问题
  22. */
  23. public function lists()
  24. {
  25. $serviceModel = new ServiiceModel();
  26. $data = $serviceModel->where('switch',1)->order('sort desc')->field('id,title')->select();
  27. return $this->success('',$data);
  28. }
  29. /**
  30. * 详情
  31. *
  32. * @param string $id 问题id
  33. */
  34. public function info()
  35. {
  36. $id = $this->request->get('id');
  37. if(!isset($id) || empty($id)) return $this->error('参数错误');
  38. $serviceModel = new ServiiceModel();
  39. $data = $serviceModel->where('id',$id)->find();
  40. return $this->success('',$data);
  41. }
  42. /**
  43. * 在线提问
  44. * @ApiMethod (POST)
  45. * @param string $title 问题标题
  46. * @param string $content 内容
  47. * @param string $images 多图,号分割
  48. */
  49. public function question()
  50. {
  51. $data = $this->request->post();
  52. if (!isset($data['title']) || empty($data['title'])) return $this->error('参数错误101');
  53. if (!isset($data['content']) || empty($data['content'])) return $this->error('参数错误102');
  54. if (!isset($data['images']) || empty($data['images'])) return $this->error('参数错误103');
  55. $user = $this->auth->getUser();
  56. $data['uid'] = $user['id'];
  57. $data['create_time'] = date('Y-m-d H:i:s',time());
  58. $save = Db::name('service_qustion')->insert($data);
  59. if ($save) {
  60. return $this->success('提交成功');
  61. } else {
  62. return $this->error('提交失败!请退出重新提交');
  63. }
  64. }
  65. }