diff --git a/src/api/index.ts b/src/api/index.ts index 3e83d88..aa2cfc0 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1022,17 +1022,22 @@ export async function getaddr() { const res = await get('ip'); const gj = res.data.address.split("|")[0]; const lan = getValue("Lanvuage"); + const qh = await get('countryCode', { + longitude: res.data.content.point.x, + latitude: res.data.content.point.y + }); + console.log(qh) if(lan != null && lan){ if(gj == "CN"){ - return ['人民币¥']; + return {hb: '人民币¥', qh}; }else { - return [ '美元$'] + return {hb: '美元$'} } }else{ if(gj == "CN"){ - return ["zh", "中文", '人民币¥']; + return {yy: "zh", yyx: "中文", hb: '人民币¥', qh}; }else { - return ['en', 'English', '美元$'] + return {yy: 'en', yyx: 'English', hb: '美元$', qh} } } diff --git a/src/store/index.ts b/src/store/index.ts index 8ca4f4d..5eed3e6 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,6 +1,7 @@ import { getaddr, userinfo } from '@/api'; import { setLanvuage } from '@/api/base'; import { getValue, saveValue } from '@/utils/common'; +import { geti18n } from '@/utils/i18n'; import { isProxy } from 'vue'; import { createStore } from 'vuex' @@ -62,6 +63,11 @@ export default createStore({ symbol: "", timeCeiling: "", timeLowerLimit: "", + }, + qh: { + code: "86", + ename: "China", + name: "中国", } }, mutations: { @@ -81,19 +87,20 @@ export default createStore({ const split = new Date().toString().split(" "); const timeZoneFormatted = split[split.length - 2] + " " + split[split.length - 1]; const lan = getValue("Lanvuage"); + state.qh = data.qh.data; if(lan != null && lan){ // state.userinfo.language = data[1] // English 中文 // state.userinfo.languageValue = data[0] // 'en' 'zh' state.userinfo.zoneStr = timeZoneFormatted; - state.userinfo.currency = data[0]; + state.userinfo.currency = data.hb; }else{ console.log(data, 111) - state.userinfo.language = data[1] // English 中文 - state.userinfo.languageValue = data[0] // 'en' 'zh' + state.userinfo.language = data.yyx // English 中文 + state.userinfo.languageValue = data.yy // 'en' 'zh' state.userinfo.zoneStr = timeZoneFormatted; - state.userinfo.currency = data[2]; - saveValue("Lanvuage", data[0]); - if( data[0] != 'zh'){ + state.userinfo.currency = data.hb; + saveValue("Lanvuage", data.yx); + if( data.yx != geti18n().$s()){ location.reload() } // setLanvuage(data[0]); diff --git a/src/views/login/Login.vue b/src/views/login/Login.vue index 1d88dd2..e8dc5ce 100644 --- a/src/views/login/Login.vue +++ b/src/views/login/Login.vue @@ -23,7 +23,7 @@ Jiangsu --> - + {{i.name}}+{{i.code}} @@ -117,13 +117,14 @@