168 lines
4.4 KiB
TypeScript
168 lines
4.4 KiB
TypeScript
import { getaddr, getarticle, personalCenterData, 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'
|
|
|
|
export default createStore({
|
|
state: {
|
|
userinfo:{
|
|
accesstoken: "",
|
|
apiToken: "",
|
|
birthday: "",
|
|
country: "",
|
|
countryValue: "",
|
|
cover: "",
|
|
code:"",
|
|
createdAt: "",
|
|
currency: "",
|
|
currencyValue: "",
|
|
deletedAt: null,
|
|
desc: "",
|
|
email: "",
|
|
img: "",
|
|
interest: "",
|
|
language: "中文",
|
|
languageValue: "zh",
|
|
live: "",
|
|
livetime: "",
|
|
loginType: 0,
|
|
memberid: 0,
|
|
mobile: "",
|
|
money: "",
|
|
moneyValue: 0,
|
|
msg: "",
|
|
mtongue: "",
|
|
name: "",
|
|
password: "",
|
|
position: 0,
|
|
publish: 0,
|
|
score: "",
|
|
status: false,
|
|
tlanguage: "中文",
|
|
tlanguageValue: 1,
|
|
type: 1,
|
|
uid: "",
|
|
updatedAt: "",
|
|
video: "",
|
|
videoid: "",
|
|
willsay: [{name: "请选择", level: 0}],
|
|
willsayValue: [{name: "0", level: 0}],
|
|
zoneStr: "中途岛GMT-11:00",
|
|
zoneid: 1,
|
|
symbol: "$",
|
|
zoneValue: "Atlantic/South_Georgia",
|
|
currencytag: 0
|
|
},
|
|
islogin: false,
|
|
seting:{
|
|
lowerLimit: "",
|
|
minmoney: 0,
|
|
minwithdraw: "",
|
|
numberCeiling: "",
|
|
sxf: "",
|
|
symbol: "",
|
|
timeCeiling: "",
|
|
timeLowerLimit: "",
|
|
views:0,
|
|
releaseLiveDay: ""
|
|
},
|
|
qh: {
|
|
code: "",
|
|
ename: "",
|
|
name: "",
|
|
},
|
|
infotext:[{title:"",content:""},{title:"",content:""}],
|
|
indexarr:{countries:{},willsay:{},timezones:{},phonecodes:{},currencys:{},interests:{},language:{}}
|
|
},
|
|
mutations: {
|
|
setseting(state, info){
|
|
console.log(info, 112)
|
|
state.seting = info
|
|
},
|
|
setUserInfo(state, userinfo){
|
|
userinfo.money = userinfo.money.toString()
|
|
state.userinfo = userinfo
|
|
state.islogin = true;
|
|
},
|
|
login(state, islogin: boolean){
|
|
state.islogin = islogin;
|
|
},
|
|
setLanguage(state, data){
|
|
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.hb;
|
|
}else{
|
|
console.log(data, 111)
|
|
state.userinfo.language = data.yyx // English 中文
|
|
state.userinfo.languageValue = data.yy // 'en' 'zh'
|
|
state.userinfo.zoneStr = timeZoneFormatted;
|
|
state.userinfo.currency = data.hb;
|
|
saveValue("Lanvuage", data.yy);
|
|
if( data.yy != geti18n().$s()){
|
|
location.reload()
|
|
}
|
|
// setLanvuage(data[0]);
|
|
}
|
|
|
|
},
|
|
setquhao(state, data){
|
|
state.qh = data.qh.data;
|
|
},
|
|
setWlan(state){
|
|
const lan = getValue("Lanvuage");
|
|
if(lan != null && lan){
|
|
state.userinfo.languageValue = !getValue("Lanvuage") ? 'zh' : getValue("Lanvuage");
|
|
state.userinfo.language = (!getValue("Lanvuage") ? 'zh' : getValue("Lanvuage")) == 'zh' ? '中文' : 'English';
|
|
}
|
|
},
|
|
setinfotext(state, data){
|
|
state.infotext = data;
|
|
},
|
|
setindexarr(state, data){
|
|
state.indexarr = data
|
|
}
|
|
},
|
|
actions: {
|
|
async setUserInfo({ commit }){
|
|
const user = await userinfo();
|
|
if(user != '未登录'){
|
|
saveValue("Lanvuage", user.languageValue);
|
|
commit('setUserInfo', user);
|
|
} else {
|
|
const info = await getaddr();
|
|
console.log(info,11256445)
|
|
commit("setLanguage", info)
|
|
}
|
|
},
|
|
async getip({ commit }){
|
|
const info = await getaddr();
|
|
console.log(info,11256445);
|
|
commit("setLanguage", info)
|
|
},
|
|
async getcode({ commit }){
|
|
const info = await getaddr();
|
|
console.log(info,11256445);
|
|
commit("setquhao", info)
|
|
},
|
|
async getinfotext({ commit }){
|
|
const info = await getarticle();
|
|
commit("setinfotext", info)
|
|
|
|
},
|
|
async getindexarr({ commit }){
|
|
const info = await personalCenterData();
|
|
commit("setindexarr", info)
|
|
}
|
|
},
|
|
modules: {
|
|
}
|
|
})
|