mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-07 21:15:47 +08:00
bug(积分商品):
This commit is contained in:
@@ -3,16 +3,19 @@
|
||||
* See LICENSE file for license details.
|
||||
*/
|
||||
.sp-point {
|
||||
font-family: PingFangSC-Regular, PingFang SC;
|
||||
font-family: D-DIN-PRO, D-DIN-PRO;
|
||||
font-weight: 600;
|
||||
font-size: 34px;
|
||||
line-height: 1;
|
||||
.point {
|
||||
font-size: 32px;
|
||||
color: var(--color-primary);
|
||||
margin-right: 4px;
|
||||
}
|
||||
.unit {
|
||||
font-size: 26px;
|
||||
font-family: D-DIN-PRO, D-DIN-PRO;
|
||||
font-weight: 500;
|
||||
font-size: 24px;
|
||||
line-height: 1;
|
||||
color: var(--color-primary);
|
||||
// position: relative;
|
||||
// top: -2px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect } from 'react'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { SpImage, SpPrice } from '@/components'
|
||||
import { SpImage, SpPrice, SpPoint } from '@/components'
|
||||
import SpTag from '@/components/sp-tag/index'
|
||||
import Taro from '@tarojs/taro'
|
||||
import qs from 'qs'
|
||||
@@ -15,6 +15,7 @@ function SpGoodsCompactCard(props) {
|
||||
mode = 'aspectFill',
|
||||
top,
|
||||
showTop,
|
||||
showPrice = true,
|
||||
onClickGio = () => {},
|
||||
onChangeRegionauth = () => {}
|
||||
} = props
|
||||
@@ -26,7 +27,7 @@ function SpGoodsCompactCard(props) {
|
||||
onClick(info)
|
||||
return
|
||||
}
|
||||
const { itemId, distributorId } = info
|
||||
const { itemId, distributorId, point } = info
|
||||
let query = { id: itemId }
|
||||
if (typeof distributorId !== 'undefined') {
|
||||
query = {
|
||||
@@ -34,7 +35,9 @@ function SpGoodsCompactCard(props) {
|
||||
dtid: distributorId
|
||||
}
|
||||
}
|
||||
const url = `/pages/item/espier-detail?${qs.stringify(query)}`
|
||||
const url = point
|
||||
? `/subpages/pointshop/espier-detail?${qs.stringify(query)}`
|
||||
: `/pages/item/espier-detail?${qs.stringify(query)}`
|
||||
onChangeRegionauth(info)
|
||||
Taro.navigateTo({
|
||||
url
|
||||
@@ -114,28 +117,32 @@ function SpGoodsCompactCard(props) {
|
||||
|
||||
<View className='sp-goods-compact-card__price'>
|
||||
<View className='price-wrapper'>
|
||||
<SpPrice
|
||||
className='current-price'
|
||||
size={34}
|
||||
value={finalPrice}
|
||||
style={{ marginRight: '6px' }}
|
||||
weight={600}
|
||||
/>
|
||||
|
||||
{Number(info.marketPrice || 0) > 0 &&
|
||||
Number(finalPrice || 0) < Number(info.marketPrice || 0) && (
|
||||
{info.point != null && info.point !== '' ? (
|
||||
<SpPoint value={info.point} />
|
||||
) : showPrice ? (
|
||||
<>
|
||||
<SpPrice
|
||||
size={24}
|
||||
noSymbol
|
||||
// noDecimal
|
||||
className='market-price'
|
||||
lineThrough
|
||||
value={info.marketPrice}
|
||||
className='current-price'
|
||||
size={34}
|
||||
value={finalPrice}
|
||||
style={{ marginRight: '6px' }}
|
||||
weight={600}
|
||||
/>
|
||||
)}
|
||||
{Number(info.marketPrice || 0) > 0 &&
|
||||
Number(finalPrice || 0) < Number(info.marketPrice || 0) && (
|
||||
<SpPrice
|
||||
size={24}
|
||||
noSymbol
|
||||
className='market-price'
|
||||
lineThrough
|
||||
value={info.marketPrice}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
</View>
|
||||
|
||||
{info.discountRate && (
|
||||
{showPrice && !info.point && info.discountRate && (
|
||||
<View className='discount-tag'>
|
||||
<Text className='discount-tag__value'>{info.discountRate}</Text>
|
||||
<Text className='discount-tag__unit'>折</Text>
|
||||
@@ -161,6 +168,7 @@ SpGoodsCompactCard.defaultProps = {
|
||||
width: 218,
|
||||
top: 0,
|
||||
showTop: false,
|
||||
showPrice: true,
|
||||
onLoad: () => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { SpImage, SpPrice } from '@/components'
|
||||
import { SpImage, SpPrice, SpPoint } from '@/components'
|
||||
import SpTag from '@/components/sp-tag/index'
|
||||
import Taro from '@tarojs/taro'
|
||||
import qs from 'qs'
|
||||
@@ -8,17 +8,19 @@ import { classNames } from '@/utils'
|
||||
import './hero-card.scss'
|
||||
|
||||
function SpGoodsHeroCard(props) {
|
||||
const { info = null, onClick, mode = 'aspectFill' } = props
|
||||
const { info = null, onClick, mode = 'aspectFill', showPrice = true } = props
|
||||
|
||||
const handleClick = async () => {
|
||||
if (!info) return
|
||||
const { itemId, distributorId } = info
|
||||
const { itemId, distributorId, point } = info
|
||||
if (onClick) {
|
||||
onClick(info)
|
||||
return
|
||||
}
|
||||
let query = { id: itemId, dtid: distributorId ?? '' }
|
||||
const url = `/pages/item/espier-detail?${qs.stringify(query)}`
|
||||
const url = point
|
||||
? `/subpages/pointshop/espier-detail?${qs.stringify(query)}`
|
||||
: `/pages/item/espier-detail?${qs.stringify(query)}`
|
||||
Taro.navigateTo({
|
||||
url
|
||||
})
|
||||
@@ -88,29 +90,35 @@ function SpGoodsHeroCard(props) {
|
||||
)}
|
||||
<View className='sp-goods-hero-card__price'>
|
||||
<View className='price-wrapper'>
|
||||
<SpPrice
|
||||
className='current-price'
|
||||
size={34}
|
||||
value={finalPrice}
|
||||
style={{ marginRight: '6px' }}
|
||||
weight={600}
|
||||
/>
|
||||
{Number(info.marketPrice || 0) > 0 &&
|
||||
Number(finalPrice || 0) < Number(info.marketPrice || 0) && (
|
||||
{info.point != null && info.point !== '' ? (
|
||||
<SpPoint value={info.point} />
|
||||
) : showPrice ? (
|
||||
<>
|
||||
<SpPrice
|
||||
size={24}
|
||||
noSymbol
|
||||
className='market-price'
|
||||
lineThrough
|
||||
value={info.marketPrice}
|
||||
className='current-price'
|
||||
size={34}
|
||||
value={finalPrice}
|
||||
style={{ marginRight: '6px' }}
|
||||
weight={600}
|
||||
/>
|
||||
)}
|
||||
{info.discountRate && (
|
||||
<View className='discount-tag'>
|
||||
<Text className='discount-tag__value'>{info.discountRate}</Text>
|
||||
<Text className='discount-tag__unit'>折</Text>
|
||||
</View>
|
||||
)}
|
||||
{Number(info.marketPrice || 0) > 0 &&
|
||||
Number(finalPrice || 0) < Number(info.marketPrice || 0) && (
|
||||
<SpPrice
|
||||
size={24}
|
||||
noSymbol
|
||||
className='market-price'
|
||||
lineThrough
|
||||
value={info.marketPrice}
|
||||
/>
|
||||
)}
|
||||
{info.discountRate && (
|
||||
<View className='discount-tag'>
|
||||
<Text className='discount-tag__value'>{info.discountRate}</Text>
|
||||
<Text className='discount-tag__unit'>折</Text>
|
||||
</View>
|
||||
)}
|
||||
</>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
@@ -130,6 +138,7 @@ SpGoodsHeroCard.defaultProps = {
|
||||
onClick: null,
|
||||
mode: 'aspectFill',
|
||||
width: 200,
|
||||
showPrice: true,
|
||||
onLoad: () => {}
|
||||
}
|
||||
|
||||
|
||||
@@ -550,5 +550,8 @@ export const WGT_SPEEDKILL_GOODS = {
|
||||
return (activity_price || price) / 100
|
||||
},
|
||||
discount_var: ({ discount_rate }) =>
|
||||
discount_rate ? String((discount_rate / 10).toFixed(1)) : null
|
||||
discount_rate ? String((discount_rate / 10).toFixed(1)) : null,
|
||||
// 积分商品:data_type=pointsmall_items 时接口返回,用于挂件展示积分不展示价格
|
||||
point: ({ point, point_exchange }) =>
|
||||
point != null ? point : point_exchange != null ? point_exchange : null
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import './index.scss'
|
||||
* @param {Array} props.goodsRightList - 右列商品列表(two布局时使用)
|
||||
* @param {Function} props.onClickItem - 商品点击回调函数
|
||||
* @param {string} props.classNamePrefix - CSS类名前缀,如 'wgt-goods', 'wgt-group' 等
|
||||
* @param {boolean} [props.showPrice=true] - 是否展示价格(积分商品时可传 false,由卡片根据 info.point 展示积分)
|
||||
*/
|
||||
export default function GoodsLayout(props) {
|
||||
const {
|
||||
@@ -25,7 +26,8 @@ export default function GoodsLayout(props) {
|
||||
goodsLeftList = [],
|
||||
goodsRightList = [],
|
||||
onClickItem,
|
||||
classNamePrefix = 'wgt-goods'
|
||||
classNamePrefix = 'wgt-goods',
|
||||
showPrice = true
|
||||
} = props
|
||||
|
||||
// 一列网格布局
|
||||
@@ -39,6 +41,7 @@ export default function GoodsLayout(props) {
|
||||
})}
|
||||
key={item.item_id}
|
||||
info={item}
|
||||
showPrice={showPrice}
|
||||
onClick={() => onClickItem(item, index + 1)}
|
||||
/>
|
||||
))}
|
||||
@@ -55,6 +58,7 @@ export default function GoodsLayout(props) {
|
||||
<SpGoodsHeroCard
|
||||
key={item.item_id}
|
||||
info={item}
|
||||
showPrice={showPrice}
|
||||
onClick={() => onClickItem(item, index + 1)}
|
||||
/>
|
||||
))}
|
||||
@@ -64,6 +68,7 @@ export default function GoodsLayout(props) {
|
||||
<SpGoodsHeroCard
|
||||
key={item.item_id}
|
||||
info={item}
|
||||
showPrice={showPrice}
|
||||
onClick={() => onClickItem(item, index + 1)}
|
||||
/>
|
||||
))}
|
||||
@@ -80,6 +85,7 @@ export default function GoodsLayout(props) {
|
||||
<SpGoodsHeroCard
|
||||
key={item.item_id}
|
||||
info={item}
|
||||
showPrice={showPrice}
|
||||
onClick={() => onClickItem(item, index + 1)}
|
||||
/>
|
||||
))}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import React, { useState, useEffect, useMemo, useContext, useCallback } from 'react'
|
||||
import Taro, { useDidShow } from '@tarojs/taro'
|
||||
import { View, Text } from '@tarojs/components'
|
||||
import { SpImage } from '@/components'
|
||||
import { SpImage, SpPoint } from '@/components'
|
||||
import { classNames, styleNames, linkPage, pickBy, getDistributorId } from '@/utils'
|
||||
import { getBrowseHistoryList } from '@/utils/browseHistory'
|
||||
import doc from '@/doc'
|
||||
@@ -29,6 +29,7 @@ export default function WgtGoods(props) {
|
||||
const data = params.data || {}
|
||||
|
||||
const { onAddToCart } = useContext(WgtsContext)
|
||||
const isPointsmallItems = base.dataType === 'pointsmall_items'
|
||||
|
||||
// 获取外层样式(包含 outerMargin 和背景配置)
|
||||
const outerStyle = useMemo(() => {
|
||||
@@ -121,8 +122,15 @@ export default function WgtGoods(props) {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理商品点击
|
||||
// 处理商品点击:积分商品跳积分详情,否则走 linkPage
|
||||
const handleClickItem = (item) => {
|
||||
const itemId = item.item_id ?? item.itemId
|
||||
if (isPointsmallItems || item.point != null) {
|
||||
Taro.navigateTo({
|
||||
url: `/subpages/pointshop/espier-detail?id=${itemId}`
|
||||
})
|
||||
return
|
||||
}
|
||||
linkPage({
|
||||
linkPage: 'goods',
|
||||
id: item.goodsId || item.item_id || item.itemId
|
||||
@@ -199,15 +207,21 @@ export default function WgtGoods(props) {
|
||||
<View className='wgt-goods__activity-item-title'>
|
||||
{item.itemName || item.title}
|
||||
</View>
|
||||
<View className='wgt-goods__activity-item-price'>
|
||||
<Text className='wgt-goods__activity-item-price__unit'>¥</Text>
|
||||
<Text className='wgt-goods__activity-item-price__text'>
|
||||
{item.mainPrice ||
|
||||
(item.activityPrice
|
||||
? item.activityPrice.toFixed(2)
|
||||
: item.price?.toFixed(2) || '0.00')}
|
||||
</Text>
|
||||
</View>
|
||||
{isPointsmallItems ? (
|
||||
<View className='wgt-goods__activity-item-point'>
|
||||
<SpPoint value={item.point ?? item.point_exchange ?? 0} />
|
||||
</View>
|
||||
) : (
|
||||
<View className='wgt-goods__activity-item-price'>
|
||||
<Text className='wgt-goods__activity-item-price__unit'>¥</Text>
|
||||
<Text className='wgt-goods__activity-item-price__text'>
|
||||
{item.mainPrice ||
|
||||
(item.activityPrice
|
||||
? item.activityPrice.toFixed(2)
|
||||
: item.price?.toFixed(2) || '0.00')}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
))}
|
||||
@@ -221,6 +235,7 @@ export default function WgtGoods(props) {
|
||||
goodsRightList={goodsRightList}
|
||||
onClickItem={handleClickItem}
|
||||
classNamePrefix='wgt-goods'
|
||||
showPrice={!isPointsmallItems}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user