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.
xxdj1/store/modules/service.js

80 lines
1.2 KiB

2 years ago
import $api from "@/api/index.js"
export default {
state: {
pageActive: false,
activeIndex: 0,
tabList: [{
2 years ago
title: '综合推荐',
2 years ago
sort: 'top desc',
2 years ago
}, {
title: '单量',
sort: 'total_sale',
2 years ago
sign: 0,
is_sign: 1,
}, {
2 years ago
title: '距离',
sort: 'price',
2 years ago
sign: 0,
is_sign: 1,
2 years ago
},{
title: '评分',
2 years ago
sort: 'star',
sign: 0,
is_sign: 1,
}],
param: {
page: 1,
sort: ''
},
list: {
data: [],
last_page: 1,
current_page: 1
},
banner: []
},
mutations: {
async updateServiceItem(state, item) {
let {
key,
val
} = item
state[key] = val
}
},
actions: {
async getServiceIndex({
commit,
state
}, param) {
let d = await $api.service.index(param);
let {
banner
} = d
commit('updateServiceItem', {
key: 'banner',
val: banner
})
},
async getServiceList({
commit,
state
}, param) {
let d = await $api.service.serviceList(param)
let oldList = state.list;
let newList = d;
let list = {}
if (param.page == 1) {
list = newList;
} else {
newList.data = oldList.data.concat(newList.data)
list = newList;
}
commit('updateServiceItem', {
key: 'list',
val: list
})
}
},
}