增加store存储account等数据

This commit is contained in:
cebgcontract 2022-11-16 20:27:34 +08:00
parent 39dc6bf266
commit 0e1ed8d5b4
4 changed files with 32 additions and 12 deletions

View File

@ -1 +1 @@
VUE_APP_API_HOST='https://game2006api-test.kingsome.cn' VUE_APP_API_HOST='http://192.168.100.83:3000'

7
src/api/webapi.js Normal file
View File

@ -0,0 +1,7 @@
import axios from "axios";
export function checkStatus(account) {
return axios.post(process.env.VUE_APP_API_HOST + "/aa1/user_status", {
account,
});
}

View File

@ -1,17 +1,28 @@
import Vue from 'vue' import Vue from "vue";
import Vuex from 'vuex' import Vuex from "vuex";
Vue.use(Vuex) Vue.use(Vuex);
export default new Vuex.Store({ export default new Vuex.Store({
state: { state() {
}, return {
getters: { account: "",
token: "",
status: 0,
};
}, },
getters: {},
mutations: { mutations: {
updataAccount(state, _account) {
state.account = _account;
}, },
actions: { updataToken(state, _token) {
state.token = _token;
}, },
modules: { updateStatus(state, _state) {
} state.status = _state;
}) },
},
actions: {},
modules: {},
});

View File

@ -62,6 +62,8 @@ export default {
logined: this.chain.logined, logined: this.chain.logined,
token: this.chain.token, token: this.chain.token,
}; };
this.$store.commit('updataAccount', this.chain.account);
this.$store.commit('updataToken', this.chain.token);
window.localStorage.setItem("userinfo", JSON.stringify(userInfo)); window.localStorage.setItem("userinfo", JSON.stringify(userInfo));
let userinfo = window.localStorage.getItem("userinfo"); let userinfo = window.localStorage.getItem("userinfo");
console.log(JSON.parse(userinfo) , "2022"); console.log(JSON.parse(userinfo) , "2022");