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) + } +}