增加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 Vuex from 'vuex'
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex)
Vue.use(Vuex);
export default new Vuex.Store({
state: {
},
getters: {
state() {
return {
account: "",
token: "",
status: 0,
};
},
getters: {},
mutations: {
updataAccount(state, _account) {
state.account = _account;
},
updataToken(state, _token) {
state.token = _token;
},
updateStatus(state, _state) {
state.status = _state;
},
},
actions: {
},
modules: {
}
})
actions: {},
modules: {},
});

View File

@ -62,6 +62,8 @@ export default {
logined: this.chain.logined,
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));
let userinfo = window.localStorage.getItem("userinfo");
console.log(JSON.parse(userinfo) , "2022");