diff --git a/.workbuddy/memory/2026-07-14.md b/.workbuddy/memory/2026-07-14.md index eb2587e..fdedb2c 100644 --- a/.workbuddy/memory/2026-07-14.md +++ b/.workbuddy/memory/2026-07-14.md @@ -147,6 +147,19 @@ adapter `/list` 接口忽略分页,一次返回全部收藏;前端 `listShop 3. `useEffect` 中增加 `if (!user?.userId) return` 判断,已登录但 userId 还没拿到时等待下次渲染 4. `useEffect` 依赖数组加 `user?.userId`,userId 变化时重新触发加载 +## 商城列表页浮动购物车按钮(2026-07-14) + +### 需求 +`pages/shop/index` 页面右下角添加浮动购物车按钮,显示购物车商品数量角标。 + +### 实现 +- **`src/pages/shop/index.tsx`**: + 1. 从 `useCartContext()` 额外解构 `totalCount` + 2. 页面末尾添加 fixed 定位浮动按钮:绿色圆形(48px),`bottom:80px right:16px`(避开 tabBar) + 3. `totalCount > 0` 时右上角显示红色角标,超过 99 显示 `99+` + 4. 点击 `Taro.navigateTo` 跳转购物车页(cart 非 tabBar 页) + 5. 数量实时更新:`addItem` 内部调 `refresh()` → `totalCount` 派生值自动重渲染 + ## 购物车页面进入不刷新 Bug 修复(2026-07-14) ### 问题 diff --git a/src/pages/shop/index.tsx b/src/pages/shop/index.tsx index f713f11..0c9f712 100644 --- a/src/pages/shop/index.tsx +++ b/src/pages/shop/index.tsx @@ -36,7 +36,7 @@ const SORT_TABS: { key: SortKey; label: string }[] = [ ] const ShopPage: React.FC = () => { - const { addItem } = useCartContext() + const { addItem, totalCount } = useCartContext() const [categoryList, setCategoryList] = useState(PRESET_CATEGORIES) const [activeCategory, setActiveCategory] = useState(0) @@ -343,6 +343,47 @@ const ShopPage: React.FC = () => { + + {/* 浮动购物车按钮 */} + Taro.navigateTo({ url: '/pages/shop/cart' })} + > + 🛒 + {totalCount > 0 && ( + + + {totalCount > 99 ? '99+' : totalCount} + + + )} + ) } diff --git a/src/pages/user/index.tsx b/src/pages/user/index.tsx index fdc1b7d..00c315f 100644 --- a/src/pages/user/index.tsx +++ b/src/pages/user/index.tsx @@ -23,7 +23,7 @@ const UserPage: React.FC = () => { { icon: '📅', label: '预约订单', url: '/pages/booking/list' }, { icon: '🏆', label: '赛事活动', url: '/pages/event/my/index' }, { icon: '🎫', label: '优惠券', url: '/pages/user/coupon-list' }, - { icon: '💰', label: '我的钱包', url: '/pages/user/wallet' }, + // { icon: '💰', label: '我的钱包', url: '/pages/user/wallet' }, { icon: '📍', label: '收货地址', url: '/pages/user/address-list' }, { icon: '⭐', label: '积分明细', url: '/pages/user/points-record' }, { icon: '🔔', label: '消息通知', url: '/pages/index/notification' },