✨ feat(ID1000829):【临】剪版下单米数调整为0.3米,每次新增时,整数累加,不要0.3+1这样累加
This commit is contained in:
parent
4788f2dca2
commit
990f5a9ff2
@ -37,13 +37,21 @@ const Counter = ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum
|
||||
return parseFloat(num)
|
||||
}
|
||||
|
||||
// 判断是否整数类型
|
||||
function isInteger(obj) {
|
||||
return (obj | 0) === obj
|
||||
}
|
||||
|
||||
// 加号
|
||||
const onPlus = (event) => {
|
||||
event.stopPropagation()
|
||||
if (disable) { return false }
|
||||
let num_res = Big(value).add(step).toNumber()
|
||||
num_res = num_res >= maxNum ? maxNum : num_res
|
||||
num_res = formatDigits(num_res)
|
||||
if (!isInteger(num_res)) {
|
||||
num_res = Math.trunc(num_res)
|
||||
}
|
||||
num_res = num_res >= maxNum ? maxNum : num_res
|
||||
setValue(num_res)
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
}
|
||||
@ -51,7 +59,14 @@ const Counter = ({ minNum = 0, maxNum = 10000, step = 1, digits = 0, defaultNum
|
||||
const minus = (event) => {
|
||||
event.stopPropagation()
|
||||
if (disable) { return false }
|
||||
let num_res = Big(value).minus(step).toNumber()
|
||||
let num_res = value
|
||||
// let num_res = Big(value).minus(step).toNumber()
|
||||
if (!isInteger(num_res)) {
|
||||
num_res = Math.trunc(num_res)
|
||||
}
|
||||
else {
|
||||
num_res = Big(value).minus(step).toNumber()
|
||||
}
|
||||
num_res = num_res < minNum ? minNum : num_res
|
||||
setValue(num_res)
|
||||
onClickBtn?.(parseFloat(num_res))
|
||||
|
||||
@ -44,7 +44,7 @@ const GoodsItem = (props: props) => {
|
||||
}
|
||||
if (props.modeFont == 1) {
|
||||
if (Number(res) < 0) {
|
||||
setValue({ count: 0.5 })
|
||||
setValue({ count: '' })
|
||||
}
|
||||
}
|
||||
if (props.modeFont == 2) {
|
||||
|
||||
@ -145,8 +145,8 @@ const Index = () => {
|
||||
item.buyNums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
item.nums = 0.5
|
||||
item.buyNums = 0.5
|
||||
item.nums = 0.3
|
||||
item.buyNums = 0.3
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
item.nums = 3
|
||||
@ -185,7 +185,13 @@ const Index = () => {
|
||||
const reduceNums = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
if (isInteger(item.nums)) {
|
||||
item.nums--
|
||||
}
|
||||
else {
|
||||
item.nums = Math.trunc(item.nums)
|
||||
}
|
||||
|
||||
if (search.modeId == 0) {
|
||||
if (item.nums < 1) {
|
||||
it.showInput = false
|
||||
@ -193,9 +199,9 @@ const Index = () => {
|
||||
}
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
if (item.nums < 0.5) {
|
||||
if (item.nums < 0.3) {
|
||||
it.showInput = false
|
||||
it.nums = 0.5
|
||||
it.nums = 0.3
|
||||
}
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
@ -214,7 +220,13 @@ const Index = () => {
|
||||
const handPlus = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
it.nums++
|
||||
if (isInteger(item.nums)) {
|
||||
item.nums++
|
||||
}
|
||||
else {
|
||||
item.nums++
|
||||
item.nums = Math.trunc(item.nums)
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
@ -289,11 +301,11 @@ const Index = () => {
|
||||
else if (search.modeId == 0 && (e.detail.value != '' || Number(e.detail.value) > 0)) {
|
||||
item.nums = e.detail.value
|
||||
}
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.5) {
|
||||
item.nums = 0.5
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.3) {
|
||||
item.nums = 0.3
|
||||
item.showInput = false
|
||||
}
|
||||
else if (search.modeId == 1 && Number(e.detail.value) >= 0.5) {
|
||||
else if (search.modeId == 1 && Number(e.detail.value) >= 0.3) {
|
||||
if (isInteger(Number(e.detail.value))) {
|
||||
item.nums = Number(e.detail.value)
|
||||
}
|
||||
|
||||
@ -88,8 +88,8 @@ const SearchPage = () => {
|
||||
item.buyNums = 1
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
item.nums = 0.5
|
||||
item.buyNums = 0.5
|
||||
item.nums = 0.3
|
||||
item.buyNums = 0.3
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
item.nums = 3
|
||||
@ -158,9 +158,13 @@ const SearchPage = () => {
|
||||
const handPlus = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
// if (it.nums > item.buyNums) {
|
||||
it.nums++
|
||||
// }
|
||||
if (isInteger(item.nums)) {
|
||||
item.nums++
|
||||
}
|
||||
else {
|
||||
item.nums++
|
||||
item.nums = Math.trunc(item.nums)
|
||||
}
|
||||
}
|
||||
return item
|
||||
})
|
||||
@ -197,7 +201,13 @@ const SearchPage = () => {
|
||||
const reduceNums = useCallback((item) => {
|
||||
goodList.map((it) => {
|
||||
if (item.id === it.id) {
|
||||
if (isInteger(item.nums)) {
|
||||
item.nums--
|
||||
}
|
||||
else {
|
||||
item.nums = Math.trunc(item.nums)
|
||||
}
|
||||
|
||||
if (search.modeId == 0) {
|
||||
if (item.nums < 1) {
|
||||
it.showInput = false
|
||||
@ -205,9 +215,9 @@ const SearchPage = () => {
|
||||
}
|
||||
}
|
||||
if (search.modeId == 1) {
|
||||
if (item.nums < 0.5) {
|
||||
if (item.nums < 0.3) {
|
||||
it.showInput = false
|
||||
it.nums = 0.5
|
||||
it.nums = 0.3
|
||||
}
|
||||
}
|
||||
if (search.modeId == 2) {
|
||||
@ -321,11 +331,11 @@ const SearchPage = () => {
|
||||
else if (search.modeId == 0 && (e.detail.value != '' || Number(e.detail.value) > 0)) {
|
||||
item.nums = e.detail.value
|
||||
}
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.5) {
|
||||
item.nums = 0.5
|
||||
if (search.modeId == 1 && Number(e.detail.value) < 0.3) {
|
||||
item.nums = 0.3
|
||||
item.showInput = false
|
||||
}
|
||||
else if (search.modeId == 1 && Number(e.detail.value) >= 0.5) {
|
||||
else if (search.modeId == 1 && Number(e.detail.value) >= 0.3) {
|
||||
if (isInteger(Number(e.detail.value))) {
|
||||
item.nums = Number(e.detail.value)
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ export const selectList = {
|
||||
eunit: 'm',
|
||||
step: 1,
|
||||
digits: 2,
|
||||
minNum: 0.5,
|
||||
maxNum: 9.99,
|
||||
minNum: 0.3,
|
||||
maxNum: 100000,
|
||||
defaultNum: 1,
|
||||
},
|
||||
2: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user