From 2b50fdf5a44677c961ff32558619f4d6940d393d Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 26 Aug 2022 17:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E5=B1=80=E5=A2=9E=E5=8A=A0=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=E7=99=BB=E5=BD=95=E4=BF=A1=E6=81=AF=E7=9A=84=E6=89=A9?= =?UTF-8?q?=E5=B1=95=E5=9F=8B=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/App.vue | 6 +++--- examples/store/index.js | 8 ++------ project/xiushan/mutations.js | 9 +++++++++ 3 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 project/xiushan/mutations.js diff --git a/examples/App.vue b/examples/App.vue index 38031641..d54f1983 100644 --- a/examples/App.vue +++ b/examples/App.vue @@ -43,7 +43,7 @@ export default { } }, methods: { - ...mapMutations(['setToken', 'setFinanceUser']), + ...mapMutations(['setToken', 'getFinanceUser']), ...mapActions(['getUserInfo']), getToken(params) { if (params.access_token) { @@ -62,9 +62,9 @@ export default { }, created() { wx = jWeixin - if (this.user.token) this.getUserInfo().then(() => { + if (this.user.token) this.getUserInfo().finally(() => { if (/^\/project\/xiushan/.test(location.pathname)) { - this.setFinanceUser() + this.getFinanceUser() } }) } diff --git a/examples/store/index.js b/examples/store/index.js index 22293cd3..6b3fc761 100644 --- a/examples/store/index.js +++ b/examples/store/index.js @@ -2,7 +2,7 @@ import Vue from 'vue' import Vuex from 'vuex' import preState from 'vuex-persistedstate' import * as modules from "dvcp-ui/lib/js/modules" -import axios from "../router/axios"; +import xsMutations from "../../project/xiushan/mutations" Vue.use(Vuex) @@ -17,11 +17,7 @@ export default new Vuex.Store({ cleanApps(state) { state.apps = [] }, - setFinanceUser(state) { - axios.post("appfinancialorganizationuser/checkUser").then(res => { - state.user.financeUser = res.data - }).catch(() => 0) - } + ...xsMutations }, modules, plugins: [preState()] diff --git a/project/xiushan/mutations.js b/project/xiushan/mutations.js new file mode 100644 index 00000000..719dec60 --- /dev/null +++ b/project/xiushan/mutations.js @@ -0,0 +1,9 @@ +import axios from "dvcp-ui/lib/js/request"; + +export default { + getFinanceUser(state) { + axios.post("appfinancialorganizationuser/checkUser").then(res => { + state.user.financeUser = res.data + }).catch(() => 0) + } +}