1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\facade\Db;
- class Addr extends BaseController
- {
- public function province(){
- $list=Db::name("province")->select();
- return app_show(0,"获取成功",$list);
- }
- public function area(){
- $post=$this->request->post();
- $city_code = isset($post['code'])&& $post['code']!="" ? $post['code']:"";
- if($city_code==""){
- return error_show(1002,"市级未选择");
- }
- $city =Db::name("city")->where(['city_code'=>$city_code])->find();
- if(empty($city)){
- return error_show(1003,"参数code非法数据");
- }
- $list=Db::name("area")->where(['city_code'=>$city_code])->select();
- return app_show(0,"获取成功",$list);
- }
- public function city(){
- $post=$this->request->post();
- $province_code = isset($post['code'])&& $post['code']!="" ? $post['code']:"";
- if($province_code==""){
- return error_show(1002,"省级未选择");
- }
- $provice = Db::name("province")->where(['province_code'=>$province_code])->find();
- if(empty($provice)){
- return error_show(1003,"参数code非法数据");
- }
- $list=Db::name("city")->where(['province_code'=>$province_code])->select();
- return app_show(0,"获取成功",$list);
- }
- }
|