amap的geocode接口增加了city参数
This commit is contained in:
parent
af02b5a4f8
commit
f64acd8a05
|
|
@ -18,5 +18,6 @@ export declare class AmapInstance {
|
|||
}): Promise<any>;
|
||||
geocode(data: {
|
||||
address: string;
|
||||
city?: string;
|
||||
}): Promise<any>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,8 +70,8 @@ export class AmapInstance {
|
|||
return jsonData;
|
||||
}
|
||||
async geocode(data) {
|
||||
const { address } = data;
|
||||
const url = `https://restapi.amap.com/v3/geocode/geo?address=${address}&key=${this.key}`;
|
||||
const { address, city } = data;
|
||||
const url = `https://restapi.amap.com/v3/geocode/geo?address=${address}${city ? `$city=${city}` : ''}&key=${this.key}`;
|
||||
let response;
|
||||
try {
|
||||
response = await global.fetch(url);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ export class WechatMpInstance {
|
|||
const { type, media, filetype, filename } = options;
|
||||
const formData = new FormData();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename, // 微信识别需要
|
||||
});
|
||||
const getLength = () => {
|
||||
|
|
@ -332,7 +332,7 @@ export class WechatMpInstance {
|
|||
body: JSON.stringify({
|
||||
jump_wxa: jump_wxa,
|
||||
is_expire: true,
|
||||
expire_type: expireType, //默认是零,到期失效的 scheme 码失效类型,失效时间类型:0,失效间隔天数类型:1
|
||||
expire_type: expireType,
|
||||
expire_time: expiresAt,
|
||||
expire_interval: expireInterval,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -511,8 +511,8 @@ export class WechatPublicInstance {
|
|||
const { type, media, description, filetype, filename, fileLength } = options;
|
||||
const formData = new FormData();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
filename: filename, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename,
|
||||
knownLength: fileLength,
|
||||
});
|
||||
if (type === 'video') {
|
||||
|
|
@ -535,8 +535,8 @@ export class WechatPublicInstance {
|
|||
const { media, filetype, filename, fileLength } = options;
|
||||
const formData = new FormData();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
filename: filename, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename,
|
||||
knownLength: fileLength,
|
||||
});
|
||||
const headers = formData.getHeaders();
|
||||
|
|
@ -556,8 +556,8 @@ export class WechatPublicInstance {
|
|||
const { type, media, filetype, filename, fileLength } = options;
|
||||
const formData = new FormData();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
filename: filename, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename,
|
||||
knownLength: fileLength,
|
||||
});
|
||||
const headers = formData.getHeaders();
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@ export declare class AmapInstance {
|
|||
}): Promise<any>;
|
||||
geocode(data: {
|
||||
address: string;
|
||||
city?: string;
|
||||
}): Promise<any>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ class AmapInstance {
|
|||
return jsonData;
|
||||
}
|
||||
async geocode(data) {
|
||||
const { address } = data;
|
||||
const url = `https://restapi.amap.com/v3/geocode/geo?address=${address}&key=${this.key}`;
|
||||
const { address, city } = data;
|
||||
const url = `https://restapi.amap.com/v3/geocode/geo?address=${address}${city ? `$city=${city}` : ''}&key=${this.key}`;
|
||||
let response;
|
||||
try {
|
||||
response = await global.fetch(url);
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class WechatMpInstance {
|
|||
const { type, media, filetype, filename } = options;
|
||||
const formData = new form_data_1.default();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename, // 微信识别需要
|
||||
});
|
||||
const getLength = () => {
|
||||
|
|
@ -336,7 +336,7 @@ class WechatMpInstance {
|
|||
body: JSON.stringify({
|
||||
jump_wxa: jump_wxa,
|
||||
is_expire: true,
|
||||
expire_type: expireType, //默认是零,到期失效的 scheme 码失效类型,失效时间类型:0,失效间隔天数类型:1
|
||||
expire_type: expireType,
|
||||
expire_time: expiresAt,
|
||||
expire_interval: expireInterval,
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -515,8 +515,8 @@ class WechatPublicInstance {
|
|||
const { type, media, description, filetype, filename, fileLength } = options;
|
||||
const formData = new form_data_1.default();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
filename: filename, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename,
|
||||
knownLength: fileLength,
|
||||
});
|
||||
if (type === 'video') {
|
||||
|
|
@ -539,8 +539,8 @@ class WechatPublicInstance {
|
|||
const { media, filetype, filename, fileLength } = options;
|
||||
const formData = new form_data_1.default();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
filename: filename, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename,
|
||||
knownLength: fileLength,
|
||||
});
|
||||
const headers = formData.getHeaders();
|
||||
|
|
@ -560,8 +560,8 @@ class WechatPublicInstance {
|
|||
const { type, media, filetype, filename, fileLength } = options;
|
||||
const formData = new form_data_1.default();
|
||||
formData.append('media', media, {
|
||||
contentType: filetype, // 微信识别需要
|
||||
filename: filename, // 微信识别需要
|
||||
contentType: filetype,
|
||||
filename: filename,
|
||||
knownLength: fileLength,
|
||||
});
|
||||
const headers = formData.getHeaders();
|
||||
|
|
|
|||
|
|
@ -97,9 +97,9 @@ export class AmapInstance {
|
|||
return jsonData;
|
||||
}
|
||||
|
||||
async geocode(data: { address: string }) {
|
||||
const { address } = data;
|
||||
const url = `https://restapi.amap.com/v3/geocode/geo?address=${address}&key=${this.key}`;
|
||||
async geocode(data: { address: string, city?: string }) {
|
||||
const { address, city } = data;
|
||||
const url = `https://restapi.amap.com/v3/geocode/geo?address=${address}${city ? `$city=${city}` : ''}&key=${this.key}`;
|
||||
let response: Response;
|
||||
try {
|
||||
response = await global.fetch(url);
|
||||
|
|
|
|||
Loading…
Reference in New Issue