var numArray = new Array("139","138","137","136","135","134","159","158","157","150","151","152","188","187","182","183","184","178","130","131","132","156","155","186","185","176","133","153","189","180","181","177"); //这是目前找到的除了数据卡外的手机卡前三位,类型是字符串数组
var numList = ""; //创建一个数组用来存放10个手机号
var arraryLength = numArray.length; //获取数组长度,这样如果手机号前三位取值单位发生变化,在下一步求i的地方就不用修改随机数取值范围了
for( var n = 0; n < 10; n++){
var i = parseInt( Math.random() * arraryLength); //注意乘以的是上面numArray数组的长度,这样就可以取出数组中的随机一个数。random的取值范围是大于等于0.0,小于1.0,相乘后得到的就是0到(数组长度-1)的值。
var num = numArray[i]; //取出随机的手机号前三位并赋值给num,手机号前三位是字符串类型的
for ( var j = 0; j < 8; j++){
num = num + Math.floor(Math.random() * 10); //num是字符串,后面的数字被当做字符串。所以变成两个字符串拼接了
}
if(n == 0){
numList = numList + num; //第一个手机号前不出现“,”
}else{
numList = numList + "," + num;//从第一个手机号后面到最后一个之前用逗号分隔
}
}
var arr = numList.split(',');
var str = '';
for (j = 0; j < arr.length; j++){
var adj = arr[j].slice(0, 3) + '****' + arr[j].slice(arr[j].length - 4, arr[j].length);
str += "<div class='swiper-slide'>"+adj+"<span>预约成功</span>"+"</div>";
}
$(".rolling_display_wrapper").html(str);
var rolling_display = new Swiper('.rolling_display', {
direction: 'vertical',
loop: true, // 循环模式选项
autoplay: {
delay: 0,//1秒切换一次
},
speed: 2000,
observer:true,//修改swiper自己或子元素时,自动初始化swiper
observeParents:true,//修改swiper的父元素时,自动初始化swiper
});
07-19
5850
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
01-02
2412
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-14