Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
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
方斌
51business
Commits
6042ffc4
Commit
6042ffc4
authored
Sep 24, 2019
by
Hsinli
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of t-git.51gjj.com:fangbin/51business
parents
309bec2a
00211cb0
Pipeline
#14099
passed with stage
in 37 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
19 deletions
+48
-19
location.js
app/controller/course/location.js
+28
-0
course.js
app/router/course.js
+1
-0
lbs.js
app/service/course/lbs.js
+19
-19
No files found.
app/controller/course/location.js
0 → 100644
View file @
6042ffc4
'use strict'
;
const
Controller
=
require
(
'egg'
).
Controller
;
class
LocationController
extends
Controller
{
/**
* 筛选项
*/
async
getAddress
()
{
const
{
ctx
}
=
this
;
const
{
lat
,
lng
}
=
ctx
.
request
.
body
;
if
(
!
lat
||
!
lng
)
{
ctx
.
failed
(
'error lat lng'
);
}
const
location_ret
=
await
ctx
.
service
.
course
.
lbs
.
getLBSLocation
({
lat
,
lng
});
let
address
=
'获取位置信息失败'
;
if
(
location_ret
.
result
.
formatted_addresses
&&
location_ret
.
result
.
formatted_addresses
.
recommend
)
{
address
=
location_ret
.
result
.
formatted_addresses
.
recommend
;
}
ctx
.
success
({
result
:
address
});
}
}
module
.
exports
=
LocationController
;
app/router/course.js
View file @
6042ffc4
...
...
@@ -6,6 +6,7 @@ module.exports = app => {
const
miniAuth
=
app
.
middleware
.
miniAuth
();
//登录中间件
router
.
get
(
'third'
,
'/options'
,
'course.option.getOptions'
);
//筛选项
router
.
post
(
'third'
,
'/address'
,
'course.location.getAddress'
);
//根据经纬度或ip获取地理位置信息
router
.
post
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institution/:institution_id/:area_id'
,
'course.institution.institutionInfo'
);
//机构详情
...
...
app/service/course/lbs.js
View file @
6042ffc4
...
...
@@ -95,28 +95,28 @@ class LbsService extends Service {
return
{
result
};
}
// 地址解析
async
getLBSAddress
(
address
)
{
const
{
ctx
}
=
this
;
let
result
=
{};
const
params
=
{
address
,
key
:
ctx
.
app
.
config
.
TX_LBS_KEY
,
};
const
resp
=
await
ctx
.
helper
.
send_request
(
ctx
.
app
.
config
.
TX_LBS_ADDRESS_URL
,
params
,
{
method
:
'GET'
});
// resp.data.status 状态码,0:正常,310:请求参数信息有误,311:Key格式错误,306:请求有护持信息请检查字符串,110:请求来源未被授权
ctx
.
logger
.
info
(
'tx_lbs_address_resp: '
+
JSON
.
stringify
(
resp
));
if
(
resp
.
status
===
200
)
{
// 判断响应是否正确
if
(
resp
.
data
.
status
===
0
)
{
result
=
resp
.
data
.
result
;
}
// 逆地址解析
async
getLBSLocation
(
location
)
{
const
{
ctx
}
=
this
;
let
result
=
{};
const
params
=
{
location
:
location
.
lat
+
','
+
location
.
lng
,
key
:
ctx
.
app
.
config
.
TX_LBS_KEY
,
};
const
resp
=
await
ctx
.
helper
.
send_request
(
ctx
.
app
.
config
.
TX_LBS_ADDRESS_URL
,
params
,
{
method
:
'GET'
});
// resp.data.status 状态码,0:正常,310:请求参数信息有误,311:Key格式错误,306:请求有护持信息请检查字符串,110:请求来源未被授权
ctx
.
logger
.
info
(
'tx_lbs_address_resp: '
+
JSON
.
stringify
(
resp
));
if
(
resp
.
status
===
200
)
{
// 判断响应是否正确
if
(
resp
.
data
.
status
===
0
)
{
result
=
resp
.
data
.
result
;
}
return
{
result
};
}
return
{
result
};
}
}
...
...
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