区号自动获取

This commit is contained in:
luyuan 2020-11-18 09:40:56 +08:00
parent 0d6a2329d4
commit c73f45d27e
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
5 changed files with 39 additions and 18 deletions

View File

@ -1022,17 +1022,22 @@ 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 ['人民币¥'];
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}
}
}

View File

@ -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]);

View File

@ -23,7 +23,7 @@
</a-select-option>
<a-select-option value="Jiangsu"> Jiangsu </a-select-option>
</a-select> -->
<a-select :default-value="quhaolist[0].name + '+' + quhaolist[0].code" size="small" option-label-prop="label" @change="getquhao" class="getcode" show-search >
<a-select :default-value="mrqh.name + '+' + mrqh.code" size="small" option-label-prop="label" @change="getquhao" class="getcode" show-search >
<a-select-option v-for="(i,j) in quhaolist" :key="j" :value="i.name + '+' + i.code" :label="'+' + i.code">
{{i.name}}+{{i.code}}
</a-select-option>
@ -117,13 +117,14 @@
</template>
<script lang="ts">
import { defineComponent, onMounted, reactive, ref } from "vue";
import { computed, defineComponent, onMounted, reactive, ref } from "vue";
import LoginTab from "@/components/login/LoginTab.vue";
import NavTop from "@/components/NavTop.vue"
import { checksmscode, getquhaolist, getwebvideolist, loginpass, sendsms } from '@/api';
import { message } from 'ant-design-vue';
import router from '@/router';
import { useI18n } from '@/utils/i18n';
import store from '@/store';
export default defineComponent({
name: "Login",
@ -146,6 +147,7 @@ export default defineComponent({
phone: '13152639856',
password: '123456'
})
const mrqh = computed(() => store.state.qh)
const quhaolist = ref<any>([
{
code: "86",
@ -281,7 +283,8 @@ export default defineComponent({
tovideoxq,
navto,
lan,
slogin
slogin,
mrqh
};
},
});

View File

@ -23,7 +23,7 @@
>
<a-input-group compact>
<a-select
:default-value="quhaolist[0].name + '+' + quhaolist[0].code"
:default-value="mrqh.name + '+' + mrqh.code"
size="small"
@change="getquhao"
class="getcode"
@ -221,7 +221,7 @@
</template>
<script lang="ts">
import { defineComponent, onMounted, reactive, ref, toRaw } from "vue";
import { computed, defineComponent, onMounted, reactive, ref, toRaw } from "vue";
import NavTop from "@/components/NavTop.vue";
import {
checksmscode,
@ -235,6 +235,7 @@ import {
import { message } from "ant-design-vue";
import router from "@/router";
import { useI18n } from "@/utils/i18n";
import store from '@/store';
export default defineComponent({
name: "Sign",
@ -260,6 +261,7 @@ export default defineComponent({
jiaoshou: "",
});
const willsay = ref<any>();
const mrqh = computed(() => store.state.qh)
const quhaolist = ref<any>([
{
code: "86",
@ -426,7 +428,8 @@ export default defineComponent({
navto,
lan,
quhaolist,
getquhao
getquhao,
mrqh
};
},
});

View File

@ -383,7 +383,7 @@
<!-- <a-input size="small" v-model:value="bindPhone.number" /> -->
<a-input-group compact class="telbox">
<a-select
:default-value="quhaolist[0].name + '+' + quhaolist[0].code"
:default-value="mrqh.name + '+' + mrqh.code"
size="small"
@change="getquhao"
option-label-prop="label"
@ -574,6 +574,8 @@ export default defineComponent({
const chiveslist = ref<any>([[], []]);
const languages = ref<unknown>([]);
const quhaolist = ref<any>([]);
const mrqh = computed(() => store.state.qh)
const myquhao = ref<string>("");
const mynewtel = ref<string>("");
@ -1056,7 +1058,8 @@ export default defineComponent({
isdisabled,
setname,
video,
imgs
imgs,
mrqh
};
},
});