nebula/store/bank.js

55 lines
1.0 KiB
JavaScript
Raw Normal View History

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 = {}) {
2022-06-21 08:33:33 +08:00
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);
});
}
}