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

83 lines
1.2 KiB

import $api from "@/api/index.js"
export default {
state: {
pageActive: false,
activeIndex: 0,
tabList: [{
title: '综合推荐',
sort: 'top desc',
id:0
}, {
title: '单量',
sort: 'total_sale',
sign: 0,
is_sign: 1,
id:1
}, {
title: '距离',
sort: 'distance',
sign: 0,
is_sign: 1,
id:2
},{
title: '评分',
sort: 'star',
sign: 0,
is_sign: 1,
id:3
}],
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
})
}
},
}