计算价格精度计算处理decimal.jsimportDecimalfrom'decimal.js'constcalculation=(data:any,type:number)=>{const{priceProductShow,priceProductDiscount,skuNum}=dataconstmoney=newDecimal(priceProductShow)constcount=newDecimal(priceProductDiscount)constnum=newDecimal(skuNum)constadd=money.mul(num).add(count).toNumber()lettemp=0if(type===1){temp=newDecimal(totalMoney).add(newDecimal(add)).toNumber()}else{temp=newDecimal(totalMoney).sub(newDecimal(add)).toNumber()}returntemp}加密工具crypto-jsimportCryptoJSfrom'crypto-js';constaesPassword=(password:any)=>{constp=password.split('');如果(p.length!==16){for(leti=p.length;i<16;i++){p[i]='';}}consttxt=CryptoJS.enc.Utf8.parse(p.join(''));constkey=CryptoJS.enc.Utf8.parse('test');constiv=CryptoJS.enc.Utf8.parse('test2');constaesPassword=CryptoJS.AES.en密码crypt(txt,key,{iv,模式:CryptoJS.mode.CBC,填充:CryptoJS.pad.ZeroPadding,});返回aesPassword.ciphertext.toString(CryptoJS.enc.Base64);};
