Commit cce650bb authored by GuanHua's avatar GuanHua

feat:添加渠道自由商城路由到白名单

parent 52275304
......@@ -54,7 +54,15 @@ const mallLists = [
'/channelmall/infomation/detail',
'/channelmall/infomation/search',
'/channelmall/about',
'/channel/purchaseOrder'
'/ichannelmall',
'/ichannelmall/commodity',
'/ichannelmall/commodity/search',
'/ichannelmall/commodity/detail',
'/ichannelmall/pointsMall',
'/ichannelmall/infomation',
'/ichannelmall/infomation/detail',
'/ichannelmall/infomation/search',
'/ichannelmall/about',
]
// let routeAuthUrls: any[] = []
......
......@@ -18,7 +18,7 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
const [maxCount, setMaxCount] = useState<number>()
useEffect(() => {
if (min) {
if (min || min === 0) {
setMinCount(min)
if (value < min) {
onChange(min)
......
......@@ -391,3 +391,19 @@ export enum OrderModalType {
*/
CHANNEL_SPOT_MANUAL_ORDER,
}
export enum COMMODITY_TYPE {
/**
* 现货商品
*/
prompt = 1,
/**
*询价商品
*/
inquiry = 2,
/**
* 积分商品
*/
integral = 3
}
......@@ -236,7 +236,7 @@ const CommoditySearch: React.FC<CommodityPropsType> = (props) => {
</div>
</div>
{
(commodityList.length === 0 || !commodityList) ? <SearchNoResult search={search} /> : (
(commodityList.length === 0 || !commodityList) ? !loading && <SearchNoResult search={search} /> : (
<>
<Spin spinning={loading}>
<CommodityList showType={showType} commodityList={commodityList} layoutType={layoutType} />
......
......@@ -4,6 +4,7 @@ import Comment from './components/Comment'
import Introduction from './components/Introduction'
import TradeRecord from './components/TradeRecord'
import Recommand from './components/Recommand'
import { COMMODITY_TYPE } from '@/constants'
import { GetSearchShopStoreGetCommodityDetailResponse } from '@/services/SearchApi'
import cx from 'classnames'
import styles from './index.less'
......@@ -23,6 +24,7 @@ const ProductDescription: React.FC<ProductDescriptionPropsType> = (props) => {
setCurrentAnchor(currentActiveLink)
}
}
return (
<div className={styles.product_description} id="product_description">
<Anchor
......@@ -31,7 +33,7 @@ const ProductDescription: React.FC<ProductDescriptionPropsType> = (props) => {
onChange={handleAnchorChange}
>
<Link className={cx(currentAnchor === "#introduction" ? 'active' : '')} href="#introduction" title="产品简介" />
<Link href="#trade_record" title="交易记录(2)" />
<Link href="#trade_record" title={commodityDetail?.priceType === COMMODITY_TYPE.integral ? `兑换记录(2)` : `交易记录(2)`} />
<Link href="#comment" title="交易评价(96)" />
<BackTop className={styles.buy_now_btn} visibilityHeight={800} >立即订购</BackTop>
</Anchor>
......
......@@ -120,6 +120,11 @@
text-align: center;
cursor: pointer;
&>a {
display: block;
color: #333333;
}
&:hover {
background-color: #f5f5f5;
}
......
import React from 'react'
import { Rate } from 'antd'
import { Link } from 'umi'
import shop_icon from '@/assets/imgs/shop_icon.png'
import credit_icon from '@/assets/imgs/credit_icon.png'
import styles from './index.less'
const ShopInfo: React.FC = () => {
interface ShopInfoPropsType {
shopInfo: any;
shopUrlParam: string;
}
const ShopInfo: React.FC<ShopInfoPropsType> = (props) => {
const { shopInfo, shopUrlParam } = props
return (
<div className={styles.shop_info}>
......@@ -13,7 +20,7 @@ const ShopInfo: React.FC = () => {
<div className={styles.shop_info_title_text}>会员认证</div>
<div className={styles.shop_info_title_split}></div>
</div>
<div className={styles.shop_name}>温州市龙昌皮具有限公司</div>
<div className={styles.shop_name}>{shopInfo?.company}</div>
<div className={styles.shop_about}>
<div className={styles.shop_about_item}>
<i className={styles.icon}><img src={shop_icon} /></i>
......@@ -45,7 +52,7 @@ const ShopInfo: React.FC = () => {
</div>
<div className={styles.dashed_split}></div>
<div className={styles.shop_info_btn_group}>
<div className={styles.shop_info_btn}>进入店铺</div>
<div className={styles.shop_info_btn}><Link to={`/shop?shopId=${shopUrlParam}`}>进入店铺</Link></div>
<div className={styles.shop_info_btn}>收藏本店</div>
</div>
<div className={styles.apply_member_btn}>申请成为本店会员</div>
......
......@@ -63,7 +63,7 @@ const CommodityDetail = (props) => {
const [commodityDetail, setCommodityDetail] = useState<GetSearchShopStoreGetCommodityDetailResponse>()
const [attrAndValList, setAttrAndValList] = useState<any>({})
const [selectAttrVal, setSelectAttrVal] = useState<selectAttrValType[]>([])
const [stockCount, setStockCount] = useState<number>(2000)
const [stockCount, setStockCount] = useState<number>(0)
const [commodityImgList, setCommodityImgList] = useState<imgItemType[]>([])
const [commodityPriceInfo, setCommodityPriceInfo] = useState([])
const [parameter, setParameter] = useState<number>() // 权益参数
......@@ -93,6 +93,7 @@ const CommodityDetail = (props) => {
}
getDetailFn(params).then(res => {
if (res.code === 1000) {
// res.data.priceType = 3
setCommodityDetail(res.data)
initAttributeAndValueList(res.data)
getPayWayListByMemberId(res.data?.memberId)
......@@ -205,7 +206,7 @@ const CommodityDetail = (props) => {
setCurrentPriceRange(item.unitPrice)
setAttrAndValList(item)
setStockCount(item.stockCount || 2000)
setStockCount(item.stockCount)
}
}
}
......@@ -351,19 +352,21 @@ const CommodityDetail = (props) => {
const renderBtn = () => {
switch (commodityDetail?.priceType) {
case COMMODITY_TYPE.prompt:
return (
return stockCount > 0 ? (
<>
<Button disabled={stockCount <= 0} className={cx(styles.product_info_btn_item, styles.buy)} onClick={() => handleToBuy()}>立即订购</Button>
<div className={cx(styles.product_info_btn_item, styles.add)} onClick={() => handleAddToPurchase()} >
<Button disabled={stockCount <= 0} className={cx(styles.product_info_btn_item, styles.add)} onClick={() => handleAddToPurchase()} >
<img className={styles.btn_icon} src={jinhuodanIcon} />
<span>加入进货单</span>
</div>
</Button>
</>
)
) : (
<Button className={cx(styles.product_info_btn_item, styles.buy)} >暂无库存</Button>
)
case COMMODITY_TYPE.inquiry:
return <div className={cx(styles.product_info_btn_item, styles.buy)}>立即询价</div>
case COMMODITY_TYPE.integral:
return <div className={cx(styles.product_info_btn_item, styles.buy)}>立即兑换</div>
return stockCount > 0 ? <div className={cx(styles.product_info_btn_item, styles.buy)}>立即兑换</div> : <Button className={cx(styles.product_info_btn_item, styles.buy)} >暂无库存</Button>
}
}
......@@ -423,7 +426,7 @@ const CommodityDetail = (props) => {
}
}
setCurrentPriceRange(unitPriceAndPicList[0].unitPrice)
setStockCount(unitPriceAndPicList[0].stockCount || 2000)
setStockCount(unitPriceAndPicList[0].stockCount)
setCommodityImgList(tempImgList)
setAttributeList(tempAttrList)
}
......@@ -521,10 +524,10 @@ const CommodityDetail = (props) => {
/**
* 获取合计金额
*/
const getAmount = () => {
const getAmount = (state = true) => {
let unitPrice = getUnitPrice()
let amount = unitPrice * (Number(buyCount) || 0)
return priceFormat(amount)
return state ? priceFormat(amount) : amount
}
/**
......@@ -561,7 +564,7 @@ const CommodityDetail = (props) => {
tempList.push(temp)
}
}
if (newSelectAttrVal.length < attributeList.length && selectAttrVal[0].attrId === attrId) {
if (newSelectAttrVal.length <= attributeList.length && selectAttrVal[0].attrId === attrId) {
return true
}
result = tempList.some(item => item.some(childItem => childItem.attrId === attrId && childItem.attrValId === attrValId))
......@@ -641,7 +644,12 @@ const CommodityDetail = (props) => {
<div className={styles.product_info_line_list}>
{
item.customerAttributeValueList.map((childItem, index) => (
<div key={`product_info_line_list_item_${childItem.id}`} className={cx(styles.product_info_line_list_item, judgeSelectAttrInList(selectAttrVal, childItem.id, 'attrValId') ? styles.active : '', judgeHasAttr(item.customerAttribute.id, childItem.id) ? '' : styles.disabled)} onClick={() => handleSelectAttrVal(item.customerAttribute.id, childItem.id)} >
<div
key={`product_info_line_list_item_${childItem.id}`}
className={cx(styles.product_info_line_list_item,
judgeSelectAttrInList(selectAttrVal, childItem.id, 'attrValId') ? styles.active : '',
judgeHasAttr(item.customerAttribute.id, childItem.id) ? '' : styles.disabled)}
onClick={() => handleSelectAttrVal(item.customerAttribute.id, childItem.id)} >
{
childItem.commodityPic && (
<div className={styles.imgbox}>
......@@ -661,13 +669,16 @@ const CommodityDetail = (props) => {
{
commodityDetail?.priceType === COMMODITY_TYPE.integral && (
<div className={styles.product_info_line}>
<div className={styles.product_info_line_label}>所需积分</div>
<div className={styles.product_info_line_brief}>
<span className={styles.text}>{commodityPriceInfo && commodityPriceInfo[0]?.price}</span>
<div className={styles.product_info_line_label}>
所需积分
<Tooltip placement="top" title="可使用平台通用积分或商户积分进行兑换">
<QuestionCircleOutlined />
</Tooltip>
</div>
<div className={styles.product_info_line_brief}>
<span className={styles.text}>{commodityPriceInfo && commodityPriceInfo[0]?.price}</span>
</div>
</div>
)
}
......@@ -734,7 +745,7 @@ const CommodityDetail = (props) => {
</div>
<div className={styles.commodity_detail_body}>
<div className={styles.commodity_detail_body_left}>
<ShopInfo />
<ShopInfo {...props} />
<Interested />
</div>
<div className={styles.commodity_detail_body_right}>
......
......@@ -4,6 +4,8 @@ import { Input } from 'antd'
import { history } from 'umi'
import { FileTextOutlined } from '@ant-design/icons'
import isEmpty from 'lodash/isEmpty'
import { PublicApi } from '@/services/api'
import { getAuth } from '@/utils/auth'
import styles from './index.less'
interface HeaderPropsType {
......@@ -14,7 +16,9 @@ const Header: React.FC<HeaderPropsType> = (props) => {
const { logo } = props
const [searchType, setSearchType] = useState<number>(1) // 1:商品; 2:店铺
const [searchValue, setSearchValue] = useState<string>("")
const [count, setCount] = useState<number>(0)
const { search } = history.location.query
useEffect(() => {
if (!!search) {
setSearchValue(search)
......@@ -23,6 +27,18 @@ const Header: React.FC<HeaderPropsType> = (props) => {
}
}, [search])
useEffect(() => {
if (getAuth()) {
getPurchaseCount()
}
}, [])
const getPurchaseCount = () => {
PublicApi.getProductPurchaseGetPurchaseCount().then(res => {
setCount(res.data)
})
}
const handleChangeSearchType = (type: number) => {
if (searchType !== type) {
setSearchType(type)
......@@ -63,7 +79,7 @@ const Header: React.FC<HeaderPropsType> = (props) => {
</div>
</div>
<div className={cx(styles.shopping_cart, styles.mall)} onClick={() => history.push('/purchaseOrder')}>
<div className={styles.badge}>0</div>
<div className={styles.badge}>{count}</div>
<FileTextOutlined className={styles.card_icon} />
<span>进货单</span>
</div>
......
......@@ -236,6 +236,11 @@
background-color: #f5f5f5;
}
&>a {
display: block;
color: #333333;
}
&:last-child {
margin-left: 6px;
}
......
import React, { useState, useEffect } from 'react'
import { CaretDownOutlined } from '@ant-design/icons'
import { Rate, Input } from 'antd'
import { history } from 'umi'
import { history, Link } from 'umi'
import isEmpty from 'lodash/isEmpty'
import logo from '@/theme/imgs/logo_w.png'
import shop_icon from '@/assets/imgs/shop_icon.png'
......@@ -91,7 +91,7 @@ const ShopHeader: React.FC<ShopHeaderPropsType> = (props) => {
</div>
<div className={styles.dashed_split}></div>
<div className={styles.shop_info_btn_group}>
<div className={styles.shop_info_btn}>进入店铺</div>
<div className={styles.shop_info_btn}><Link to={`/shop?shopId=${shopUrlParam}`}>进入店铺</Link></div>
<div className={styles.shop_info_btn}>收藏本店</div>
</div>
<div className={styles.apply_member_btn}>申请成为本店会员</div>
......
......@@ -40,6 +40,7 @@ const Order: React.FC<OrderPropsType> = (props) => {
const [needTheContract, setneedTheContract] = useState<boolean>(false)
const [selectAddressInfo, setSelectAddressInfo] = useState<GetLogisticsReceiverAddressGetResponse>()
const [selectInvoiceInfo, setSelectInvoiceInfo] = useState<any>()
const [logisticsFee, setLogisticsFee] = useState<number>(0)
useEffect(() => {
if (!spam_id) {
......@@ -124,12 +125,48 @@ const Order: React.FC<OrderPropsType> = (props) => {
return amount
}
useEffect(() => {
getLogisticsFeeAnync()
}, [selectAddressInfo])
const getLogisticsFeeAnync = async () => {
if (selectAddressInfo) {
let orderProductList = []
for (let item of orderInfo.orderList) {
for (let orderItem of item.orderList) {
let templateId = orderItem.logistics?.templateId
// 判断是否物流的方式和由买家承担费用并使用了运费模板
if (orderItem.logistics?.deliveryType === 1 && orderItem.logistics?.carriageType === 1 && orderItem.logistics?.useTemplate && templateId) {
orderProductList.push({
templateId,
weight: orderItem.logistics?.weight,
})
}
}
}
if (orderProductList.length > 0) {
let params: any = {
orderProductList,
receiverAddressId: selectAddressInfo.id
}
try {
const res: any = await PublicApi.postLogisticsFreightTemplateCalFreightPrice(params)
message.destroy()
setLogisticsFee(Number(res.data))
} catch (error) { }
}
}
}
/**
* 获取物流费用
*/
const getLogisticsFee = () => {
let fee = 0
return fee
return logisticsFee
}
const getAmount = () => {
console.log(getCommodityAmount(), getLogisticsFee())
return priceFormat(getCommodityAmount() + getLogisticsFee())
}
......
......@@ -200,6 +200,16 @@
outline: none;
cursor: pointer;
&[disabled] {
cursor: not-allowed;
color: rgba(0, 0, 0, 0.25);
background: #f5f5f5;
border-color: #d9d9d9;
text-shadow: none;
box-shadow: none;
}
&:hover {
opacity: .9;
}
......
......@@ -68,7 +68,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
})
})
// TODO 暂时给个库存数量
item.stockCount = item.stockCount || 2000
item.stockCount = item.stockCount
item.commodityUnitPrice['priceRange'] = tempPriceRange
tempItem.orderList = [...tempItem.orderList, item]
}
......@@ -92,8 +92,8 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
price: unitPrice[key]
})
})
// TODO 暂时给个库存数量
item.stockCount = item.stockCount || 2000
item.stockCount = item.stockCount
item.commodityUnitPrice['priceRange'] = tempPriceRange
temp.orderList = [item]
result.push(temp)
......@@ -577,7 +577,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
}
</div>
<div className={cx(styles.order_list_item_item, styles.count)}>
<InputNumber disabled={true} max={childItem.stockCount || 0} min={1} value={childItem.count} onChange={(value) => handleCountChange(value, childItem.id)} />
<InputNumber disabled={true} max={childItem.stockCount || 0} min={0} value={childItem.count} onChange={(value) => handleCountChange(value, childItem.id)} />
<div className={styles.stock}>(库存{numFormat(childItem.stockCount)}{childItem.commodityUnitPrice.commodity.unitName})</div>
</div>
<div className={cx(styles.order_list_item_item, styles.amount)}>
......@@ -623,7 +623,7 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
<b className={styles.settlement_box_item_price_total}>{handleComputeSelectPrice()}</b>
<span>RMB</span>
</div>
<Button loading={confirmLoading} className={styles.settlement_box_item_btn} onClick={() => handleSettlement()}>结算</Button>
<Button disabled={handleComputeSelectCount() <= 0} loading={confirmLoading} className={styles.settlement_box_item_btn} onClick={() => handleSettlement()}>结算</Button>
</div>
</div>
</Affix>
......
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