Commit d786f09f authored by GuanHua's avatar GuanHua

feat:商品属性筛选修改

parent 0665293a
......@@ -2,20 +2,20 @@ import React from 'react'
import cx from 'classnames'
import { Skeleton } from 'antd'
import { LAYOUT_TYPE } from '@/constants'
import { GetSearchShopEnterpriseGetCommodityListResponseDetail } from '@/services/SearchApi'
import { PostSearchShopEnterpriseGetCommodityListResponseDetail } from '@/services/SearchApi'
import { priceFormat, numFormat } from '@/utils/numberFomat'
import creditIcon from '@/assets/imgs/credit_icon.png'
import styles from './list.less'
interface CommodityListPropsType {
showType: number;
commodityList: GetSearchShopEnterpriseGetCommodityListResponseDetail[]
commodityList: PostSearchShopEnterpriseGetCommodityListResponseDetail[]
layoutType: LAYOUT_TYPE
}
const CommodityList: React.FC<CommodityListPropsType> = (props) => {
const { showType, commodityList = [], layoutType = LAYOUT_TYPE.mall } = props
const renderPrice = (commodityItem: GetSearchShopEnterpriseGetCommodityListResponseDetail) => {
const renderPrice = (commodityItem: PostSearchShopEnterpriseGetCommodityListResponseDetail) => {
switch (commodityItem.priceType) {
// 现货价格
case 1:
......
......@@ -40,6 +40,28 @@ const getItemText = (key: number) => {
return result
}
const changeAttributeDate = (list) => {
if (!list) {
return []
}
let flag = false
list = list.map(item => {
delete item.customerAttributeName
if (item.customerAttributeValueList && item.customerAttributeValueList.length <= 0) {
delete item.customerAttributeValueList
delete item.customerAttributeId
flag = true
} else {
item.customerAttributeValueList = item.customerAttributeValueList.map(attrItem => {
delete attrItem.name
return attrItem
})
}
return item
})
return flag ? [] : list
}
class FilterStore {
/**
* 筛选条件列表
......@@ -120,7 +142,7 @@ class FilterStore {
for (let filterItem of newFilterList) {
switch (filterItem.type) {
case FILTER_TYPE.category:
tempFilterParam.categoryId = filterItem.key[0]
tempFilterParam.categoryId = Number(filterItem.key[0])
break
case FILTER_TYPE.brand:
tempFilterParam.brandId = filterItem.key
......@@ -158,7 +180,9 @@ class FilterStore {
tempFilterParam.orderType = 4
break
case FILTER_TYPE.attribute:
tempFilterParam.customerAttributeList = filterItem.key
let attributeList = JSON.parse(filterItem.key)
attributeList = changeAttributeDate(attributeList)
tempFilterParam.customerAttributeList = attributeList
break
case FILTER_TYPE.shopArea:
tempFilterParam.areaCode = filterItem.key
......
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