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
linweijiong
jinfa-platform
Commits
2f0b88d5
Commit
2f0b88d5
authored
Jan 05, 2021
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 商品单位是小数时,合计值问题
parent
6b1044b8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
index.tsx
src/pages/lxMall/commodityDetail/index.tsx
+27
-1
No files found.
src/pages/lxMall/commodityDetail/index.tsx
View file @
2f0b88d5
...
...
@@ -861,11 +861,37 @@ const CommodityDetail = (props) => {
*/
const
getAmount
=
(
state
=
true
)
=>
{
const
unitPrice
=
getUnitPrice
()
const
amount
=
unitPrice
*
(
Number
(
buyCount
)
||
0
)
const
amount
=
accMul
(
unitPrice
,
buyCount
)
return
state
?
priceFormat
(
amount
)
:
amount
}
/**
** 乘法函数,用来得到精确的乘法结果
** 说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。
** 调用:accMul(arg1,arg2)
** 返回值:arg1乘以 arg2的精确结果
**/
const
accMul
=
(
arg1
:
number
,
arg2
:
number
)
=>
{
if
(
!
arg1
||
!
arg2
){
return
0
}
let
m
=
0
const
s1
=
arg1
.
toString
()
const
s2
=
arg2
.
toString
()
try
{
m
+=
s1
.
split
(
"."
)[
1
].
length
;
}
catch
(
e
)
{
console
.
log
(
e
)
}
try
{
m
+=
s2
.
split
(
"."
)[
1
].
length
;
}
catch
(
e
)
{
console
.
log
(
e
)
}
return
Number
(
s1
.
replace
(
"."
,
""
))
*
Number
(
s2
.
replace
(
"."
,
""
))
/
Math
.
pow
(
10
,
m
);
}
/**
* 获取金额区间中数量最大的区间
*/
const
getMaxCountRange
=
()
=>
{
...
...
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