Commit 4e84bee6 authored by 陈颖's avatar 陈颖

~

parent 0391ab30
Pipeline #48653 passed with stage
in 1 minute 31 seconds
...@@ -186,13 +186,9 @@ module.exports = { ...@@ -186,13 +186,9 @@ module.exports = {
}, },
async getGPS(address, city) { async getGPS(address, city) {
console.info(address); const txmap = await this.getTaskAddress(city + address);
const baidu_url = 'https://api.map.baidu.com/geocoder/v2/'; if (Object.keys(txmap).length !== 0 && txmap !== '未知') {
const result = await this.send_request(baidu_url, { address, output: 'json', ak: 'kpqBbfkKx9HvdhfAAEybyy0ATwaZgimI', city }, { method: 'GET' }); return txmap.location;
console.info(result);
const ret = result.data;
if (ret && ret.status === 0 && ret.result && ret.result.location) {
return ret.result.location;
} }
return { lng: 0, lat: 0 }; return { lng: 0, lat: 0 };
}, },
...@@ -239,6 +235,27 @@ module.exports = { ...@@ -239,6 +235,27 @@ module.exports = {
return ret.data; return ret.data;
}, },
async getTaskAddress(address) {
const { ctx, app } = this;
const url = `${app.config.NODE_BASE_URL}/apply/task-address`;
const data = {
address,
key: app.config.TencentIpKey,
};
const ret = await ctx.curl(url, {
method: 'POST',
data,
dataType: 'json',
contentType: 'json',
});
app.logger.info(JSON.stringify({ url, status: ret.status, res: ret.data }));
if (ret.status !== 200) {
return {};
}
return ret.data;
},
async check_submit_frequent(redis_key, expire = 5) { async check_submit_frequent(redis_key, expire = 5) {
const { ctx, app } = this; const { ctx, app } = this;
const redis_value = await app.memcache.get(redis_key); const redis_value = await app.memcache.get(redis_key);
......
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