Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄庭坚
jinfa-platform
Commits
1851a8ab
Commit
1851a8ab
authored
Sep 14, 2020
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:商品购买数量,单价计算
parent
f94b9266
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
28 deletions
+67
-28
index.tsx
src/components/InputNumber/index.tsx
+0
-2
index.tsx
src/pages/lxMall/commodityDetail/index.tsx
+19
-15
index.tsx
src/pages/lxMall/components/ChannelHeader/index.tsx
+25
-7
index.tsx
src/pages/lxMall/components/ShopHeader/index.tsx
+0
-1
LXChannelLayout.tsx
src/pages/lxMall/layouts/LXChannelLayout.tsx
+1
-1
index.tsx
src/pages/lxMall/purchaseOrder/index.tsx
+19
-0
request.ts
src/utils/request.ts
+3
-2
No files found.
src/components/InputNumber/index.tsx
View file @
1851a8ab
...
...
@@ -60,8 +60,6 @@ const InputNumber: React.FC<InputNumberPropsType> = (props) => {
Number
(
value
)
<
minCount
&&
onChange
(
minCount
)
Number
(
value
)
>
maxCount
&&
onChange
(
maxCount
)
}
}
return
(
...
...
src/pages/lxMall/commodityDetail/index.tsx
View file @
1851a8ab
...
...
@@ -18,6 +18,7 @@ import { GetSearchShopStoreGetCommodityDetailResponse } from '@/services/SearchA
import
{
numFormat
,
priceFormat
}
from
'@/utils/numberFomat'
import
jinhuodanIcon
from
'@/assets/imgs/jinhuodan.png'
import
styles
from
'./index.less'
import
{
isEmpty
}
from
'lodash'
enum
COMMODITY_TYPE
{
/**
...
...
@@ -196,7 +197,6 @@ const CommodityDetail = (props) => {
}
const
handleAddToPurchase
=
()
=>
{
if
(
!
selectCommodityId
)
{
message
.
destroy
()
message
.
info
(
"请选择商品属性"
)
...
...
@@ -407,6 +407,9 @@ const CommodityDetail = (props) => {
}
}
/**
* 根据购买的数量获取单前商品单价
*/
const
getUnitPrice
=
()
=>
{
let
unitPrice
=
0
if
(
!
commodityPriceInfo
)
{
...
...
@@ -419,30 +422,31 @@ const CommodityDetail = (props) => {
let
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<=
Number
(
item
.
max
)
})
if
(
isEmpty
(
temp
))
{
let
maxItem
=
getMaxCountRange
()
unitPrice
=
maxItem
.
price
}
else
{
unitPrice
=
temp
[
0
]?.
price
}
}
}
return
unitPrice
}
const
getAmount
=
()
=>
{
let
unitPrice
=
0
if
(
!
commodityPriceInfo
)
{
return
0
let
unitPrice
=
getUnitPrice
()
let
amount
=
unitPrice
*
(
Number
(
buyCount
)
||
0
)
return
priceFormat
(
amount
)
}
if
(
commodityDetail
?.
priceType
===
COMMODITY_TYPE
.
prompt
)
{
if
(
commodityPriceInfo
.
length
<=
1
)
{
unitPrice
=
commodityPriceInfo
[
0
]?.
price
}
else
{
let
temp
=
commodityPriceInfo
.
filter
(
item
=>
{
return
Number
(
buyCount
)
>=
Number
(
item
.
min
)
&&
Number
(
buyCount
)
<=
Number
(
item
.
max
)
})
unitPrice
=
temp
[
0
]?.
price
const
getMaxCountRange
=
()
=>
{
let
maxItem
:
any
=
{}
for
(
let
item
of
commodityPriceInfo
)
{
if
(
Number
(
item
.
max
)
>
Number
(
maxItem
.
max
||
0
))
{
maxItem
=
item
}
}
let
amount
=
unitPrice
*
(
Number
(
buyCount
)
||
0
)
return
priceFormat
(
amount
)
return
maxItem
}
/**
...
...
src/pages/lxMall/components/ChannelHeader/index.tsx
View file @
1851a8ab
import
React
,
{
useState
,
useEffect
}
from
'react'
import
{
history
}
from
'umi'
import
{
Input
}
from
'antd'
import
{
GetTemplateChannelFindChannelResponse
}
from
'@/services/TemplateApi'
import
logo
from
'@/theme/imgs/logo_w.png
'
import
isEmpty
from
'lodash/isEmpty
'
import
'./index.less'
interface
HeaderPropsType
{
shopInfo
:
GetTemplateChannelFindChannelResponse
shopInfo
:
GetTemplateChannelFindChannelResponse
,
id
:
number
,
shopUrlParam
:
string
,
}
const
Header
:
React
.
FC
<
HeaderPropsType
>
=
(
props
)
=>
{
const
{
shopInfo
}
=
props
const
{
id
,
shopUrlParam
,
shopInfo
}
=
props
const
[
searchValue
,
setSearchValue
]
=
useState
<
string
>
(
""
)
const
{
search
}
=
history
.
location
.
query
useEffect
(()
=>
{
// console.log(shopInfo, "shopInfo")
},
[
shopInfo
])
if
(
!!
search
)
{
setSearchValue
(
search
)
}
else
{
setSearchValue
(
""
)
}
},
[
search
])
const
handleSearchCommodity
=
()
=>
{
if
(
!
isEmpty
(
searchValue
))
{
history
.
push
(
`/channelmall/commodity/search?id=
${
shopUrlParam
}
&search=
${
encodeURIComponent
(
searchValue
)}
`
)
}
else
{
history
.
push
(
`/channelmall/commodity/search?id=
${
shopUrlParam
}
`
)
}
}
return
(
<
div
className=
"header"
>
...
...
@@ -22,8 +40,8 @@ const Header: React.FC<HeaderPropsType> = (props) => {
</
div
>
<
div
className=
"mall_search"
>
<
div
className=
"mall_search_box"
>
<
input
className=
"mall_search_input"
placeholder=
"请输入关键词"
/>
<
div
className=
"search_btn"
>
搜索
</
div
>
<
Input
className=
"mall_search_input"
value=
{
searchValue
}
placeholder=
"请输入关键词"
onChange=
{
e
=>
setSearchValue
(
e
.
target
.
value
)
}
onPressEnter=
{
()
=>
handleSearchCommodity
()
}
/>
<
div
className=
"search_btn"
onClick=
{
()
=>
handleSearchCommodity
()
}
>
搜索
</
div
>
</
div
>
</
div
>
</
div
>
...
...
src/pages/lxMall/components/ShopHeader/index.tsx
View file @
1851a8ab
...
...
@@ -6,7 +6,6 @@ import isEmpty from 'lodash/isEmpty'
import
logo
from
'@/theme/imgs/logo_w.png'
import
shop_icon
from
'@/assets/imgs/shop_icon.png'
import
credit_icon
from
'@/assets/imgs/credit_icon.png'
import
shopLogo
from
'@/assets/imgs/shop_logo.png'
import
{
GetTemplateShopFindShopResponse
}
from
'@/services/TemplateApi'
import
styles
from
'./index.less'
...
...
src/pages/lxMall/layouts/LXChannelLayout.tsx
View file @
1851a8ab
...
...
@@ -81,7 +81,7 @@ const LXChannelLayout: React.FC<LXMallLayoutPropsType> = (props) => {
{
!
menuRouter
?.
hideHeader
&&
(
<>
<
ChannelHeader
shopInfo=
{
shopInfo
}
/>
<
ChannelHeader
id=
{
query
.
shopId
}
shopUrlParam=
{
id
}
shopInfo=
{
shopInfo
}
/>
<
MainNav
menuData=
{
menuData
}
pathname=
{
location
.
pathname
}
type=
{
LAYOUT_TYPE
.
channel
}
shopId=
{
query
.
shopId
}
shopUrlParam=
{
id
}
/>
</>
)
...
...
src/pages/lxMall/purchaseOrder/index.tsx
View file @
1851a8ab
...
...
@@ -14,6 +14,7 @@ import { LAYOUT_TYPE } from '@/constants'
import
{
GetProductPurchaseGetPurchaseListResponse
}
from
'@/services/ProductApi'
import
{
GetTemplateChannelFindChannelResponse
}
from
'@/services/TemplateApi'
import
{
GlobalConfig
}
from
'@/global/config'
import
{
isEmpty
}
from
'lodash'
interface
PurchaseOrderPropsType
{
layoutType
:
LAYOUT_TYPE
,
...
...
@@ -227,6 +228,9 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
priceItem
=
item
}
}
if
(
isEmpty
(
priceItem
))
{
priceItem
=
getMaxCountRange
(
priceRange
)
}
return
parseFloat
(
priceItem
.
price
)
*
count
}
}
...
...
@@ -479,12 +483,27 @@ const PurchaseOrder: React.FC<PurchaseOrderPropsType> = (props) => {
let
temp
=
detail
.
priceRange
.
filter
(
item
=>
{
return
Number
(
count
)
>=
Number
(
item
.
min
)
&&
Number
(
count
)
<=
Number
(
item
.
max
)
})
if
(
isEmpty
(
temp
))
{
let
maxItem
=
getMaxCountRange
(
detail
.
priceRange
)
unitPrice
=
maxItem
.
price
}
else
{
unitPrice
=
temp
[
0
]?.
price
}
}
return
unitPrice
}
const
getMaxCountRange
=
(
priceRange
)
=>
{
let
maxItem
:
any
=
{}
for
(
let
item
of
priceRange
)
{
if
(
Number
(
item
.
max
)
>
Number
(
maxItem
.
max
||
0
))
{
maxItem
=
item
}
}
return
maxItem
}
return
(
<
div
className=
{
styles
.
purchase_order
}
>
<
div
className=
{
styles
.
purchase_order_container
}
>
...
...
src/utils/request.ts
View file @
1851a8ab
...
...
@@ -116,11 +116,12 @@ class ApiRequest {
baseRequest
<
IRequestSuccess
<
T
>>
(
url
,
options
).
then
(
res
=>
{
// 登录验证
if
(
res
.
code
===
1101
)
{
removeAuth
()
//
removeAuth()
// history.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
window
.
location
.
replace
(
`/user/login?redirect=
${
btoa
(
encodeURIComponent
(
String
(
window
.
location
)))}
`
)
//
window.location.replace(`/user/login?redirect=${btoa(encodeURIComponent(String(window.location)))}`)
message
.
destroy
()
message
.
error
(
res
.
message
)
reject
(
res
)
return
false
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment