Commit 24609d70 authored by 李尚科's avatar 李尚科

add map house list

parent 0add987e
...@@ -59,6 +59,67 @@ const USER_AGENT = [ ...@@ -59,6 +59,67 @@ const USER_AGENT = [
]; ];
class ToolController extends Controller { class ToolController extends Controller {
async getMapHouses() {
const { ctx } = this;
const input_parmas = ctx.query;
const rule = {
house_style: { type: 'string', required: true },
keyword: { type: 'string', required: true },
page: { type: 'string', required: false },
}
ctx.validate(rule, input_parmas);
const house_style = input_parmas.house_style;
const keyword = input_parmas.keyword;
const page = input_parmas.page;
const where = { where: { name: { $like: `%${keyword}%` } }, page: page };
let results = [];
let map_houses_results;
if (house_style === 'used_house') {
map_houses_results = await ctx.blockModel.HousePriceMap3.list(where);
const map_houses = map_houses_results.rows;
for (let i in map_houses) {
const item = map_houses[i];
if (('price' in item) && !item.price) {
continue;
}
results.push({
id: item.id,
name: item.name,
longitude: item.longitude,
latitude: item.latitude,
price: item.price,
unit: item.unit || '元/平',
level: 3,
});
}
} else if (house_style === 'new_house') {
map_houses_results = await ctx.blockModel.HouseNewHousePriceMap2.list(where);
const map_houses = map_houses_results.rows;
for (let i in map_houses) {
const item = map_houses[i];
if (('price' in item) && !item.price) {
continue;
}
if (('count' in item) && !item.count) {
continue;
}
results.push({
id: item.id,
name: item.name,
longitude: item.longitude,
latitude: item.latitude,
price: item.price,
count: item.count,
unit: item.unit || '个楼盘',
level: 2,
});
}
}
ctx.success({ results, count: map_houses_results.count, page: map_houses_results.page });
}
//获取地图上的点位 //获取地图上的点位
async getMapPoint() { async getMapPoint() {
const { ctx } = this; const { ctx } = this;
......
...@@ -9,6 +9,7 @@ module.exports = app => { ...@@ -9,6 +9,7 @@ module.exports = app => {
router.get('/tool/:type/:area_code', 'house.tool.getHousePriceFeature');//房价指数 房价涨跌 购房资格、贷款额度问答 router.get('/tool/:type/:area_code', 'house.tool.getHousePriceFeature');//房价指数 房价涨跌 购房资格、贷款额度问答
router.post('/tool/calculate_price', 'house.tool.calculateHousePrice');//房产估价 router.post('/tool/calculate_price', 'house.tool.calculateHousePrice');//房产估价
router.get('/tool/qfang_area_list', 'house.tool.getQFangAreaList');//房产估价模糊匹配到的小区列表 router.get('/tool/qfang_area_list', 'house.tool.getQFangAreaList');//房产估价模糊匹配到的小区列表
router.get('/tool/map_houses', 'house.tool.getMapHouses');//房产估价模糊匹配到的小区列表
//租房 //租房
router.get('/rental_house/home', 'house.rentalHouse.home');//租房首页信息 router.get('/rental_house/home', 'house.rentalHouse.home');//租房首页信息
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment