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
4ca6fbf0
Commit
4ca6fbf0
authored
Sep 24, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
course fix
parent
b4be5526
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
5 deletions
+46
-5
institution.js
app/controller/course/institution.js
+3
-1
institution.js
app/service/course/institution.js
+43
-4
No files found.
app/controller/course/institution.js
View file @
4ca6fbf0
...
@@ -22,7 +22,9 @@ class InstitutionController extends Controller {
...
@@ -22,7 +22,9 @@ class InstitutionController extends Controller {
async
institutionInfo
()
{
async
institutionInfo
()
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
input_params
=
ctx
.
params
;
let
input_params
=
ctx
.
params
;
const
query
=
ctx
.
query
;
input_params
=
Object
.
assign
(
input_params
,
query
);
const
result
=
await
ctx
.
service
.
course
.
institution
.
getInstitution
(
input_params
);
const
result
=
await
ctx
.
service
.
course
.
institution
.
getInstitution
(
input_params
);
ctx
.
success
({
result
});
ctx
.
success
({
result
});
...
...
app/service/course/institution.js
View file @
4ca6fbf0
...
@@ -59,14 +59,45 @@ class InstitutionService extends Service {
...
@@ -59,14 +59,45 @@ class InstitutionService extends Service {
/**
/**
* 机构详情页
* 机构详情页
*/
*/
async
getInstitution
(
{
institution_id
,
area_id
}
)
{
async
getInstitution
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
user_uuid
=
ctx
.
userUuid
;
const
{
institution_id
,
area_id
,
lat
,
lng
}
=
input
;
const
institution
=
await
ctx
.
classModel
.
CourseInstitution
.
one
({
where
:
{
id
:
institution_id
}
});
const
institution
=
await
ctx
.
classModel
.
CourseInstitution
.
one
({
where
:
{
id
:
institution_id
}
});
const
teachers
=
await
this
.
getTeachers
({
institution_id
,
limit
:
6
});
const
teachers
=
await
this
.
getTeachers
({
institution_id
,
limit
:
6
});
const
classes
=
await
this
.
getClasses
({
institution_id
,
limit
:
4
});
const
classes
=
await
this
.
getClasses
({
institution_id
,
limit
:
4
});
const
areas
=
await
this
.
getInstitutionAreas
({
institution_id
,
limit
:
1000
});
//校区
const
areas_ret
=
await
this
.
getInstitutionAreas
({
institution_id
,
limit
:
1000
});
//校区
//计算校区距离
const
area_rows
=
areas_ret
.
rows
;
const
area_lbs
=
await
this
.
computeDistance
(
area_rows
,
{
lat
,
lng
});
//计算距离信息
const
areas
=
[];
for
(
let
i
in
area_rows
)
{
const
area
=
area_rows
[
i
];
const
lbs
=
area_lbs
[
i
];
const
area_name
=
area
.
name
;
const
distance
=
lbs
.
distance
?
lbs
.
distance
:
10
;
const
duration
=
lbs
.
duration
?
lbs
.
duration
:
60
;
let
travel_tips
=
`距我
${
distance
}
km,开车
${
duration
}
分钟`
;
if
(
lbs
.
travel_method
===
'walking'
)
{
travel_tips
=
`距我
${
distance
}
km,步行
${
duration
}
分钟`
;
}
areas
.
push
({
id
:
area
.
id
,
institution_id
:
area
.
institution_id
,
name
:
area_name
,
address
:
area
.
address
,
phone
:
area
.
phone
,
travel_tips
,
lat
:
area
.
lat
,
lng
:
area
.
lng
,
});
}
const
institution_images
=
await
ctx
.
classModel
.
CourseImages
.
all
({
where
:
{
type
:
1
,
type_id
:
institution_id
}
});
//图片
const
institution_images
=
await
ctx
.
classModel
.
CourseImages
.
all
({
where
:
{
type
:
1
,
type_id
:
institution_id
}
});
//图片
//处理详情页信息
//处理详情页信息
...
@@ -76,6 +107,14 @@ class InstitutionService extends Service {
...
@@ -76,6 +107,14 @@ class InstitutionService extends Service {
institution_detail
.
address
=
current_area
.
address
;
institution_detail
.
address
=
current_area
.
address
;
institution_detail
.
phone
=
current_area
.
phone
;
institution_detail
.
phone
=
current_area
.
phone
;
institution_detail
.
description
=
institution
.
description
;
institution_detail
.
description
=
institution
.
description
;
institution_detail
.
is_collect
=
false
;
//是否收藏过
const
collection_ret
=
await
ctx
.
classModel
.
CourseUserCollection
.
one
({
where
:
{
user_uuid
,
institution_id
,
is_deleted
:
0
}
});
if
(
collection_ret
&&
collection_ret
.
id
)
{
institution_detail
.
is_collect
=
true
;
}
//处理图片
//处理图片
const
photo_album
=
[];
const
photo_album
=
[];
...
@@ -89,7 +128,7 @@ class InstitutionService extends Service {
...
@@ -89,7 +128,7 @@ class InstitutionService extends Service {
}
}
institution_detail
.
photo_album
=
photo_album
;
institution_detail
.
photo_album
=
photo_album
;
return
{
institution_detail
,
teachers
:
teachers
.
rows
,
classes
:
classes
.
rows
,
areas
:
areas
.
rows
};
return
{
institution_detail
,
teachers
:
teachers
.
rows
,
classes
:
classes
.
rows
,
areas
:
areas
};
}
}
async
getTeacher
(
teacher_id
)
{
async
getTeacher
(
teacher_id
)
{
...
...
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