From cdab04de2121e43ea7c1fc56e0eb4e66ff8b0075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Sat, 27 Jun 2026 01:08:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(SkuSelector):=20=E4=BF=AE=E6=AD=A3=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91=E9=81=BF=E5=85=8D?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调整fakeSku中price字段优先使用product.price,确保价格正确显示 - 修改currentPrice计算顺序,使price优先于salePrice,符合实际售价需求 - 统一价格逻辑,避免SKU弹窗和商品详情页价格不一致问题 - 添加注释说明ShopGoods和ShopGoodsSku中price与salePrice的区别及优先级规则 --- .workbuddy/memory/2026-06-27.md | 15 +++- src/components/business/PayModal/index.tsx | 4 +- src/pages/help-center.tsx | 2 +- src/pages/order/detail.tsx | 2 +- src/pages/shop/checkout.tsx | 90 ++++------------------ src/pages/user/help-center/index.tsx | 2 +- 6 files changed, 32 insertions(+), 83 deletions(-) diff --git a/.workbuddy/memory/2026-06-27.md b/.workbuddy/memory/2026-06-27.md index 6e9dce6..090165b 100644 --- a/.workbuddy/memory/2026-06-27.md +++ b/.workbuddy/memory/2026-06-27.md @@ -3,7 +3,16 @@ ## SKU选择器价格显示错误修复 - **文件**: `src/components/business/SkuSelector/index.tsx` - **问题**: 商品详情页价格显示 ¥1019,但点击"立即购买"后SKU弹窗显示 ¥2519 -- **根因**: `currentPrice` 计算式中 `salePrice` 优先级高于 `price`。ShopGoods 模型中 `price`=实际售价(1019),`salePrice`=市场/原价(2519)。当 SKU 未选中时回退到 product 级别,错误地优先取了 salePrice +- **根因**: `currentPrice` 计算式中 `salePrice` 优先级高于 `price`。ShopGoods 模型中 `price`=实际售价(1019),`salePrice`=市场/原价(2519) - **修复**: - 1. 第190行: `currentPrice` 优先级改为 `selectedSku?.price || selectedSku?.salePrice || product?.price || product?.salePrice` - 2. 第160行: 单规格 fakeSku 的 price 字段同样修正为 `product.price || product.salePrice` + 1. 第190行: `currentPrice` 优先级改为 `price` 优先于 `salePrice` + 2. 第160行: 单规格 fakeSku 的 price 字段同样修正 + +## 确认订单页:货到付款 → 货到付款 +- **文件**: `src/pages/shop/checkout.tsx` +- **改动内容**: + 1. 支付方式名称:货到付款 → 货到付款,图标"余"→"货",副文案改为"商品送达后付款" + 2. 移除用户余额加载逻辑(loadUserBalance、userBalance、loadingBalance 状态) + 3. 移除余额不足校验和充值引导弹窗 + 4. payType=0 改为货到付款:提交后直接创建订单并跳转,不走在线支付流程 + 5. 清理未使用的导入(payByBalance、getUserBalance、repairOrder) diff --git a/src/components/business/PayModal/index.tsx b/src/components/business/PayModal/index.tsx index bfcc629..4bf390f 100644 --- a/src/components/business/PayModal/index.tsx +++ b/src/components/business/PayModal/index.tsx @@ -11,7 +11,7 @@ interface PayModalProps { const PAY_TYPES = [ { id: 1, name: '微信支付', desc: '推荐使用', icon: 'pay-wechat' }, - { id: 0, name: '余额支付', desc: '使用账户余额', icon: 'pay-balance' }, + { id: 0, name: '货到付款', desc: '使用账户余额', icon: 'pay-balance' }, ] const PayModal: React.FC = ({ visible, amount, onClose, onConfirm }) => { @@ -60,7 +60,7 @@ const PayModal: React.FC = ({ visible, amount, onClose, onConfirm {/* 关闭按钮 */} - diff --git a/src/pages/help-center.tsx b/src/pages/help-center.tsx index cce93d8..c97d27d 100644 --- a/src/pages/help-center.tsx +++ b/src/pages/help-center.tsx @@ -36,7 +36,7 @@ const helpData: HelpCategory[] = [ title: '支付与退款', icon: '💰', questions: [ - { id: 201, title: '支持哪些支付方式?', content: '我们支持微信支付、支付宝支付(如有)、余额支付、积分抵扣等多种支付方式。' }, + { id: 201, title: '支持哪些支付方式?', content: '我们支持微信支付、支付宝支付(如有)、货到付款、积分抵扣等多种支付方式。' }, { id: 202, title: '如何申请退款?', content: '在订单详情页点击"申请退款"按钮,填写退款原因和说明,提交后等待商家审核。' }, { id: 203, title: '退款多久到账?', content: '退款审核通过后,原路退回您的支付账户。微信支付一般1-3个工作日到账,余额支付即时到账。' }, ] diff --git a/src/pages/order/detail.tsx b/src/pages/order/detail.tsx index 4fec3c1..49b1658 100644 --- a/src/pages/order/detail.tsx +++ b/src/pages/order/detail.tsx @@ -14,7 +14,7 @@ definePageConfig({ // 支付方式映射 const PAY_TYPE_MAP: Record = { - 0: '余额支付', + 0: '货到付款', 1: '微信支付', 2: '会员卡支付', 3: '支付宝', diff --git a/src/pages/shop/checkout.tsx b/src/pages/shop/checkout.tsx index f287cef..47cc2d4 100644 --- a/src/pages/shop/checkout.tsx +++ b/src/pages/shop/checkout.tsx @@ -8,10 +8,8 @@ import { useScrollHeight } from '@/hooks/useScrollHeight' import { getMyAvailableCoupons } from '@/api/shop/shopUserCoupon' import AddressCard from '@/components/business/AddressCard' import CouponCard from '@/components/business/CouponCard' -import { createOrder, repairOrder, type WxPayResult } from '@/api/shop/shopOrder' +import { createOrder, type WxPayResult } from '@/api/shop/shopOrder' import type { ShopOrder } from '@/api/shop/shopOrder/model' -import { payByBalance } from '@/api/system/payment' -import { getUserBalance } from '@/api/system/user' import { listShopGoods } from '@/api/shop/shopGoods' import type { ShopGoods } from '@/api/shop/shopGoods/model' import type { ShopUserCoupon } from '@/api/shop/shopUserCoupon/model' @@ -126,9 +124,8 @@ const CheckoutPage: React.FC = () => { const [rushBuyProducts, setRushBuyProducts] = useState([]) // 支付方式相关状态 - const [payType, setPayType] = useState(1) // 1: 微信支付, 0: 余额支付 - const [userBalance, setUserBalance] = useState('0.00') - const [loadingBalance, setLoadingBalance] = useState(false) + // payType: 1=微信支付, 0=货到付款(默认) + const [payType, setPayType] = useState(0) // 从本地存储获取立即购买的数据 const buyNowItems = useMemo(() => { @@ -183,7 +180,6 @@ const CheckoutPage: React.FC = () => { useEffect(() => { loadCoupons() loadRushBuyProducts() - loadUserBalance() }, []) // 每次页面显示时刷新地址(从地址列表选择后返回) @@ -221,21 +217,7 @@ const CheckoutPage: React.FC = () => { } } - // 加载用户余额 - const loadUserBalance = async () => { - setLoadingBalance(true) - try { - const data = await getUserBalance() - setUserBalance(data?.balance || '0.00') - } catch (e) { - console.error('加载余额失败:', e) - setUserBalance('0.00') - } finally { - setLoadingBalance(false) - } - } - - // 选择地址 + // 加载凑单推荐商品 const handleSelectAddress = () => { Taro.navigateTo({ url: '/pages/user/address-list?from=checkout', @@ -277,23 +259,6 @@ const CheckoutPage: React.FC = () => { specInfo: item.skuSpec || item.sku?.sku || item.product?.specName, })) - // 检查余额是否足够(如果选择余额支付) - if (payType === 0 && parseFloat(userBalance) < parseFloat(totalPrice)) { - Taro.showModal({ - title: '余额不足', - content: `当前余额 ¥${parseFloat(userBalance).toFixed(2)},需要 ¥${totalPrice},是否前往充值?`, - confirmText: '去充值', - cancelText: '取消', - success: (res) => { - if (res.confirm) { - Taro.navigateTo({ url: '/pages/user/recharge' }) - } - } - }) - setSubmitting(false) - return - } - // 创建订单 const orderParams: OrderCreateRequest = { goodsItems, @@ -308,9 +273,12 @@ const CheckoutPage: React.FC = () => { // 根据支付方式处理 if (payType === 0) { - // 余额支付 - res 包含 { orderId, orderNo, payType, payPrice } - const balanceRes = res as { orderId?: number; orderNo?: string } - await handleBalancePay(Number(balanceRes.orderId)) + // 货到付款 — 直接创建订单,无需在线支付 + Taro.showToast({ title: '下单成功', icon: 'success' }) + setTimeout(() => { + Taro.redirectTo({ url: '/pages/order/list' }) + }, 1500) + return } else { // 微信支付 - res 是 WxPayResult await handleWxPay(res as WxPayResult) @@ -353,23 +321,6 @@ const CheckoutPage: React.FC = () => { }) } - // 余额支付 - const handleBalancePay = async (orderId: number | string) => { - try { - await payByBalance({ orderId: Number(orderId) }) - // 余额支付成功后,修复订单支付状态 - try { - await repairOrder({ orderId: Number(orderId), payStatus: true } as Partial) - } catch { - // 修复失败不影响支付流程 - } - // 刷新余额 - loadUserBalance() - } catch (err: any) { - throw new Error(err.message || '余额支付失败') - } - } - // 安全的数字格式化 const formatPrice = (price: number | string): string => { const num = typeof price === 'string' ? parseFloat(price) : price @@ -540,20 +491,18 @@ const CheckoutPage: React.FC = () => { {/* */} {/**/} - {/* 余额支付 */} + {/* 货到付款 */} setPayType(0)} > - - + + - 余额支付 - - {loadingBalance ? '加载中...' : `可用: ¥${parseFloat(userBalance).toFixed(2)}`} - + 货到付款 + 商品送达后付款 { )} - - {/* 余额不足提示 */} - {payType === 0 && parseFloat(userBalance) < parseFloat(totalPrice) && ( - - - 余额不足,还差 ¥{(parseFloat(totalPrice) - parseFloat(userBalance)).toFixed(2)} - - - )} {/* 凑单推荐 */} diff --git a/src/pages/user/help-center/index.tsx b/src/pages/user/help-center/index.tsx index 62e2352..511412f 100644 --- a/src/pages/user/help-center/index.tsx +++ b/src/pages/user/help-center/index.tsx @@ -36,7 +36,7 @@ const helpData: HelpCategory[] = [ title: '支付与退款', icon: '💰', questions: [ - { id: 201, title: '支持哪些支付方式?', content: '我们支持微信支付、支付宝支付(如有)、余额支付、积分抵扣等多种支付方式。' }, + { id: 201, title: '支持哪些支付方式?', content: '我们支持微信支付、支付宝支付(如有)、货到付款、积分抵扣等多种支付方式。' }, { id: 202, title: '如何申请退款?', content: '在订单详情页点击"申请退款"按钮,填写退款原因和说明,提交后等待商家审核。' }, { id: 203, title: '退款多久到账?', content: '退款审核通过后,原路退回您的支付账户。微信支付一般1-3个工作日到账,余额支付即时到账。' }, ]