46 lines
1.5 KiB
JavaScript
46 lines
1.5 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
//import * as api from "../api/schedulepromise.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
home_services: [],
|
|
listing_status: 0,
|
|
listing_error_message: ''
|
|
},
|
|
mutations: {
|
|
update_home_service(state, data) {
|
|
state.home_services = data
|
|
},
|
|
update_listing_status(state, val) {
|
|
state.listing_status = val
|
|
},
|
|
update_listing_error_message(state, val) {
|
|
state.listing_error_message = val
|
|
}
|
|
},
|
|
actions: {
|
|
async lookup(context, prm) {
|
|
context.commit("update_listing_status", 1)
|
|
try {
|
|
let resp = await api.lookup(prm.id)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_listing_status", 3)
|
|
context.commit("update_listing_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_listing_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("home_services", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_listing_status", 3)
|
|
context.commit("update_listing_error_message", resp.message)
|
|
}
|
|
}
|
|
}
|
|
} |