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.
44 lines
1.1 KiB
44 lines
1.1 KiB
10 months ago
|
import { BigNumber } from 'bignumber.js';
|
||
|
export default {
|
||
|
//加法
|
||
|
add(a, b) {
|
||
|
a = BigNumber(a);
|
||
|
b = BigNumber(b);
|
||
|
return a.plus(b).toNumber(); //结果需要用toNumber转为普通数字
|
||
|
},
|
||
|
//减法
|
||
|
minus(a, b) {
|
||
|
a = BigNumber(a);
|
||
|
b = BigNumber(b);
|
||
|
return a.minus(b).toNumber();
|
||
|
},
|
||
|
//乘法
|
||
|
mutiply(a, b) {
|
||
|
a = BigNumber(a);
|
||
|
b = BigNumber(b);
|
||
|
return a.multipliedBy(b).toNumber();
|
||
|
},
|
||
|
//除法
|
||
|
devide(a, b) {
|
||
|
a = BigNumber(a);
|
||
|
b = BigNumber(b);
|
||
|
return a.dividedBy(b).toNumber();
|
||
|
},
|
||
|
//多个数求和
|
||
|
multiAdd(...params) {
|
||
|
let data = BigNumber(0);
|
||
|
for (let index = 0; index < params.length; index++) {
|
||
|
const element = BigNumber(params[index]);
|
||
|
data = data.plus(element);
|
||
|
}
|
||
|
return data.toNumber();
|
||
|
},
|
||
|
tel(phone){
|
||
|
const reg = /^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/
|
||
|
if(!reg.test(phone)){
|
||
|
return false;
|
||
|
}else{
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|