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
00211cb0
Commit
00211cb0
authored
Sep 24, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
course fix
parent
414ea6f4
Pipeline
#14098
passed with stage
in 16 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 @
00211cb0
'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 @
00211cb0
...
@@ -6,6 +6,7 @@ module.exports = app => {
...
@@ -6,6 +6,7 @@ module.exports = app => {
const
miniAuth
=
app
.
middleware
.
miniAuth
();
//登录中间件
const
miniAuth
=
app
.
middleware
.
miniAuth
();
//登录中间件
router
.
get
(
'third'
,
'/options'
,
'course.option.getOptions'
);
//筛选项
router
.
get
(
'third'
,
'/options'
,
'course.option.getOptions'
);
//筛选项
router
.
post
(
'third'
,
'/address'
,
'course.location.getAddress'
);
//根据经纬度或ip获取地理位置信息
router
.
post
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
post
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institutions'
,
'course.institution.institutionList'
);
//机构列表
router
.
get
(
'third'
,
'/institution/:institution_id/:area_id'
,
'course.institution.institutionInfo'
);
//机构详情
router
.
get
(
'third'
,
'/institution/:institution_id/:area_id'
,
'course.institution.institutionInfo'
);
//机构详情
...
...
app/service/course/lbs.js
View file @
00211cb0
...
@@ -95,28 +95,28 @@ class LbsService extends Service {
...
@@ -95,28 +95,28 @@ class LbsService extends Service {
return
{
result
};
return
{
result
};
}
}
// 地址解析
// 逆地址解析
async
getLBSAddress
(
address
)
{
async
getLBSLocation
(
location
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
let
result
=
{};
let
result
=
{};
const
params
=
{
const
params
=
{
address
,
location
:
location
.
lat
+
','
+
location
.
lng
,
key
:
ctx
.
app
.
config
.
TX_LBS_KEY
,
key
:
ctx
.
app
.
config
.
TX_LBS_KEY
,
};
};
const
resp
=
await
ctx
.
helper
.
send_request
(
ctx
.
app
.
config
.
TX_LBS_ADDRESS_URL
,
params
,
{
method
:
'GET'
});
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:请求来源未被授权
// resp.data.status 状态码,0:正常,310:请求参数信息有误,311:Key格式错误,306:请求有护持信息请检查字符串,110:请求来源未被授权
ctx
.
logger
.
info
(
'tx_lbs_address_resp: '
+
JSON
.
stringify
(
resp
));
ctx
.
logger
.
info
(
'tx_lbs_address_resp: '
+
JSON
.
stringify
(
resp
));
if
(
resp
.
status
===
200
)
{
if
(
resp
.
status
===
200
)
{
// 判断响应是否正确
// 判断响应是否正确
if
(
resp
.
data
.
status
===
0
)
{
if
(
resp
.
data
.
status
===
0
)
{
result
=
resp
.
data
.
result
;
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