Index.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\Config;
  4. use app\common\model\User;
  5. use app\common\controller\Api;
  6. use hg\apidoc\Parser;
  7. use PhpOffice\PhpWord\Template;
  8. use PhpOffice\PhpWord\TemplateProcessor;
  9. use setasign\Fpdi\PdfParser\PdfParser;
  10. use think\Db;
  11. use think\facade\Validate;
  12. use function Sodium\add;
  13. use Mpdf\Mpdf;
  14. /**
  15. * @title 首页
  16. * @controller Index
  17. */
  18. class Index extends Api
  19. {
  20. protected $arr=[
  21. '一年内'=>[0,13],
  22. '1~2年'=>[11,25],
  23. '2~3年'=>[23,37],
  24. '3年以上'=>[35,999999],
  25. ];
  26. public function lists(){
  27. $list=Db::table('p_car')->where('is_deleted',0)
  28. ->limit(getLimit())
  29. ->select();
  30. $this->success('操作成功',$list);
  31. }
  32. public function info(){
  33. $this->check_login();
  34. $id=input('id');
  35. if(empty($id)){
  36. $this->error('参数错误');
  37. }
  38. $info=Db::table('p_car')->where('id',$id)->find();
  39. $this->success('操作成功',$info);
  40. }
  41. public function collect(){
  42. $uid=$this->check_login();
  43. $car_id=input('car_id');
  44. if(empty($car_id)){
  45. $this->error('参数错误');
  46. }
  47. $r=Db::table('p_collect')->where('uid',$uid)->where('car_id',$car_id)->find();
  48. if($r){
  49. Db::table('p_collect')->where('uid',$uid)->where('car_id',$car_id)->delete();
  50. $this->success('取消收藏成功');
  51. }else{
  52. $data['car_id']=$car_id;
  53. $data['uid']=$uid;
  54. Db::table('p_collect')->insert($data);
  55. $this->success('收藏成功');
  56. }
  57. }
  58. public function order(){
  59. $uid=$this->check_login();
  60. $car_id=input('car_id');
  61. $username=input('username');
  62. $mobile=input('mobile');
  63. $data['car_id']=$car_id;
  64. $data['uid']=$uid;
  65. $data['username']=$username;
  66. $data['mobile']=$mobile;
  67. Db::table('p_order')->insert($data);
  68. $this->success('提交成功');
  69. }
  70. public function chexing(){
  71. $list=Db::table('p_car_chexing')->where('is_deleted',0)
  72. ->select();
  73. foreach ($list as $k=>&$v){
  74. $v['pinpai']=Db::table('p_car_pinpai')->where('find_in_set('.$v['id'].',chexing_id)')->select();
  75. }
  76. $this->success('操作成功',$list);
  77. }
  78. public function tm(){
  79. $this->success('操作成功',$this->arr);
  80. }
  81. }