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
93906451
Commit
93906451
authored
Apr 25, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
house tool fix
parent
7fa44a98
Pipeline
#6432
passed with stage
in 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
tool.js
app/controller/house/tool.js
+34
-6
city.js
app/model/block/city.js
+1
-0
No files found.
app/controller/house/tool.js
View file @
93906451
...
...
@@ -189,19 +189,30 @@ class ToolController extends Controller {
direction_str
:
{
type
:
'string'
,
required
:
true
},
floor
:
{
type
:
'string'
,
required
:
true
},
total_floor
:
{
type
:
'string'
,
required
:
true
},
area_code
:
{
type
:
'string'
,
required
:
true
},
};
ctx
.
validate
(
rule
,
input_params
);
const
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
input_params
.
area_code
}
});
if
(
!
city
||
!
city
.
pinyin
||
Object
.
keys
(
city
).
length
===
0
)
{
ctx
.
failed
(
'暂不支持城市'
);
}
const
city_pinyin_array
=
city
.
pinyin
.
split
(
' '
);
let
city_pinyin
=
''
;
for
(
let
i
=
0
;
i
<
city_pinyin_array
.
length
-
1
;
i
++
)
{
const
pinyin
=
city_pinyin_array
[
i
];
city_pinyin
+=
pinyin
;
};
// ctx.validate(rule, input_params);
const
residential_id
=
input_params
.
residential_id
;
const
residential_name
=
input_params
.
residential_name
;
const
area
=
input_params
.
area
;
const
direction_str
=
input_params
.
direction_str
;
const
floor
=
input_params
.
floor
;
const
total_floor
=
input_params
.
total_floor
;
const
qfang_url_area
=
'https://hangzhou.qfang.com/fangjia/area'
;
const
qfang_url_area
=
`https://
${
city_pinyin
}
.qfang.com/fangjia/area`
;
// const query_string = encodeURIComponent(`userName=&gardenId=&gardenInternalID=${residential_id}&name=${residential_name}&area=${area}&floor=${floor}&totlaFloor=${total_floor}&directionStr=${direction_str}&buildingId=&building=&roomNoId=&roomNo=&subQueryType=quick`);
// const qfang_url_chaxun = 'https://hangzhou.qfang.com/fangjia/chaxun?userName=&gardenId=&gardenInternalID=1f552c71-2747-4539-aeaa-0fc37a6dcd10&name=%E4%B8%87%E9%83%BD%E6%99%B6%E5%BA%A7&area=12&floor=2&totlaFloor=10&directionStr=SOUTHEAST&buildingId=&building=&roomNoId=&roomNo=&subQueryType=quick';
const
qfang_url_chaxun
=
`https://
hangzhou
.qfang.com/fangjia/chaxun?userName=&gardenId=&gardenInternalID=
${
residential_id
}
&name=
${
encodeURIComponent
(
residential_name
)}
&area=
${
area
}
&floor=
${
floor
}
&totlaFloor=
${
total_floor
}
&directionStr=
${
direction_str
}
&buildingId=&building=&roomNoId=&roomNo=&subQueryType=quick`
;
console
.
info
(
qfang_url_chaxun
);
const
qfang_url_chaxun
=
`https://
${
city_pinyin
}
.qfang.com/fangjia/chaxun?userName=&gardenId=&gardenInternalID=
${
residential_id
}
&name=
${
encodeURIComponent
(
residential_name
)}
&area=
${
area
}
&floor=
${
floor
}
&totlaFloor=
${
total_floor
}
&directionStr=
${
direction_str
}
&buildingId=&building=&roomNoId=&roomNo=&subQueryType=quick`
;
//
console.info(qfang_url_chaxun);
// const data = {
// userName: '',
// gardenId: '',
...
...
@@ -221,6 +232,10 @@ class ToolController extends Controller {
// await this.httprequest(qfang_url_chaxun, data);
// return;
const
ret1
=
await
ctx
.
curl
(
qfang_url_area
,
{
method
:
'POST'
});
if
(
ret1
.
status
!==
200
){
ctx
.
failed
(
'暂不支持该城市'
);
}
// ctx.success(ret1); return;
const
headers
=
ret1
.
headers
;
const
cookies
=
headers
[
'set-cookie'
];
let
cookie
=
''
;
...
...
@@ -335,13 +350,26 @@ class ToolController extends Controller {
const
input_parmas
=
ctx
.
query
;
const
rule
=
{
keyword
:
{
type
:
'string'
,
required
:
true
},
area_code
:
{
type
:
'string'
,
required
:
true
},
}
ctx
.
validate
(
rule
,
input_parmas
);
const
qfang_url
=
'https://hangzhou.qfang.com/fangjia/getGarden'
;
const
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
input_parmas
.
area_code
}
});
if
(
!
city
||
!
city
.
pinyin
||
Object
.
keys
(
city
).
length
===
0
)
{
ctx
.
failed
(
'暂不支持城市'
);
}
const
city_pinyin_array
=
city
.
pinyin
.
split
(
' '
);
let
city_pinyin
=
''
;
for
(
let
i
=
0
;
i
<
city_pinyin_array
.
length
-
1
;
i
++
)
{
const
pinyin
=
city_pinyin_array
[
i
];
city_pinyin
+=
pinyin
;
};
const
qfang_url
=
`https://
${
city_pinyin
}
.qfang.com/fangjia/getGarden`
;
const
keyword
=
encodeURIComponent
(
input_parmas
.
keyword
);
const
result
=
await
ctx
.
helper
.
send_request
(
qfang_url
+
'?keyword='
+
keyword
,
{},
{
dataType
:
'json'
});
let
ret
=
[];
if
(
result
.
status
!==
200
){
ctx
.
failed
(
'暂不支持该城市'
);
}
if
(
result
.
status
===
200
&&
result
.
data
&&
result
.
data
.
items
)
{
const
residential_items
=
result
.
data
.
items
;
for
(
let
i
in
residential_items
)
{
...
...
app/model/block/city.js
View file @
93906451
...
...
@@ -13,6 +13,7 @@ module.exports = app => {
code
:
INTEGER
,
level
:
INTEGER
,
parent
:
INTEGER
,
pinyin
:
STRING
,
fword
:
STRING
,
hot
:
INTEGER
,
},
{
...
...
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