You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
596 B
32 lines
596 B
/* 操作数量:常用于商品数量操作
|
|
---------------------------------------------------------------*/
|
|
export default {
|
|
//增
|
|
increase(curr, max, min = 1) {
|
|
let n = parseInt(curr);
|
|
max = parseInt(max);
|
|
min = parseInt(min);
|
|
if (n >= max) {
|
|
n = max;
|
|
} else if (n < min) {
|
|
n = min;
|
|
} else {
|
|
n++;
|
|
}
|
|
return n;
|
|
},
|
|
//减
|
|
decrease(curr, max, min = 1) {
|
|
let n = parseInt(curr);
|
|
max = parseInt(max);
|
|
min = parseInt(min);
|
|
if (n > max) {
|
|
n = max;
|
|
} else if (n <= min) {
|
|
n = min;
|
|
} else {
|
|
n--;
|
|
}
|
|
return n;
|
|
}
|
|
};
|
|
|