标签:nbsp ons and span max += == code bsp
微信随机红包,指定金额指定用户,随机发送红包
1 var moneys = new Array(); 2 var moneyTotal = 0; 3 function rand(obj){ 4 if(obj.size == 1){ 5 obj.size--; 6 moneyTotal+=obj.money; 7 moneys.push(obj.money); 8 obj.money=0; 9 return; 10 } 11 var r = Math.random(); 12 var min = 1; 13 if(obj.size <= 2){ 14 var max = obj.money / obj.size; 15 } else { 16 var max = obj.money / obj.size * 2; 17 } 18 var money = r * max; 19 money = Math.ceil(money); 20 money = money <= min ? 1 : money; 21 obj.size--; 22 obj.money -= money; 23 moneys.push(money); 24 moneyTotal+=money; 25 rand(obj); 26 } 27 var objs = {money:100,size:10}; 28 rand(objs); 29 console.log(moneys);
标签:nbsp ons and span max += == code bsp
原文地址:https://www.cnblogs.com/laushow/p/9077182.html