fix(search): 修复搜索页商品状态筛选条件错误
- 将搜索页商品筛选条件由 isShow: 1 修改为 status: 0,统一与商城主页规则 - 确认收藏列表和浏览历史不受影响,维护数据一致性 feat(price): 全站商品价格登录后可见脱敏实现 - 将所有硬编码价格替换为支持游客脱敏的 <Price loginMask> 组件 - 覆盖首页热销、收藏列表、秒杀列表、秒杀详情、拼团列表和拼团详情多个页面 - 秒杀详情价格组件支持白色字体,保持视觉效果一致
This commit is contained in:
@@ -30,3 +30,20 @@
|
|||||||
- **文件**: `src/pages/shop/product-detail.tsx`
|
- **文件**: `src/pages/shop/product-detail.tsx`
|
||||||
- **问题**: `mode='aspectFill'` 裁剪图片,看不完整
|
- **问题**: `mode='aspectFill'` 裁剪图片,看不完整
|
||||||
- **修复**: 改为 `mode='widthFix'`,图片宽度铺满屏幕、高度自适应;新增 `swiperHeight` 状态,通过第一张图片 `onLoad` 回调按实际宽高比动态计算 Swiper 高度
|
- **修复**: 改为 `mode='widthFix'`,图片宽度铺满屏幕、高度自适应;新增 `swiperHeight` 状态,通过第一张图片 `onLoad` 回调按实际宽高比动态计算 Swiper 高度
|
||||||
|
|
||||||
|
## 搜索页商品状态筛选修复
|
||||||
|
- **文件**: `src/pages/index/search.tsx`
|
||||||
|
- **问题**: 搜索页使用 `isShow: 1` 筛选商品,而项目统一约定 `status: 0` = 已上架(`shopGoods.status=0`),与商城主页不一致
|
||||||
|
- **修复**: `isShow: 1` → `status: 0`(第34行)
|
||||||
|
- **排查结果**: 商城主页 `shop/index.tsx` 和首页热销 `index/index.tsx` 已正确使用 `status: 0`;收藏列表使用独立 API 不受影响;浏览历史为本地存储
|
||||||
|
|
||||||
|
## 商品价格登录后可见(全站统一脱敏)
|
||||||
|
- **方式**: 将所有硬编码价格的位置替换为 `<Price loginMask>` 组件(该组件游客态显示"登录后查看价格")
|
||||||
|
- **已覆盖的页面(之前已使用 Price 组件)**: ProductCard、商城主页、搜索页、商品详情页 — 无需改动
|
||||||
|
- **本次修改的 6 个文件**:
|
||||||
|
1. `src/pages/index/index.tsx` — 首页热销,替换自绘价格
|
||||||
|
2. `src/pages/user/favorite-list/index.tsx` — 收藏列表
|
||||||
|
3. `src/pages/shop/seckill-list/index.tsx` — 秒杀列表
|
||||||
|
4. `src/pages/shop/seckill-detail/index.tsx` — 秒杀详情(红色背景,传 color='#ffffff')
|
||||||
|
5. `src/pages/shop/group-buy-list/index.tsx` — 拼团列表
|
||||||
|
6. `src/pages/shop/group-buy-detail/index.tsx` — 拼团详情
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { pageShopGoods } from '@/api/shop/shopGoods'
|
|||||||
import type { CmsAd } from '@/api/cms/cmsAd/model'
|
import type { CmsAd } from '@/api/cms/cmsAd/model'
|
||||||
import type { CmsArticle } from '@/api/cms/cmsArticle/model'
|
import type { CmsArticle } from '@/api/cms/cmsArticle/model'
|
||||||
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||||
|
import Price from '@/components/common/Price'
|
||||||
|
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: '首页',
|
navigationBarTitleText: '首页',
|
||||||
@@ -241,10 +242,12 @@ const IndexPage: React.FC = () => {
|
|||||||
<View className='p-2'>
|
<View className='p-2'>
|
||||||
<Text className='text-sm text-gray-700 truncate block'>{item.goodsName || item.name}</Text>
|
<Text className='text-sm text-gray-700 truncate block'>{item.goodsName || item.name}</Text>
|
||||||
<View className='flex items-center mt-1'>
|
<View className='flex items-center mt-1'>
|
||||||
<Text className='text-sm font-bold text-red-500 mr-1'>¥{item.price || '0'}</Text>
|
<Price
|
||||||
{item.salePrice && item.salePrice !== item.price && (
|
price={item.price || '0'}
|
||||||
<Text className='text-xs text-gray-400 line-through'>¥{item.salePrice}</Text>
|
original={item.salePrice && item.salePrice !== item.price ? item.salePrice : undefined}
|
||||||
)}
|
size='small'
|
||||||
|
loginMask
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
{item.sales !== undefined && item.sales > 0 && (
|
{item.sales !== undefined && item.sales > 0 && (
|
||||||
<Text className='text-xs text-gray-400 mt-1'>已售 {item.sales}</Text>
|
<Text className='text-xs text-gray-400 mt-1'>已售 {item.sales}</Text>
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ const SearchPage: React.FC = () => {
|
|||||||
if (!q.trim()) return
|
if (!q.trim()) return
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
try {
|
try {
|
||||||
const params: ShopGoodsParam = { keywords: q, isShow: 1, page: 1, limit: 20 }
|
const params: ShopGoodsParam = { keywords: q, status: 0, page: 1, limit: 20 }
|
||||||
const res = await pageShopGoods(params)
|
const res = await pageShopGoods(params)
|
||||||
setList(res?.list || [])
|
setList(res?.list || [])
|
||||||
// 保存搜索历史
|
// 保存搜索历史
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { ShopGroupBuy, ShopGroupBuyRecord } from '@/api/shop/shopGroupBuy/m
|
|||||||
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||||
import type { ShopGoodsSku } from '@/api/shop/shopGoodsSku/model'
|
import type { ShopGoodsSku } from '@/api/shop/shopGoodsSku/model'
|
||||||
import SkuSelector from '@/components/business/SkuSelector'
|
import SkuSelector from '@/components/business/SkuSelector'
|
||||||
|
import Price from '@/components/common/Price'
|
||||||
|
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: '拼团详情',
|
navigationBarTitleText: '拼团详情',
|
||||||
@@ -192,12 +193,12 @@ const GroupBuyDetailPage: React.FC = () => {
|
|||||||
{groupBuy.goodsName || groupBuy.product?.name}
|
{groupBuy.goodsName || groupBuy.product?.name}
|
||||||
</Text>
|
</Text>
|
||||||
<View className="flex items-baseline gap-2">
|
<View className="flex items-baseline gap-2">
|
||||||
<Text className="text-2xl font-bold text-red-500">
|
<Price
|
||||||
¥{groupBuy.groupPrice}
|
price={groupBuy.groupPrice}
|
||||||
</Text>
|
original={groupBuy.product?.price || 0}
|
||||||
<Text className="text-xs text-gray-400 line-through">
|
size='large'
|
||||||
¥{groupBuy.product?.price || 0}
|
loginMask
|
||||||
</Text>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View className="flex items-center gap-2 mt-1">
|
<View className="flex items-center gap-2 mt-1">
|
||||||
{isActive && remaining > 0 && (
|
{isActive && remaining > 0 && (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro'
|
|||||||
import { pageShopGroupBuy } from '@/api/shop/shopGroupBuy'
|
import { pageShopGroupBuy } from '@/api/shop/shopGroupBuy'
|
||||||
import type { ShopGroupBuy } from '@/api/shop/shopGroupBuy/model'
|
import type { ShopGroupBuy } from '@/api/shop/shopGroupBuy/model'
|
||||||
import EmptyState from '@/components/common/EmptyState'
|
import EmptyState from '@/components/common/EmptyState'
|
||||||
|
import Price from '@/components/common/Price'
|
||||||
|
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: '拼团活动',
|
navigationBarTitleText: '拼团活动',
|
||||||
@@ -91,12 +92,12 @@ const GroupBuyListPage: React.FC = () => {
|
|||||||
|
|
||||||
<View className='flex items-center justify-between mt-1'>
|
<View className='flex items-center justify-between mt-1'>
|
||||||
<View className='flex items-baseline gap-1'>
|
<View className='flex items-baseline gap-1'>
|
||||||
<Text className='text-lg font-bold text-red-500'>
|
<Price
|
||||||
{'\u00A5'}{item.groupPrice}
|
price={item.groupPrice}
|
||||||
</Text>
|
original={item.product?.price || 0}
|
||||||
<Text className='text-xs text-gray-400 line-through'>
|
size='small'
|
||||||
{'\u00A5'}{item.product?.price || 0}
|
loginMask
|
||||||
</Text>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
className='px-3 py-1 rounded-full text-white text-xs'
|
className='px-3 py-1 rounded-full text-white text-xs'
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import type { ShopSeckill } from '@/api/shop/shopSeckill/model'
|
|||||||
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
import type { ShopGoods } from '@/api/shop/shopGoods/model'
|
||||||
import type { ShopGoodsSku } from '@/api/shop/shopGoodsSku/model'
|
import type { ShopGoodsSku } from '@/api/shop/shopGoodsSku/model'
|
||||||
import SkuSelector from '@/components/business/SkuSelector'
|
import SkuSelector from '@/components/business/SkuSelector'
|
||||||
|
import Price from '@/components/common/Price'
|
||||||
|
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: '秒杀详情',
|
navigationBarTitleText: '秒杀详情',
|
||||||
@@ -199,12 +200,13 @@ const SeckillDetailPage: React.FC = () => {
|
|||||||
{/* 价格和倒计时 */}
|
{/* 价格和倒计时 */}
|
||||||
<View className="px-4 py-4" style={{ background: 'linear-gradient(135deg, #ef4444 0%, #dc2626 100%)' }}>
|
<View className="px-4 py-4" style={{ background: 'linear-gradient(135deg, #ef4444 0%, #dc2626 100%)' }}>
|
||||||
<View className="flex items-baseline gap-2">
|
<View className="flex items-baseline gap-2">
|
||||||
<Text className="text-3xl font-bold text-white">
|
<Price
|
||||||
¥{seckill.seckillPrice}
|
price={seckill.seckillPrice}
|
||||||
</Text>
|
original={seckill.product?.price || 0}
|
||||||
<Text className="text-sm text-red-200 line-through">
|
size='large'
|
||||||
¥{seckill.product?.price || 0}
|
color='#ffffff'
|
||||||
</Text>
|
loginMask
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View className="flex items-center justify-between mt-3">
|
<View className="flex items-center justify-between mt-3">
|
||||||
<View className="bg-white rounded px-2 py-1">
|
<View className="bg-white rounded px-2 py-1">
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro'
|
|||||||
import { pageShopSeckill } from '@/api/shop/shopSeckill'
|
import { pageShopSeckill } from '@/api/shop/shopSeckill'
|
||||||
import type { ShopSeckill } from '@/api/shop/shopSeckill/model'
|
import type { ShopSeckill } from '@/api/shop/shopSeckill/model'
|
||||||
import EmptyState from '@/components/common/EmptyState'
|
import EmptyState from '@/components/common/EmptyState'
|
||||||
|
import Price from '@/components/common/Price'
|
||||||
|
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: '限时秒杀',
|
navigationBarTitleText: '限时秒杀',
|
||||||
@@ -121,12 +122,12 @@ const SeckillListPage: React.FC = () => {
|
|||||||
|
|
||||||
<View className='flex items-center justify-between mt-1'>
|
<View className='flex items-center justify-between mt-1'>
|
||||||
<View className='flex items-baseline gap-1'>
|
<View className='flex items-baseline gap-1'>
|
||||||
<Text className='text-lg font-bold text-red-500'>
|
<Price
|
||||||
{'\u00A5'}{item.seckillPrice}
|
price={item.seckillPrice}
|
||||||
</Text>
|
original={item.product?.price || 0}
|
||||||
<Text className='text-xs text-gray-400 line-through'>
|
size='small'
|
||||||
{'\u00A5'}{item.product?.price || 0}
|
loginMask
|
||||||
</Text>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
className='px-3 py-1 rounded-full text-white text-xs'
|
className='px-3 py-1 rounded-full text-white text-xs'
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { listShopGoodsFavorite } from '@/api/shop/shopGoodsFavorite'
|
|||||||
import type { ShopGoodsFavorite } from '@/api/shop/shopGoodsFavorite/model'
|
import type { ShopGoodsFavorite } from '@/api/shop/shopGoodsFavorite/model'
|
||||||
import EmptyState from '@/components/common/EmptyState'
|
import EmptyState from '@/components/common/EmptyState'
|
||||||
import LoadMore from '@/components/common/LoadMore'
|
import LoadMore from '@/components/common/LoadMore'
|
||||||
|
import Price from '@/components/common/Price'
|
||||||
|
|
||||||
definePageConfig({
|
definePageConfig({
|
||||||
navigationBarTitleText: '我的收藏',
|
navigationBarTitleText: '我的收藏',
|
||||||
@@ -76,9 +77,9 @@ const FavoriteListPage: React.FC = () => {
|
|||||||
<Text className='text-sm text-gray-800 line-clamp-2 block'>
|
<Text className='text-sm text-gray-800 line-clamp-2 block'>
|
||||||
{item.goodsName}
|
{item.goodsName}
|
||||||
</Text>
|
</Text>
|
||||||
<Text className='text-red-500 text-sm font-medium mt-1 block'>
|
<View className='mt-1'>
|
||||||
¥{item.salePrice || '0'}
|
<Price price={item.salePrice || '0'} size='small' loginMask />
|
||||||
</Text>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user