属性随机使用既有方法

This commit is contained in:
luying
2020-12-23 11:52:02 +08:00
parent af8c89db20
commit 9746f53570
3 changed files with 36 additions and 25 deletions
+13
View File
@@ -293,6 +293,19 @@ export function getRandValue(base: number, ratio: number, decimal = 2): number {
return parseFloat((base * (1 - ratio + Math.random() * ratio * 2)).toFixed(decimal));
}
/**
* 在给定最大最小值中随机一个值
* @param min 最小
* @param max 最大
* @param decimal 返回值保留的小数位数
*/
export function getRandValueByMinMax(min: number, max: number, decimal = 2): number {
return parseFloat((min + (max - min) * Math.random()).toFixed(decimal));
}
export function resResult(status: {code: number, simStr: string}, data = null, customMsg = '') {
const { code, simStr } = status;
if (code !== STATUS.SUCCESS.code) {