nebula/store/bank.js
2022-06-21 08:33:33 +08:00

55 lines
1.0 KiB
JavaScript

export const BANK_API_PATH = '/api/admin/bank'
const getDefaultListData = () => {
return {
banks: [],
pagination: {}
}
}
export const state = () => {
return {
list: {
fetching: false,
data: getDefaultListData()
}
}
}
export const mutations = {
updateListFetching(state, action) {
state.list.fetching = action
},
updateListData(state, action) {
state.list.data = action
}
}
export const actions = {
fetchList({commit}, params = {}) {
if (params && params.reset === '0') {
return true;
}
// 清空已有数据
commit('updateListData', getDefaultListData())
commit('updateListFetching', true)
let data = {
page: params.page || 1
}
return this.$axios
.$get(`${BANK_API_PATH}/list`, {
params: data
})
.then(response => {
commit('updateListFetching', false);
commit('updateListData', response);
})
.catch(error => {
console.log(error);
commit('updateListFetching', false);
});
}
}