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; } } }