Addr.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\facade\Db;
  5. class Addr extends BaseController
  6. {
  7. public function province(){
  8. $list=Db::name("province")->select();
  9. return app_show(0,"获取成功",$list);
  10. }
  11. public function area(){
  12. $post=$this->request->post();
  13. $city_code = isset($post['code'])&& $post['code']!="" ? $post['code']:"";
  14. if($city_code==""){
  15. return error_show(1002,"市级未选择");
  16. }
  17. $city =Db::name("city")->where(['city_code'=>$city_code])->find();
  18. if(empty($city)){
  19. return error_show(1003,"参数code非法数据");
  20. }
  21. $list=Db::name("area")->where(['city_code'=>$city_code])->select();
  22. return app_show(0,"获取成功",$list);
  23. }
  24. public function city(){
  25. $post=$this->request->post();
  26. $province_code = isset($post['code'])&& $post['code']!="" ? $post['code']:"";
  27. if($province_code==""){
  28. return error_show(1002,"省级未选择");
  29. }
  30. $provice = Db::name("province")->where(['province_code'=>$province_code])->find();
  31. if(empty($provice)){
  32. return error_show(1003,"参数code非法数据");
  33. }
  34. $list=Db::name("city")->where(['province_code'=>$province_code])->select();
  35. return app_show(0,"获取成功",$list);
  36. }
  37. }