Authored by y.huang

商品列表页面样式修改

... ... @@ -60,27 +60,34 @@ export default {
type: 6
};
},
deactivated: function() {
this.initData();
},
activated: function() {
this.changeArrow();
let params = this.$route.query;
if (Object.keys(params).length && params.listType) {
this.listType = params.listType;
delete params.listType;
}
if (Object.keys(params).length && params.type) {
this.type = params.type;
} else {
params.type = 6;
}
!params.order && (params.order = 'sale_desc');
params.listPage = true
this.fetchProductList({...params, isReset: true});
this.fetchFilterData(params);
},
methods: {
...mapActions(['fetchProductList', 'fetchFilterData']),
...mapActions(['fetchProductList', 'fetchFilterData', 'initData']),
// 上拉加载
async onPullingUp() {
await this.fetchProductList({listType: this.listType});
await this.fetchProductList();
},
// 点击tab type, 0: 推荐, 1: 价格, 2: 人气, 3: 新品
... ...
import {get} from 'lodash';
export default function() {
return {
namespaced: true,
... ... @@ -18,7 +16,7 @@ export default function() {
},
searchParams: {
type: 0, // type:0,推荐;1,热销;2,即将发售; 3,品类; 4,品牌;5,系列;6,搜索 7, 收藏
order: 'sale_desc', // 指定排序
order: '', // 指定排序
productPool: null, // 商品池id
sort: null, // 品类id
brand: null, // 品牌id
... ... @@ -59,7 +57,8 @@ export default function() {
}
},
setSearchParams(state, {params}) {
state.searchParams = Object.assign(state.searchParams, params);
console.log(params)
state.searchParams = params || {};
},
addFilterData(state, {filter}) {
state.filterData = filter;
... ... @@ -87,23 +86,74 @@ export default function() {
},
setDefaultSearchWords(state, {defaultSearchWord}) {
state.defaultSearchWord = defaultSearchWord;
},
initData(state) {
state = {
productList: {
showErrorPage: false,
isFetching: false,
error: null,
page: 0, // 当前页
page_size: 10, // 每页数量
page_total: 0, // 总共多少页
total: 0, // 总共多少条
endReached: false, // 到达底部
list: [], // 商品列表
isEmpty: false,
},
searchParams: {
type: 0, // type:0,推荐;1,热销;2,即将发售; 3,品类; 4,品牌;5,系列;6,搜索 7, 收藏
order: '', // 指定排序
productPool: null, // 商品池id
sort: null, // 品类id
brand: null, // 品牌id
series: null, // 系列id
gender: null, // 性别
size: null, // 尺码id
isSoonSale: null, // 是否是即将售卖
query: null, // 搜索词
limit: null, // 每页记录数
page: null, // 当前页号
coupon_token: null, // 优惠券token
},
filterParams: {
sort: [], // 品类id
brand: [], // 品牌id
gender: [], // 性别
size: [], // 尺码id
},
filterData: [],
filterVisible: false,
searchWord: [],
defaultSearchWord: [],
searchSuggestList: [],
};
}
},
actions: {
//查询商品列表
fetchProductList: async function({commit, state}, params) {
let searchParams = state.searchParams;
let list = state.productList;
let pageSize = list.page_size;
let isReset = false;
let isReset = false, isHome = false;
if (params && params.isReset) {
isReset = true;
delete params.isReset;
}
if (params && Object.keys(params).length) {
searchParams = Object.assign({...searchParams}, params);
if (params && params.isHome) {
isHome = true;
delete params.isHome;
}
if (!isHome && params && Object.keys(params).length) {
searchParams = Object.assign({...searchParams}, params)
commit('setSearchParams', {params: searchParams});
}
isHome && (searchParams = params || {});
if (!isReset && (list.endReached || (!list.endReached && list.page_total === 1))) {
return;
}
... ... @@ -129,6 +179,8 @@ export default function() {
return result.data ? result.data.length : 0;
},
//查询筛选列表
fetchFilterData: async function({commit, state}) {
let searchParams = state.searchParams;
... ... @@ -140,28 +192,42 @@ export default function() {
commit('addFilterData', {filter: data.filter});
}
},
// 设置筛选参数
setFilterParam: function({commit}, params) {
commit('setFilterParam', {filter: params});
},
// 设置查询参数
setSearchQuery: function({commit}, query) {
commit('setSearchQuery', {query});
},
// 请求查询关键词
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});
},
initData: function({commit}) {
commit('initData');
}
}
};
... ...