Help.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\{Category,Help as HelpModel};
  5. use liuniu\UtilService;
  6. use think\Request;
  7. class Help extends Api
  8. {
  9. protected $noNeedLogin = [];
  10. protected $noNeedRight = ['*'];
  11. public function index(Request $request)
  12. {
  13. $where = UtilService::getMore(
  14. [
  15. ['category_id',0],
  16. ['page',1],
  17. ['limit',10],
  18. ['isrec',-1],
  19. ]
  20. );
  21. return $this->success('获取成功',HelpModel::lst($where));
  22. }
  23. public function ify()
  24. {
  25. $this->success('获取成功',Category::getCategoryArray('help'));
  26. }
  27. public function apply(Request $request)
  28. {
  29. $where = UtilService::postMore(
  30. [
  31. ['category_id',0],
  32. ['full_name',''],
  33. ['contact',''],
  34. ['id_card',''],
  35. ['title',''],
  36. ['info',''],
  37. ['userimage',''],
  38. ['userimages',''],
  39. ['sex',0],
  40. ['politics',0],
  41. ['birthday',''],
  42. ['address',''],
  43. ['company',''],
  44. ['unit_nature',''],
  45. ['monthly_income',0],
  46. ['annual_household_income',0],
  47. ['annual_household_income_average',0],
  48. ['identity',''],
  49. ['marriage',0],
  50. ['medical_insurance',0],
  51. ['object_features',0],
  52. ['reason',0],
  53. ['family',[]],
  54. ],$request
  55. );
  56. $where['cid'] = $this->cid;
  57. $where['user_id'] = $this->auth->getUserinfo()['id'];
  58. $rs = HelpModel::help_create($where);
  59. if(!$rs) $this->error(HelpModel::getErrorInfo());
  60. $this->success('申请成功',$rs);
  61. }
  62. public function lst(Request $request)
  63. {
  64. $where = UtilService::getMore(
  65. [
  66. ['user_id',$this->auth->getUserinfo()['id']],
  67. ['page',1],
  68. ['limit',10],
  69. ['status',-2],
  70. ]
  71. );
  72. return $this->success('获取成功',HelpModel::lst($where));
  73. }
  74. public function view()
  75. {
  76. $id = input('id',0);
  77. if($id==0) $this->error('参数错误!');
  78. $rs = HelpModel::info($id);
  79. if(!$rs)$this->error(HelpModel::getErrorInfo());
  80. return $this->success('获取成功',$rs);
  81. }
  82. }