Browse Source

feat: 支持在业态筛选时,根据推荐店铺排序

master
jiannibang 2 years ago
parent
commit
d34feaea42
  1. 6
      src/components/ShopList/ShopList.js
  2. 31
      src/js/helpers/data-helper.js

6
src/components/ShopList/ShopList.js

@ -10,10 +10,7 @@ const ShopList = ({
format = null,
floorOrder = null,
}) => {
const shops = mall.shopInfo.reduce(
(acc, { shopList }) => acc.concat(shopList),
[]
);
const shops = format ? mall.sortedShops : mall.shops;
const upperQ = q ? q.toUpperCase() : "";
const filteredShops = shops
.filter(({ yaxis }) => yaxis)
@ -49,6 +46,7 @@ const ShopList = ({
(format === null ? true : shopFormat === format) &&
(floorOrder === null ? true : floorOrder1 === floorOrder)
);
const listRef = useRef(null);
return (
<div className={"shop-list " + (isRow ? "is-row" : "")} ref={listRef}>

31
src/js/helpers/data-helper.js

@ -53,13 +53,14 @@ const getMallInfo = async ({ memberID }) => {
} = await axios.get(
`${cdnUrl}/ar/${code}/config.json?t=${new Date().getTime()}`
);
// if (mapUrl) config.mapDataUrl = mapUrl;
// if (shopUrl) config.shopInfoUrl = shopUrl;
if (mapUrl) config.mapDataUrl = mapUrl;
if (shopUrl) config.shopInfoUrl = shopUrl;
} catch (error) {
console.log("获取config失败");
}
const [
recIndexMap,
mapDataJSON,
serverShopInfo,
facs,
@ -68,6 +69,24 @@ const getMallInfo = async ({ memberID }) => {
menu,
{ shopCouponMap, userLevel },
] = await Promise.all([
(async () => {
try {
const {
data: {
data: { recommendList },
},
} = await axios.get(
`${baseUrl}/api/guidance/v1/web/getBrandShopList?projectCode=${code}`
);
return recommendList.reduce(
(acc, nxt, i) => ({ ...acc, [nxt.shopCode]: i }),
{}
);
} catch (error) {
console.error(error);
return {};
}
})(),
(async () => {
try {
const {
@ -126,6 +145,7 @@ const getMallInfo = async ({ memberID }) => {
return { shopCouponMap: {} };
})(),
]);
mall.name = "SKP";
document.title = "成都SKP";
mall.city = "成都";
@ -189,6 +209,13 @@ const getMallInfo = async ({ memberID }) => {
mapData.buildArr.forEach(({ mapData: { parkArea } }) => {
parkArea.forEach(({ parkNum }) => mall.lots.push(parkNum));
});
mall.shops = shopInfo.reduce((acc, { shopList }) => acc.concat(shopList), []);
mall.sortedShops = [...mall.shops];
mall.sortedShops.sort(
(a, b) =>
(a.shopCode in recIndexMap ? recIndexMap[a.shopCode] : Infinity) -
(b.shopCode in recIndexMap ? recIndexMap[b.shopCode] : Infinity)
);
Object.assign(mall, {
floorData: mall.floors,

Loading…
Cancel
Save