Commit 26f5678b authored by 李尚科's avatar 李尚科

add tool house point

parent 4f117690
Pipeline #8961 passed with stage
in 19 seconds
......@@ -7,6 +7,17 @@ class HomeController extends Controller {
const { ctx } = this;
ctx.body = 'hi, egg';
}
async setCookie(){
const {ctx} = this;
const expire = 7200 * 1000;
const date = new Date();
ctx.cookies.set('auth_token', '0f42a68d19ef161a7c7665488e625ba8', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
ctx.cookies.set('jianbing_customer_id', '815209', { httpOnly: false, signed: false, maxAge: expire, expires: date, path: '/' });
ctx.success(ctx.cookies);
}
}
module.exports = HomeController;
......@@ -117,6 +117,60 @@ class ToolController extends Controller {
ctx.success({ results: ret });
}
//存钱罐推荐的楼盘跳转到地图页 获取点位信息给前端
async getHousePoint() {
const { ctx } = this;
const house_id = ctx.query.house_id;
console.info(house_id);
const new_house = await ctx.realestateModel.NewHouse.one({ where: { id: house_id } });
const new_house_name = new_house.name;
const map_house = await ctx.blockModel.HouseNewHousePriceMap2.one({ where: { name: new_house_name } });
let result = {};
if (map_house && map_house.id) {
result = {
name: map_house.name,
longitude: map_house.longitude,
latitude: map_house.latitude,
price: map_house.price,
unit: map_house.unit,
}
} else {
const city_codes = [new_house.province, new_house.city, new_house.area];
const cities = await ctx.blockModel.City.all({ where: { code: { $in: city_codes } } });
const city = (cities && cities[1] && cities[1].name) ? cities[1].name : '';
const address = R.pluck('name', cities).join('') + new_house.address;
const gps_info = await ctx.helper.getGPS(address, city);
if (gps_info.lng && gps_info.lat) {
result = {
name: new_house_name,
longitude: gps_info.lng,
latitude: gps_info.lat,
price: new_house.reference_avg_price,
unit: '元/平',
}
}
}
ctx.success({ result });
}
async getHouseNearbyPoint() {
const { ctx } = this;
const input_parmas = ctx.request.body;
const rule = {
right_corner_gps: { type: 'string', required: true },
left_corner_gps: { type: 'string', required: true },
}
ctx.validate(rule, input_parmas);
const right_point = ctx.helper.checkGps(input_parmas.right_corner_gps).split(',');
const left_point = ctx.helper.checkGps(input_parmas.left_corner_gps).split(',');
const house_nearby_points = await ctx.blockModel.HouseNewHousePriceMap2.all({ where: { longitude: { $between: [left_point[1], right_point[1]] }, latitude: { $between: [left_point[0], right_point[0]] } } });
const results = house_nearby_points.map(item => { return { name: item.name, longitude: item.longitude, latitude: item.latitude, price: item.price, unit: item.unit } });
ctx.success({ results });
}
//生成购房计划
async generateBuyHousePlan() {
......
......@@ -127,6 +127,21 @@ module.exports = {
//校验经纬度 部分存入的gps地址经纬度混乱,输出使用时进行校验修复
//longitude 经线 latitude 纬度 纬度从南到北,范围为-90 - 90
//示例:北纬N29°57′28.20″ 东经E119°42′32.30″ gps:29.9578340000,119.7089730000
checkGps(gps) {
if (!gps || gps.indexOf(',') === -1) {
return '';
}
let gps_arr = gps.split(',');
if (Math.abs(gps_arr[0]) >= 90) {
gps_arr.reverse();
gps = gps_arr.join(',');
};
return gps;
},
async parseGps(gps) {
if (!gps || gps.indexOf(',') === -1) {
......@@ -245,11 +260,11 @@ module.exports = {
return array;
},
// 获取客户端IP
// 获取客户端IP
getClientIP() {
const { ctx } = this;
const ips = ctx.request.header['x-forwarded-for'];
const ipList = ips ? ips.split(',') : [ '' ];
const ipList = ips ? ips.split(',') : [''];
const ip = ipList[0];
return ip;
},
......
......@@ -7,6 +7,7 @@ module.exports = app => {
const { controller } = app;
const router = app.router.namespace(app.config.projectRootPath);
router.get('/', controller.home.index);
// router.get('/home/setCookie', controller.home.setCookie);
require('./router/gjj')(app);
......
......@@ -54,9 +54,10 @@ module.exports = app => {
router.post('/v2/tool/calculate_price', 'house.tool.calculateHousePrice');//房产估价
router.get('/v2/tool/qfang_area_list', 'house.tool.getQFangAreaList');//房产估价模糊匹配到的小区列表
router.get('/v2/tool/map_houses', 'house.tool.getMapHouses');//房产估价模糊匹配到的小区列表
router.get('/v2/tool/house_price_feature_city', 'house.v2.tool.getHousePriceFeatureCity');//房产估价模糊匹配到的小区列表
router.get('/v2/tool/house_price_city', 'house.v2.tool.getHousePriceCity');//房产估价模糊匹配到的小区列表
router.get('/v2/tool/house_price_feature_city', 'house.v2.tool.getHousePriceFeatureCity');//房价指数 城市月参考价支持的城市
router.get('/v2/tool/house_price_city', 'house.v2.tool.getHousePriceCity');//房价指数 城市月参考价
router.get('/v2/tool/house_point', 'house.v2.tool.getHousePoint');//点击房源信息跳到地图页 需要的经纬度信息。
router.post('/v2/tool/nearby_house_points', 'house.v2.tool.getHouseNearbyPoint');//点击房源信息跳到地图页 此房源周边信息。
//租房列表
......
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