64 lines
1.4 KiB
JavaScript
64 lines
1.4 KiB
JavaScript
// store/store.js
|
|
const URL = "/westone-api/v1/system/auth";
|
|
const store = Vuex.createStore({
|
|
state() {
|
|
return {
|
|
count: 0,
|
|
data: null,
|
|
email:null,
|
|
password:null,
|
|
dialog_success:false
|
|
};
|
|
},
|
|
mutations: {
|
|
increment(state) {
|
|
state.count++;
|
|
},
|
|
decrement(state) {
|
|
state.count--;
|
|
},
|
|
setData(state, payload) {
|
|
state.data = payload;
|
|
},
|
|
setEmail(state, data) {
|
|
state.email = data;
|
|
},
|
|
setPassword(state, data) {
|
|
state.password = data;
|
|
},
|
|
setDialogSuccess(state, data) {
|
|
state.dialog_success = data;
|
|
}
|
|
},
|
|
actions: {
|
|
increment({ commit }) {
|
|
commit('increment');
|
|
},
|
|
decrement({ commit }) {
|
|
commit('decrement');
|
|
},
|
|
async loginState({ state, commit }) {
|
|
const params = {
|
|
email: state.email,
|
|
password: state.pasword
|
|
};
|
|
|
|
try {
|
|
const response = await axios.post(URL+'/login', params);
|
|
commit('setData', response.data);
|
|
} catch (error) {
|
|
commit('setError', error);
|
|
}
|
|
},
|
|
async LoginParam({ commit }, params) {
|
|
try {
|
|
const response = await axios.post(URL+'/login', params);
|
|
commit('setData', response.data);
|
|
} catch (error) {
|
|
commit('setError', error);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
export default store;
|
|
|