Commit 4835f050 authored by GuanHua's avatar GuanHua

feat:会员折扣价格计算

parent 5d5cd2df
......@@ -19,6 +19,8 @@ export default {
'menu.shopCommodity': '商品',
'menu.shopCommoditySearch': '商品搜索',
'menu.shopCommodityDetail': '商品详情',
'menu.channelCommodityDetail': '商品详情',
'menu.channelmallCommoditySearch': '商品搜索',
'menu.purchaseOnline': '在线求购',
'menu.pointsMall': '积分商城',
'menu.shopPointsMall': '积分兑换',
......
......@@ -259,9 +259,9 @@ const Commodity: React.FC<CommodityPropsType> = (props) => {
<div className={styles.commodity_container}>
<Filter filterConfig={filterConfig} {...props} />
<div className={styles.commodity_main}>
<div className={styles.banner}>
{/* <div className={styles.banner}>
<img src={bannerImg} />
</div>
</div> */}
<div className={styles.tool_bar}>
<div className={styles.tool_bar_left}>
<div className={styles.tool_bar_filter_item} onClick={() => handleSort(FILTER_TYPE.soldSort)}>
......
......@@ -465,6 +465,10 @@ const CommodityDetail = (props) => {
}
}
}
// 会员折扣价格
if (parameter) {
unitPrice = unitPrice * parameter
}
return unitPrice
}
......
......@@ -24,14 +24,16 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const [categoryList, setCategoryList] = useState<any>([])
const [lastCategoryId, setLastCategoryId] = useState<number>()
const [attributeList, setAttributeList] = useState<any>([])
// const [selectAttrbuteList, setSelectAttrbuteList] = useState<any>([])
const [selectAttrbuteList, setSelectAttrbuteList] = useState<any>([])
useEffect(() => {
if (isEmpty(filterList)) {
setSelectedKeys([])
setLastCategoryId(null)
setSelectAttrbuteList([])
} else {
let initKeys = []
// let initAttrKeys = []
for (let item of filterList) {
if (item.type === FILTER_TYPE.category) {
initKeys.push(String(item.key))
......@@ -200,6 +202,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const handleChange = (attrId, checkedList) => {
setSelectAttrbuteList(checkedList)
let tempSelect = []
let attrInfo: any = getDetailById(attrId, attrId, 1)
let tempItem = {
......@@ -266,7 +269,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
title={attrItem.name}
>
<div className={styles.filter_style}>
<CheckboxGroup options={attrItem.attributeValueList} onChange={(val) => handleChange(attrItem.id, val)} />
<CheckboxGroup value={selectAttrbuteList} options={attrItem.attributeValueList} onChange={(val) => handleChange(attrItem.id, val)} />
</div>
</FilterBox>
))
......
......@@ -10,8 +10,9 @@ interface PricePropsType {
}
const Price: React.FC<PricePropsType> = (props) => {
const { onFilter } = props.FilterStore
const [priceRange, setPriceRange] = useState<any>([0, 900])
const { onFilter, filterList } = props.FilterStore
const MAX_COUNT = 900
const [priceRange, setPriceRange] = useState<any>([0, MAX_COUNT])
const handlePriceChange = (value) => {
setPriceRange(value)
......@@ -36,32 +37,40 @@ const Price: React.FC<PricePropsType> = (props) => {
const handleConfirmPriceRange = () => {
let min = priceRange[0]
let max = priceRange[1]
if (min === 900) {
if (min === MAX_COUNT) {
filterMinPrice(min)
} else if (min === 0 && max !== 900) {
filterMinPrice(min, false)
} else if (min === 0 && max !== MAX_COUNT) {
if (checkHasType(FILTER_TYPE.minPrice)) {
filterMinPrice(min, false)
}
filterMaxPrice(max)
} else if (min !== 0 && max === 900) {
} else if (min !== 0 && max === MAX_COUNT) {
filterMinPrice(min)
filterMaxPrice(max, false)
} else if ((min === 0 && max === 900) || (min !== 0 && max !== 900)) {
if (checkHasType(FILTER_TYPE.maxPrice)) {
filterMaxPrice(max, false)
}
} else if ((min === 0 && max === MAX_COUNT) || (min !== 0 && max !== MAX_COUNT)) {
filterMinPrice(min)
filterMaxPrice(max)
}
}
const checkHasType = (type) => {
return filterList.some(item => item.type === type)
}
return (
<FilterBox
title="价格"
>
<div className="filter_price">
<Slider range step={1} min={0} max={900} value={priceRange} onChange={handlePriceChange} />
<Slider range step={1} min={0} max={MAX_COUNT} value={priceRange} onChange={handlePriceChange} />
<div className="price_box">
<span className="price_box_brief">价格:</span>
<div className="price_range">
<span className="price">¥{priceRange[0]}</span>
<span className="split">-</span>
<span className="price">{priceRange[0] === 900 ? '' : `¥${priceRange[1]}`}</span>
<span className="price">{priceRange[0] === MAX_COUNT ? '' : `¥${priceRange[1]}`}</span>
</div>
<div className="confirm_btn" onClick={() => handleConfirmPriceRange()}>确定</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment