/**获取当前登录的ip */ export async function getUserIP(callback) { await fetch('https://qifu-api.baidubce.com/ip/local/geo/v1/district?').then(function (response) { return response.json(); }).then(function (data) { callback(data.ip); }).catch(function (error) { console.log('Error:', error); }) } // 获取当前登录的地理位置 经纬度 export async function getUserLocation(ipInfo, callback) { await fetch(`https://ipapi.co/${ipInfo}/json`) .then(response => response.json()) .then(data => { callback(data); // 打印地理位置信息 经纬度 // console.log(data.latitude); // console.log(data.longitude); }) .catch(error => console.log(error)); } // 获取当前登录的地理 信息 export async function getAddressLocation(ipInfo, callback) { // await fetch(`https://qifu-api.baidubce.com/ip/geo/v1/district?ip=${ipInfo}`) // await fetch(`http://ip-api.com/json/${ipInfo}?lang=zh-CN`) await fetch(`http://demo.ip-api.com/json/${ipInfo}?fields=66842623&lang=zh-CN `) // const headers = new Headers({ // 'Authorization': 'APPCODE 1408028eb249479cbeeb9d20f611db79' // }); // await fetch(`https://c2ba.api.huachen.cn/ip?ip=${ipInfo}`,{ // headers: headers, // }) .then(response => response.json()) .then(res => { if (res.ret === 200) { callback({ ...res.data, prov: res.data.region }); } }) .catch(error => console.log(error)); }