Commit b28dc3cb authored by Bill's avatar Bill

fix: 修改品类导航页排序

parent 2a6f9951
...@@ -54,10 +54,18 @@ function useGetLayout() { ...@@ -54,10 +54,18 @@ function useGetLayout() {
const configKey = startKey + _index; const configKey = startKey + _index;
dataFromRequest[_item.id] = _item; dataFromRequest[_item.id] = _item;
tabKeys.push(configKey.toString()); tabKeys.push(configKey.toString());
// const children = Object.keys(_item.children);
// console.log(children);
const children = ['secondary', 'flashSale', 'saleRanking', 'brand', 'suggestProduct']; /** [{ name: 'secondary', sort: 1 }] */
const withSortedChildren = Object.keys(_item.children).map((_typeName: string) => {
const { sort } = _item.children[_typeName];
return {
name: _typeName,
sort: sort,
};
});
// const children = ['secondary', 'flashSale', 'saleRanking', 'brand', 'suggestProduct'];
const children = withSortedChildren.sort((a, b) => a.sort - b.sort).map((_sortItem) => _sortItem.name);
const tabConfig: any = { const tabConfig: any = {
componentName: tabName, componentName: tabName,
title: _item.name, title: _item.name,
......
...@@ -27,6 +27,9 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip ...@@ -27,6 +27,9 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
// }; // };
const getActivityProduct = async (ids: number[]) => { const getActivityProduct = async (ids: number[]) => {
if(ids.length === 0) {
return null;
}
return PublicApi.getMarketingAdornActivityGoodsAdorn({ids: ids as any}); return PublicApi.getMarketingAdornActivityGoodsAdorn({ids: ids as any});
}; };
...@@ -157,6 +160,7 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip ...@@ -157,6 +160,7 @@ const CustomizeTabs: React.FC<Iprops> & { TabItem: typeof TabItem } = (props: Ip
...resultData ...resultData
}; };
const cloneDeepPageConfig = cloneDeep(pageConfig); const cloneDeepPageConfig = cloneDeep(pageConfig);
console.log(cloneDeepPageConfig);
Object.keys(resultDataWithSecondary).forEach((_item) => { Object.keys(resultDataWithSecondary).forEach((_item) => {
const parentKey = domKeyMap2Type.get(_item); const parentKey = domKeyMap2Type.get(_item);
if (!parentKey) { if (!parentKey) {
......
...@@ -81,7 +81,7 @@ const CategoryNavigation = () => { ...@@ -81,7 +81,7 @@ const CategoryNavigation = () => {
/** domKey 从7开始都是tab 的值 */ /** domKey 从7开始都是tab 的值 */
setLoading(true); setLoading(true);
const tabChildren = pageConfig[4].childNodes.slice(1); const tabChildren = pageConfig[4].childNodes.slice(1);
const result = tabChildren.map((_nodeKey) => { const result = tabChildren.map((_nodeKey: string) => {
if (!pageConfig[_nodeKey]) { if (!pageConfig[_nodeKey]) {
return ; return ;
} }
...@@ -100,13 +100,14 @@ const CategoryNavigation = () => { ...@@ -100,13 +100,14 @@ const CategoryNavigation = () => {
}; };
const tabItemData = {}; const tabItemData = {};
const tabItemChild = pageConfig[_nodeKey].childNodes; const tabItemChild = pageConfig[_nodeKey].childNodes;
tabItemChild.forEach(element => { tabItemChild.forEach((element, _index) => {
const { otherProps: { type }, props, childNodes } = pageConfig[element]; const { otherProps: { type }, props, childNodes } = pageConfig[element];
const rest = type === 'suggestProduct' ? { type: props.type, num: props.num } : {}; const rest = type === 'suggestProduct' ? { type: props.type || 1, num: props.num || 50 } : {};
tabItemData[type] = { tabItemData[type] = {
title: props?.title || TITLE_MAP[type], title: props?.title || TITLE_MAP[type],
...rest, ...rest,
sort: _index + 1,
children: childNodes.map((_son) => { children: childNodes.map((_son) => {
const sonData = pageConfig[_son]; const sonData = pageConfig[_son];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment