From a477a2a784c300953a2dfdfd9d5ebc308627fffb Mon Sep 17 00:00:00 2001 From: zhangjing1 Date: Mon, 16 Mar 2026 15:35:20 +0800 Subject: [PATCH] bug: --- src/hocs/withPageWrapper.js | 5 +++++ src/pages/home/wgts/goods/index.jsx | 3 +-- src/pages/index.js | 35 +++++++++-------------------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/hocs/withPageWrapper.js b/src/hocs/withPageWrapper.js index f4c0ea5a1..0e46968bc 100644 --- a/src/hocs/withPageWrapper.js +++ b/src/hocs/withPageWrapper.js @@ -16,6 +16,7 @@ import api from '@/api' import S from '@/spx' function withPageWrapper(Component) { + try { return function EnhancedComponent(props) { console.log('withPageWrapper', props) const dispatch = useDispatch() @@ -319,6 +320,10 @@ function withPageWrapper(Component) { return null } } +} catch (error) { + console.log('error', error) + return null + } } export default withPageWrapper diff --git a/src/pages/home/wgts/goods/index.jsx b/src/pages/home/wgts/goods/index.jsx index cff68446b..0c160b94b 100644 --- a/src/pages/home/wgts/goods/index.jsx +++ b/src/pages/home/wgts/goods/index.jsx @@ -28,7 +28,6 @@ export default function WgtGoods(props) { const base = params.base || {} const data = params.data || {} - const { onAddToCart } = useContext(WgtsContext) const isPointsmallItems = base.dataType === 'pointsmall_items' // 获取外层样式(包含 outerMargin 和背景配置) @@ -125,7 +124,7 @@ export default function WgtGoods(props) { // 处理商品点击:积分商品跳积分详情,否则走 linkPage const handleClickItem = (item) => { const itemId = item.item_id ?? item.itemId - if (isPointsmallItems || item.point != null) { + if (isPointsmallItems) { Taro.navigateTo({ url: `/subpages/pointshop/espier-detail?id=${itemId}` }) diff --git a/src/pages/index.js b/src/pages/index.js index 711153a79..86f9b6f0e 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -2,38 +2,27 @@ * Copyright © ShopeX (http://www.shopex.cn). All rights reserved. * See LICENSE file for license details. */ -import React, { useEffect, useRef, useCallback } from 'react' +import React, { useEffect, useRef } from 'react' import Taro, { - getCurrentInstance, useShareAppMessage, useShareTimeline, useDidShow } from '@tarojs/taro' -import { View, Image, ScrollView, Text } from '@tarojs/components' +import { View, ScrollView } from '@tarojs/components' import { useSelector, useDispatch } from 'react-redux' -import throttle from 'lodash/throttle' import { SpScreenAd, SpPage, - SpSearch, SpRecommend, SpTabbar, SpCouponPackage, - SpSkuSelect, - SpPrivacyModal, - SpLogin, - SpLoading -} from '@/components' + SpSkuSelect} from '@/components' import api from '@/api' import { isWeixin, - isAPP, - isEmpty, getDistributorId, VERSION_STANDARD, VERSION_PLATFORM, - VERSION_IN_PURCHASE, - VERSION_B2C, classNames, getCurrentPageRouteParams, resolveStringifyParams, @@ -41,20 +30,17 @@ import { pickBy, log, showToast, - entryLaunch, buildSharePath } from '@/utils' -import { updateShopInfo } from '@/store/slices/shop' import { updatePurchaseShareInfo, updateInviteCode, updateEnterpriseId } from '@/store/slices/purchase' -import S from '@/spx' import { useImmer } from 'use-immer' import { useLogin, useNavigation, useLocation, useModal, useEffectAsync } from '@/hooks' import doc from '@/doc' -import { SG_ROUTER_PARAMS } from '@/consts/localstorage' +import SpPoweredBy from '@/components/sp-powered-by' import withPageWrapper from '@/hocs/withPageWrapper' import HomeWgts from './home/comps/home-wgts' import { WgtsContext } from './home/wgts/wgts-context' @@ -62,7 +48,6 @@ import CompAddTip from './home/comps/comp-addtip' import CompFloatMenu from './home/comps/comp-floatmenu' import './home/index.scss' -import SpPoweredBy from '@/components/sp-powered-by' const MCompAddTip = React.memo(CompAddTip) const MSpSkuSelect = React.memo(SpSkuSelect) @@ -106,6 +91,7 @@ function Home() { const nearbyText = address?.city || location?.city || '' const { setNavigationBarTitle } = useNavigation() const { updateAddress } = useLocation() + const locationKeyRef = useRef('') const { wgts, pageData, @@ -123,8 +109,6 @@ function Home() { useEffectAsync(async () => { fetchWgts() setNavigationBarTitle(appName) - - log.info({ str: 'hello world' }, 'info log', 100, [1, 2, 3]) }, []) useDidShow(() => { @@ -137,10 +121,13 @@ function Home() { Taro.eventCenter.trigger('homePageShow') }) + // 仅当定位结果真正变化(如城市/区县)时重拉首页配置,避免每次 useDidShow→updateAddress 导致 location 引用变化就整页重载 useEffect(() => { - if (location && VERSION_STANDARD) { - fetchWgts() - } + if (!location || !VERSION_STANDARD) return + const key = [location.city, location.district, location.lat, location.lng].filter(Boolean).join('|') + if (locationKeyRef.current === key) return + locationKeyRef.current = key + fetchWgts() }, [location]) useEffect(() => {