From d34feaea42df56e377366b293db185679c9a9394 Mon Sep 17 00:00:00 2001
From: jiannibang <271381693@qq.com>
Date: Mon, 1 Jul 2024 14:58:00 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=9C=A8=E4=B8=9A?=
=?UTF-8?q?=E6=80=81=E7=AD=9B=E9=80=89=E6=97=B6=EF=BC=8C=E6=A0=B9=E6=8D=AE?=
=?UTF-8?q?=E6=8E=A8=E8=8D=90=E5=BA=97=E9=93=BA=E6=8E=92=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/ShopList/ShopList.js | 6 ++----
src/js/helpers/data-helper.js | 31 +++++++++++++++++++++++++++--
2 files changed, 31 insertions(+), 6 deletions(-)
diff --git a/src/components/ShopList/ShopList.js b/src/components/ShopList/ShopList.js
index b602b67..72dd01a 100644
--- a/src/components/ShopList/ShopList.js
+++ b/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 (
diff --git a/src/js/helpers/data-helper.js b/src/js/helpers/data-helper.js
index c292667..02395e1 100644
--- a/src/js/helpers/data-helper.js
+++ b/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,