Commit 5dc1400f authored by GuanHua's avatar GuanHua

Merge branch 'dev' into test

parents 8c5cd36e 115fcb15
......@@ -147,6 +147,7 @@ const Commodity: React.FC<CommodityPropsType> = (props) => {
getFn && getFn(param, { headers }).then(res => {
setLoading(false)
if (res.code === 1000) {
message.destroy()
setCommodityList(res.data.data)
setTotalCount(res.data.totalCount)
}
......
......@@ -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:
......
......@@ -142,6 +142,7 @@ const CommodityDetail = (props) => {
}
getListFn && getListFn(param, { headers }).then(res => {
if (res.code === 1000) {
message.destroy()
setCommonCategoryCommodityList(res.data.data)
}
})
......@@ -950,7 +951,7 @@ const CommodityDetail = (props) => {
<div className={cx(styles.add_success_btn, styles.primary)} onClick={() => history.push(getPurchaseOrderLink())}>去结算</div>
<div className={styles.add_success_btn} onClick={() => setAddSuccessVisible(false)}>继续购物</div>
</div>
<InterestedCommodity />
<InterestedCommodity dataList={commonCategoryCommodityList} {...props} />
</DialogModal>
</div>
)
......
......@@ -59,7 +59,7 @@
margin-top: 5px;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
-webkit-line-clamp: 1;
text-overflow: ellipsis;
overflow: hidden;
-webkit-box-orient: vertical;
......
import React from 'react'
import React, { useState, useEffect } from 'react'
import { LeftOutlined, RightOutlined } from '@ant-design/icons'
import cx from 'classnames'
import ImageBox from '@/components/ImageBox'
import { LAYOUT_TYPE } from '@/constants'
import { priceFormat } from '@/utils/numberFomat'
import styles from './index.less'
import url from '*.svg'
const InterestedCommodity: React.FC = () => {
interface InterestedCommodityPropsType {
dataList: any,
layoutType?: LAYOUT_TYPE
}
const InterestedCommodity: React.FC<InterestedCommodityPropsType> = (props) => {
const { dataList, layoutType } = props
const [list, setList] = useState<any>([])
const arrGroup = (array, subGroupLength) => {
let index = 0;
let newArray = [];
while (index < array.length) {
newArray.push(array.slice(index, index += subGroupLength));
}
return newArray;
}
let mockList = []
for (let i = 0; i < 5; i++) {
mockList.push({
url: "https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1.jpg",
name: '0.8-1.0mm黑色手纹硬度适中偏软偏软偏软',
price: '79.00'
})
useEffect(() => {
if (dataList) {
setList(arrGroup(dataList, 5))
}
}, [dataList])
const getCommodityDetailLink = (item) => {
let link = ""
switch (layoutType) {
case LAYOUT_TYPE.channel:
link = `/channelmall/commodity/detail?id=${item.id}&type=${item.priceType}&channelId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
case LAYOUT_TYPE.ichannel:
link = `/ichannelmall/commodity/detail?id=${item.id}&type=${item.priceType}&channelId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
default:
link = `/shop/commodity/detail?id=${item.id}&type=${item.priceType}&shopId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
}
return link
}
return (
<div className={styles.interested_commodity}>
<div className={styles.interested_commodity_title}>
<span>您可能也感兴趣:</span>
<div className={styles.interested_commodity_pagination}>
{/* <div className={styles.interested_commodity_pagination}>
<div className={cx(styles.interested_commodity_pagination_btn, styles.disabled)}><LeftOutlined /></div>
<div className={cx(styles.interested_commodity_pagination_btn)}><RightOutlined /></div>
</div>
</div> */}
</div>
<div className={styles.interested_commodity_list}>
{
mockList.map(item => (
<div className={styles.interested_commodity_list_item}>
dataList && dataList.map((item, index) => index < 5 && (
<div className={styles.interested_commodity_list_item} key={`interested_commodity_list_item_${item.id}`}>
<a href={getCommodityDetailLink(item)} target="_blank">
<div className={styles.interested_commodity_list_item_imgbox}>
<div className={styles.interested_commodity_list_item_imgbox_img} style={{ backgroundImage: `url(${item.url})` }}></div>
<ImageBox width={100} height={100} imgUrl={item.mainPic} direction="column" />
</div>
<div className={styles.interested_commodity_list_item_name}>{item.name}</div>
<div className={styles.interested_commodity_list_item_price}>
<i></i>
{item.price}
{priceFormat(item.min)}
</div>
</a>
</div>
))
}
</div>
</div>
)
......
import React from 'react'
import './index.less'
import React, { useEffect, useState } from 'react'
import { PublicApi } from '@/services/api'
import ImageBox from '@/components/ImageBox'
import { inject, observer } from 'mobx-react'
import { message } from 'antd'
import { LAYOUT_TYPE } from '@/constants'
import { priceFormat } from '@/utils/numberFomat'
import styles from './index.less'
const Recommand: React.FC = () => {
interface RecommandPropsType {
SiteStore?: any,
layoutType: LAYOUT_TYPE,
categoryIds: number[], // 商品品类集合
loading: boolean,
memberId?: number
}
const product_list = [
{
imgUrl: 'https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-6.jpg',
name: '0.8-1.0mm黑色手折纹胎水牛皮黄牛头层自然摔纹硬度适中偏软…',
price: '19.00'
},
{
imgUrl: 'https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-6.jpg',
name: '0.8-1.0mm黑色手折纹胎水牛皮黄牛头层自然摔纹硬度适中偏软…',
price: '19.00'
},
{
imgUrl: 'https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-6.jpg',
name: '0.8-1.0mm黑色手折纹胎水牛皮黄牛头层自然摔纹硬度适中偏软…',
price: '19.00'
},
{
imgUrl: 'https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-6.jpg',
name: '0.8-1.0mm黑色手折纹胎水牛皮黄牛头层自然摔纹硬度适中偏软…',
price: '19.00'
},
{
imgUrl: 'https://woodmartcdn-cec2.kxcdn.com/wp-content/uploads/2016/09/product-furniture-1-6.jpg',
name: '0.8-1.0mm黑色手折纹胎水牛皮黄牛头层自然摔纹硬度适中偏软…',
price: '19.00'
const Recommand: React.FC<RecommandPropsType> = (props) => {
const { mallTemplateId } = props.SiteStore
const { layoutType, categoryIds, loading, memberId } = props
const [list, setList] = useState<any>([])
useEffect(() => {
if (loading) {
if (categoryIds && categoryIds.length > 0) {
getCommodityListByCategoryIds()
} else {
getCategoryComponents()
}
}
}, [loading])
const getCommodityListByCategoryIds = async () => {
let result = []
for (let id of categoryIds) {
let resList: any = await getListById(id)
result = [...result, ...resList]
if (result && result.length >= 5) {
setList(result)
break
}
}
if (result.length <= 0) {
getCategoryComponents()
}
}
const changeDataKey = (data) => {
return data.map(item => {
item.id = item.goodsId
item.mainPic = item.goodsPicUrl
item.name = item.goodsName
item.min = item.goodsPrice
item.storeId = item.shopId
return item
})
}
const getListById = (categoryId: number) => {
return new Promise((resolve) => {
let param: any = {
current: 1,
pageSize: 5,
categoryId
}
let headers = {}
let getListFn
switch (layoutType) {
case LAYOUT_TYPE.channel:
headers = {
type: 3
}
param.channelMemberId = memberId
getListFn = PublicApi.postSearchShopChannelGetCommodityList
break
case LAYOUT_TYPE.ichannel:
headers = {
type: 4
}
param.channelMemberId = memberId
getListFn = PublicApi.postSearchShopChannelGetCommodityList
break
default:
getListFn = PublicApi.postSearchShopEnterpriseGetCommodityList
break
}
getListFn && getListFn(param, { headers }).then(res => {
if (res.code === 1000) {
message.destroy()
resolve(res.data.data)
}
})
})
}
/**
* 获取所有一级品类信息
*/
const fetchFirstCategory = () => {
return new Promise((resolve) => {
PublicApi.getTemplatePlatformFindAllFirstCategory().then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
/**
* 获取一级品类详细信息
*/
const fetchCategoryById = (categoryId) => {
return new Promise((resolve) => {
let param = {
templateId: mallTemplateId,
categoryId
}
// @ts-ignore
PublicApi.getTemplatePlatformFindFirstCategoryDetail(param).then(res => {
if (res.code === 1000) {
resolve(res.data)
}
})
})
}
const getCategoryComponents = async () => {
let firstCategory: any = await fetchFirstCategory()
let categoryDetail: any = await fetchCategoryById(firstCategory[0].id)
setList(changeDataKey(categoryDetail.goodsBOList))
}
const getCommodityDetailLink = (item) => {
let link = ""
switch (layoutType) {
case LAYOUT_TYPE.channel:
link = `/channelmall/commodity/detail?id=${item.id}&channelId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
case LAYOUT_TYPE.ichannel:
link = `/ichannelmall/commodity/detail?id=${item.id}&channelId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
default:
link = `/shop/commodity/detail?id=${item.id}&shopId=${btoa(JSON.stringify({ shopId: item.storeId, memberId: item.memberId }))}`
break
}
return link
}
]
return (
<div className="recommand">
<div className="recommand_title">买家还在看</div>
<div className="recommand_list">
<div className={styles.recommand}>
<div className={styles.recommand_title}>买家还在看</div>
<div className={styles.recommand_list}>
{
product_list.map((item, index) => (
<a href="/" key={`recommand_list_item_${index}`}>
<div className="recommand_list_item">
<div className="recommand_list_item_img">
<img src={item.imgUrl} />
list && list.map((item, index) => index < 5 && (
<a href={getCommodityDetailLink(item)} key={`recommand_list_item_${index}`} target="_blank">
<div className={styles.recommand_list_item}>
<div className={styles.recommand_list_item_img}>
<ImageBox width={224} height={224} imgUrl={item.mainPic} direction="column" />
</div>
<div className="recommand_list_item_price">
<div className={styles.recommand_list_item_price}>
<span></span>
{item.price}
{priceFormat(item.min)}
</div>
<div className="recommand_list_item_name">{item.name}</div>
<div className={styles.recommand_list_item_name}>{item.name}</div>
</div>
</a>
))
......@@ -56,4 +173,4 @@ const Recommand: React.FC = () => {
)
}
export default Recommand
export default inject('SiteStore')(observer(Recommand))
......@@ -96,6 +96,7 @@ const MallIndex: React.FC<MallIndexPropsType> = (props) => {
let firstCategory: any = await fetchFirstCategory()
for (let item of firstCategory) {
if (item.id) {
let categoryDetail: any = await fetchCategoryById(item.id)
result.push(
<FloorLine
......@@ -130,6 +131,7 @@ const MallIndex: React.FC<MallIndexPropsType> = (props) => {
</FloorLine>
)
}
}
setCategoryComponents(result)
}
......
......@@ -6,7 +6,7 @@ import { Pagination } from 'antd'
import CommodityList from './list'
import SearchNoResult from '../components/SearchNoResult'
import isEmpty from 'lodash/isEmpty'
import { Spin } from 'antd'
import { Spin, message } from 'antd'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import { PublicApi } from '@/services/api'
......@@ -102,6 +102,7 @@ const PointsMall: React.FC<CommodityPropsType> = (props) => {
getFn(param, { headers }).then(res => {
setLoading(false)
if (res.code === 1000) {
message.destroy()
setCommodityList(res.data.data)
setTotalCount(res.data.totalCount)
}
......
......@@ -31,12 +31,20 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
const [checkedList, setCheckedList] = useState([])
const [orderList, setOrderList] = useState([])
const [confirmLoading, setConfirmLoading] = useState<boolean>(false)
const [categoryIds, setCategoryIds] = useState<any>()
const [loading, setLoading] = useState<boolean>(false)
let countState = true
useEffect(() => {
fetchPurchaseList()
}, [])
useEffect(() => {
if (categoryIds) {
setLoading(true)
}
}, [categoryIds])
const fetchPurchaseList = (initState = false) => {
let getFn
switch (layoutType) {
......@@ -52,10 +60,26 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
getFn && getFn().then(res => {
if (res.code === 1000) {
initPurchaseList(res.data, initState)
getCategoryIds(res.data)
}
})
}
/**
* 获取进货单内商品品类id集合
* @param purchaseList
*/
const getCategoryIds = (purchaseList) => {
let ids = []
for (let item of purchaseList) {
let categoryId = item.commodityUnitPrice.commodity.customerCategory.id
if (!ids.includes(categoryId)) {
ids.push(categoryId)
}
}
setCategoryIds(ids)
}
const initPurchaseList = (list: GetSearchShopPurchaseGetPurchaseListResponse, initState) => {
let result = []
for (let item of list) {
......@@ -691,7 +715,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
</Affix>
)
}
<Recommand />
<Recommand loading={loading} categoryIds={categoryIds} {...props} />
</div>
</div>
)
......
import React, { useEffect, useState } from 'react'
import cx from 'classnames'
import { Rate, Pagination, Modal } from 'antd'
import { Rate, Pagination, Modal, message } from 'antd'
import { StarFilled } from '@ant-design/icons'
import shop_icon from '@/assets/imgs/shop_icon.png'
import credit_icon from '@/assets/imgs/credit_icon.png'
......@@ -67,10 +67,15 @@ const Shops: React.FC = () => {
}
const linkToDetail = (detail) => {
if (detail.status === 1) {
let el = document.createElement('a')
el.href = `/shop?shopId=${btoa(JSON.stringify({ shopId: detail.id, memberId: detail.memberId }))}`;
el.target = '_blank';
el.click()
} else {
message.destroy()
message.info("该店铺已冻结")
}
}
return (
......
......@@ -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