猫妈狗爸伴宠师小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

63 lines
1.3 KiB

import { getConfigList, getPetTypeList, getIncreaseServiceList } from '@/api/config/config.js'
const system = {
state: {
configList: {},
petTypeOptions: [],
increaseServiceOptions: [],
},
mutations: {
setConfigList(state, list) {
const obj = {}
list.forEach(n => {
obj[n.paramCode] = n;
})
state.configList = obj;
},
setPetTypeOptions(state, list) {
state.petTypeOptions = list
},
setIncreaseServiceOptions(state, list) {
state.increaseServiceOptions = list
},
},
actions: {
async fetchConfigList({commit, state}) {
try {
const data = await getConfigList()
commit('setConfigList', data)
} catch (err) {
}
},
async fetchPetTypeOptions({commit, state}) {
if (state.petTypeOptions.length) {
return
}
try {
const data = await getPetTypeList()
commit('setPetTypeOptions', data)
} catch (err) {
}
},
async fetchIncreaseServiceOptions({commit, state}) {
if (state.increaseServiceOptions.length) {
return
}
try {
const data = await getIncreaseServiceList()
commit('setIncreaseServiceOptions', data)
} catch (err) {
}
},
}
}
export default system