换成了系统定位

This commit is contained in:
2020-11-23 16:32:54 +08:00
parent 22e93bcdaa
commit 9cefed9bfe
3 changed files with 59 additions and 21 deletions

View File

@@ -1039,28 +1039,62 @@ export async function luzhi(roomid: string){
console.log(res)
}
export async function getaddr() {
const res = await get<any>('ip');
const gj = res.data.address.split("|")[0];
const lan = getValue("Lanvuage");
const qh = await get<any>('countryCode', {
longitude: res.data.content.point.x,
latitude: res.data.content.point.y
});
console.log(qh)
if(lan != null && lan){
if(gj == "CN"){
return {hb: '人民币¥', qh};
}else {
return {hb: '美元$'}
export function getaddr() {
return new Promise((r)=>{
console.log("开始定位")
const lan = getValue("Lanvuage");
if ("geolocation" in navigator) {
/* 地理位置服务可用 */
navigator.geolocation.getCurrentPosition(async (res) => {
console.log(res, 'res')
const qh = await get<any>('countryCode', {
longitude: res.coords.longitude,
latitude: res.coords.latitude
});
console.log(qh)
if(lan != null && lan){
if(qh.data.ename == "China"){
r({hb: '人民币¥', qh});
}else {
r({hb: '美元$'})
}
}else{
if(qh.data.ename == "China"){
r({yy: "zh", yyx: "中文", hb: '人民币¥', qh});
}else {
r({yy: 'en', yyx: 'English', hb: '美元$', qh})
}
}
},(err) => {
console.log(err, 'err')
})
} else {
/* 地理位置服务不可用 */
console.log("无法定位")
}
}else{
if(gj == "CN"){
return {yy: "zh", yyx: "中文", hb: '人民币¥', qh};
}else {
return {yy: 'en', yyx: 'English', hb: '美元$', qh}
}
}
})
// const res = await get<any>('ip');
// const gj = res.data.address.split("|")[0];
// const lan = getValue("Lanvuage");
// const qh = await get<any>('countryCode', {
// longitude: res.data.content.point.x,
// latitude: res.data.content.point.y
// });
// console.log(qh)
// if(lan != null && lan){
// if(gj == "CN"){
// return {hb: '人民币¥', qh};
// }else {
// return {hb: '美元$'}
// }
// }else{
// if(gj == "CN"){
// return {yy: "zh", yyx: "中文", hb: '人民币¥', qh};
// }else {
// return {yy: 'en', yyx: 'English', hb: '美元$', qh}
// }
// }
}