From 0e1ed8d5b4b3a438f35ba26adea1efab1a40fa06 Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Wed, 16 Nov 2022 20:27:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0store=E5=AD=98=E5=82=A8accoun?= =?UTF-8?q?t=E7=AD=89=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.production | 2 +- src/api/webapi.js | 7 +++++++ src/store/index.js | 33 ++++++++++++++++++++++----------- src/views/mobile/Login.vue | 2 ++ 4 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 src/api/webapi.js diff --git a/.env.production b/.env.production index b304af5..574ed3b 100644 --- a/.env.production +++ b/.env.production @@ -1 +1 @@ -VUE_APP_API_HOST='https://game2006api-test.kingsome.cn' \ No newline at end of file +VUE_APP_API_HOST='http://192.168.100.83:3000' \ No newline at end of file diff --git a/src/api/webapi.js b/src/api/webapi.js new file mode 100644 index 0000000..891af96 --- /dev/null +++ b/src/api/webapi.js @@ -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, + }); +} diff --git a/src/store/index.js b/src/store/index.js index ceffa8e..f179fcb 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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: {}, +}); diff --git a/src/views/mobile/Login.vue b/src/views/mobile/Login.vue index 3acfaae..9977275 100644 --- a/src/views/mobile/Login.vue +++ b/src/views/mobile/Login.vue @@ -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");