index.js
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
export default function() {
return {
namespaced: true,
state: {
filterVisible: false,
searchWord: [],
defaultSearchWord: [],
searchSuggestList: [],
},
mutations: {
setSearchSuggest(state, {searchSuggestList}) {
console.log(searchSuggestList);
state.searchSuggestList = searchSuggestList.items;
},
setSearchWords(state, {searchWord}) {
state.searchWord = searchWord;
},
setDefaultSearchWords(state, {defaultSearchWord}) {
state.defaultSearchWord = defaultSearchWord;
}
},
actions: {
// 查询商品列表
fetchProductList: async function({commit, state}, params) {
let result = await this.$api.get('/api/ufo/list/productList', {
...params
});
return result;
},
// 查询筛选列表
fetchFilterData: async function({commit, state}, params) {
let result = await this.$api.get('/api/ufo/list/filterData', {...params});
if (result.code === 200) {
let {data} = result;
return data.filter;
} else {
return [];
}
},
// 请求查询关键词
fetchSearchWords: async function({commit}) {
let result = await this.$api.get('/api/ufo/list/searchWords', {word_type: 0});
commit('setSearchWords', {searchWord: result.data});
},
// 请求默认查询关键词
fetchDefaultSearchWords: async function({commit}) {
let result = await this.$api.get('/api/ufo/list/searchWords', {word_type: 1});
commit('setDefaultSearchWords', {defaultSearchWord: result.data});
},
// 联动查询输入关键词
fetchSearchSuggest: async function({commit}, query) {
let result = await this.$api.get('/api/ufo/list/searchSuggest', {query});
commit('setSearchSuggest', {searchSuggestList: result.data});
},
}
};
}