|
...
|
...
|
@@ -505,22 +505,36 @@ Page({ |
|
|
|
})
|
|
|
|
},
|
|
|
|
// 筛选出合适的充值优惠
|
|
|
|
findClosest (list,price){
|
|
|
|
let i=0;
|
|
|
|
let changzhi=0;
|
|
|
|
list.forEach((item,index)=>{
|
|
|
|
if (index==0) {
|
|
|
|
changzhi=Math.abs(price*1-item.recharge_money*1)
|
|
|
|
i=index
|
|
|
|
}else{
|
|
|
|
if (changzhi*1-Math.abs((price*1-item.recharge_money*1))>0) {
|
|
|
|
changzhi=Math.abs(price*1-item.recharge_money*1)
|
|
|
|
i=index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return list[i]
|
|
|
|
},
|
|
|
|
findClosest(list, price) {
|
|
|
|
if (list.length == 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
list.sort((i, t) => i.recharge_money - t.recharge_money)
|
|
|
|
let min = Math.abs(list[0].recharge_money - price) // 最小差值
|
|
|
|
let cur = 0 // 当前值
|
|
|
|
let isMax1001 = false
|
|
|
|
list.forEach(item => {
|
|
|
|
item.recharge_money = item.recharge_money * 1
|
|
|
|
if (item.recharge_money >= price) {
|
|
|
|
if (!isMax1001) {
|
|
|
|
min = Math.abs(item.recharge_money - price)
|
|
|
|
cur = item
|
|
|
|
isMax1001 = true
|
|
|
|
} else {
|
|
|
|
if (Math.abs(item.recharge_money - price) <= min) {
|
|
|
|
min = Math.abs(item.recharge_money - price)
|
|
|
|
cur = item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (Math.abs(item.recharge_money - price) <= min) {
|
|
|
|
min = Math.abs(item.recharge_money - price)
|
|
|
|
cur = item
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
return cur;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
...
|
...
|
|