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
75bcbe6a
Commit
75bcbe6a
authored
Apr 25, 2019
by
李尚科
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
house tool f
parent
93906451
Pipeline
#6448
passed with stage
in 5 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
26 deletions
+37
-26
tool.js
app/controller/house/tool.js
+37
-26
No files found.
app/controller/house/tool.js
View file @
75bcbe6a
...
@@ -189,19 +189,20 @@ class ToolController extends Controller {
...
@@ -189,19 +189,20 @@ class ToolController extends Controller {
direction_str
:
{
type
:
'string'
,
required
:
true
},
direction_str
:
{
type
:
'string'
,
required
:
true
},
floor
:
{
type
:
'string'
,
required
:
true
},
floor
:
{
type
:
'string'
,
required
:
true
},
total_floor
:
{
type
:
'string'
,
required
:
true
},
total_floor
:
{
type
:
'string'
,
required
:
true
},
area_code
:
{
type
:
'string'
,
required
:
true
},
city_py
:
{
type
:
'string'
,
required
:
true
},
};
};
ctx
.
validate
(
rule
,
input_params
);
ctx
.
validate
(
rule
,
input_params
);
const
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
input_params
.
area_code
}
});
// const city = await ctx.blockModel.City.one({ where: { code: input_params.area_code } });
if
(
!
city
||
!
city
.
pinyin
||
Object
.
keys
(
city
).
length
===
0
)
{
// if (!city || !city.pinyin || Object.keys(city).length === 0) {
ctx
.
failed
(
'暂不支持城市'
);
// ctx.failed('暂不支持城市');
}
// }
const
city_pinyin_array
=
city
.
pinyin
.
split
(
' '
);
// const city_pinyin_array = city.pinyin.split(' ');
let
city_pinyin
=
''
;
// let city_pinyin = '';
for
(
let
i
=
0
;
i
<
city_pinyin_array
.
length
-
1
;
i
++
)
{
// for (let i = 0; i < city_pinyin_array.length - 1; i++) {
const
pinyin
=
city_pinyin_array
[
i
];
// const pinyin = city_pinyin_array[i];
city_pinyin
+=
pinyin
;
// city_pinyin += pinyin;
};
// };
const
city_pinyin
=
input_params
.
city_py
;
const
residential_id
=
input_params
.
residential_id
;
const
residential_id
=
input_params
.
residential_id
;
const
residential_name
=
input_params
.
residential_name
;
const
residential_name
=
input_params
.
residential_name
;
const
area
=
input_params
.
area
;
const
area
=
input_params
.
area
;
...
@@ -231,10 +232,13 @@ class ToolController extends Controller {
...
@@ -231,10 +232,13 @@ class ToolController extends Controller {
// await this.httprequest(qfang_url_chaxun, data);
// await this.httprequest(qfang_url_chaxun, data);
// return;
// return;
const
ret1
=
await
ctx
.
curl
(
qfang_url_area
,
{
method
:
'POST'
});
let
ret1
;
if
(
ret1
.
status
!==
200
){
try
{
ret1
=
await
ctx
.
curl
(
qfang_url_area
,
{
method
:
'POST'
});
}
catch
(
error
)
{
ctx
.
failed
(
'暂不支持该城市'
);
ctx
.
failed
(
'暂不支持该城市'
);
}
}
// ctx.success(ret1); return;
// ctx.success(ret1); return;
const
headers
=
ret1
.
headers
;
const
headers
=
ret1
.
headers
;
const
cookies
=
headers
[
'set-cookie'
];
const
cookies
=
headers
[
'set-cookie'
];
...
@@ -350,24 +354,31 @@ class ToolController extends Controller {
...
@@ -350,24 +354,31 @@ class ToolController extends Controller {
const
input_parmas
=
ctx
.
query
;
const
input_parmas
=
ctx
.
query
;
const
rule
=
{
const
rule
=
{
keyword
:
{
type
:
'string'
,
required
:
true
},
keyword
:
{
type
:
'string'
,
required
:
true
},
area_code
:
{
type
:
'string'
,
required
:
true
},
city_py
:
{
type
:
'string'
,
required
:
true
},
}
}
ctx
.
validate
(
rule
,
input_parmas
);
ctx
.
validate
(
rule
,
input_parmas
);
const
city
=
await
ctx
.
blockModel
.
City
.
one
({
where
:
{
code
:
input_parmas
.
area_code
}
});
// const city = await ctx.blockModel.City.one({ where: { code: input_parmas.area_code } });
if
(
!
city
||
!
city
.
pinyin
||
Object
.
keys
(
city
).
length
===
0
)
{
// if (!city || !city.pinyin || Object.keys(city).length === 0) {
ctx
.
failed
(
'暂不支持城市'
);
// ctx.failed('暂不支持城市');
}
// }
const
city_pinyin_array
=
city
.
pinyin
.
split
(
' '
);
// const city_pinyin_array = city.pinyin.split(' ');
let
city_pinyin
=
''
;
// let city_pinyin = '';
for
(
let
i
=
0
;
i
<
city_pinyin_array
.
length
-
1
;
i
++
)
{
// for (let i = 0; i < city_pinyin_array.length - 1; i++) {
const
pinyin
=
city_pinyin_array
[
i
];
// const pinyin = city_pinyin_array[i];
city_pinyin
+=
pinyin
;
// city_pinyin += pinyin;
};
// };
const
city_pinyin
=
input_parmas
.
city_py
;
const
qfang_url
=
`https://
${
city_pinyin
}
.qfang.com/fangjia/getGarden`
;
const
qfang_url
=
`https://
${
city_pinyin
}
.qfang.com/fangjia/getGarden`
;
const
keyword
=
encodeURIComponent
(
input_parmas
.
keyword
);
const
keyword
=
encodeURIComponent
(
input_parmas
.
keyword
);
const
result
=
await
ctx
.
helper
.
send_request
(
qfang_url
+
'?keyword='
+
keyword
,
{},
{
dataType
:
'json'
});
let
result
;
try
{
result
=
await
ctx
.
helper
.
send_request
(
qfang_url
+
'?keyword='
+
keyword
,
{},
{
dataType
:
'json'
});
}
catch
(
error
)
{
ctx
.
failed
(
'暂不支持该城市'
);
}
let
ret
=
[];
let
ret
=
[];
if
(
result
.
status
!==
200
)
{
if
(
result
.
status
!==
200
)
{
ctx
.
failed
(
'暂不支持该城市'
);
ctx
.
failed
(
'暂不支持该城市'
);
}
}
if
(
result
.
status
===
200
&&
result
.
data
&&
result
.
data
.
items
)
{
if
(
result
.
status
===
200
&&
result
.
data
&&
result
.
data
.
items
)
{
...
...
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