Commit df983945 authored by hujun's avatar hujun

获取城市所有区

parent 4705f69c
...@@ -201,9 +201,23 @@ class BusinessDistrict extends Basic ...@@ -201,9 +201,23 @@ class BusinessDistrict extends Basic
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException * @throws \think\exception\DbException
*/ */
public function getCity() { public function getCityAll() {
$region = new Regions(); $region = new Regions();
$city = $region->where('type',2)->select(); $city = $region->getCityAll('code,parentCode,name,fullName,longitude,latitude', ['type'=>2]);
return $this->response(200, '', $city); return $this->response(200, '', $city);
} }
/**
* 获取区数据
*
* @return \think\Response
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function getAllDisc() {
header('Access-Control-Allow-Origin:*');
$regions = new Regions();
$data = $regions->getDiscByCity($this->city);
return $this->response(200, '', $data);
}
} }
\ No newline at end of file
...@@ -138,11 +138,29 @@ class Regions extends Model ...@@ -138,11 +138,29 @@ class Regions extends Model
return $data; return $data;
} }
/**
* @param $city
* @return mixed
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public function getDiscByCity($city){ public function getDiscByCity($city){
$sql = "select fullName as name,longitude,latitude,code as id from regions $sql = "select fullName as name,longitude,latitude,code as id from regions
where parentCode = (select code from regions where fullName='".$city."' and type =2) "; where parentCode = (select code from regions where fullName='".$city."' and type =2) ";
return $this->query($sql); return $this->query($sql);
}
/**
* @param $field
* @param $where
* @return false|\PDOStatement|string|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getCityAll($field, $where){
return $this->field($field)
->where($where)
->select();
} }
} }
...@@ -170,7 +170,7 @@ Route::group('index', [ ...@@ -170,7 +170,7 @@ Route::group('index', [
'houseDel' => [ 'index/Houses/del', [ 'method' => 'post' ] ], //删除商铺 'houseDel' => [ 'index/Houses/del', [ 'method' => 'post' ] ], //删除商铺
'regions' => [ 'index/BusinessDistrict/regions', [ 'method' => 'get' ] ], //获取省市区数据 'regions' => [ 'index/BusinessDistrict/regions', [ 'method' => 'get' ] ], //获取省市区数据
'getCity' => [ 'index/BusinessDistrict/getCity', [ 'method' => 'get' ] ], //获取所有的城市 'getAllDisc' => [ 'index/BusinessDistrict/getAllDisc', [ 'method' => 'get' ] ], //获取所有的城市
'getHouseList' => [ 'index/houses/getHouseList', [ 'method' => 'get' ] ], //楼盘列表 'getHouseList' => [ 'index/houses/getHouseList', [ 'method' => 'get' ] ], //楼盘列表
'carefullyChosen' => [ 'index/houses/carefullyChosen', [ 'method' => 'post' ] ], //设置精选楼盘 'carefullyChosen' => [ 'index/houses/carefullyChosen', [ 'method' => 'post' ] ], //设置精选楼盘
'editExclusive' => [ 'index/houses/editExclusive', [ 'method' => 'post' ] ], //添加和编辑楼盘独家 'editExclusive' => [ 'index/houses/editExclusive', [ 'method' => 'post' ] ], //添加和编辑楼盘独家
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment