Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
df983945
Commit
df983945
authored
Oct 23, 2018
by
hujun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取城市所有区
parent
4705f69c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
4 deletions
+37
-4
BusinessDistrict.php
application/index/controller/BusinessDistrict.php
+17
-2
Regions.php
application/model/Regions.php
+19
-1
route.php
application/route.php
+1
-1
No files found.
application/index/controller/BusinessDistrict.php
View file @
df983945
...
...
@@ -201,9 +201,23 @@ class BusinessDistrict extends Basic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function
getCity
()
{
public
function
getCity
All
()
{
$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 \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
application/model/Regions.php
View file @
df983945
...
...
@@ -138,11 +138,29 @@ class Regions extends Model
return
$data
;
}
/**
* @param $city
* @return mixed
* @throws \think\db\exception\BindParamException
* @throws \think\exception\PDOException
*/
public
function
getDiscByCity
(
$city
){
$sql
=
"select fullName as name,longitude,latitude,code as id from regions
where parentCode = (select code from regions where fullName='"
.
$city
.
"' and type =2) "
;
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
();
}
}
application/route.php
View file @
df983945
...
...
@@ -170,7 +170,7 @@ Route::group('index', [
'houseDel'
=>
[
'index/Houses/del'
,
[
'method'
=>
'post'
]
],
//删除商铺
'regions'
=>
[
'index/BusinessDistrict/regions'
,
[
'method'
=>
'get'
]
],
//获取省市区数据
'get
City'
=>
[
'index/BusinessDistrict/getCity
'
,
[
'method'
=>
'get'
]
],
//获取所有的城市
'get
AllDisc'
=>
[
'index/BusinessDistrict/getAllDisc
'
,
[
'method'
=>
'get'
]
],
//获取所有的城市
'getHouseList'
=>
[
'index/houses/getHouseList'
,
[
'method'
=>
'get'
]
],
//楼盘列表
'carefullyChosen'
=>
[
'index/houses/carefullyChosen'
,
[
'method'
=>
'post'
]
],
//设置精选楼盘
'editExclusive'
=>
[
'index/houses/editExclusive'
,
[
'method'
=>
'post'
]
],
//添加和编辑楼盘独家
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment