1. 随机生成手机号:
const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
num1=randomInt(10000000,99999999)
var tel='186'+num1
pm.globals.set("tel", tel);
2. 随机生成姓名:
const FirstName = ['艾','倪','薛','屈','励','池','赵','钱','王','李','孙','周','吴'];
const Names = ['伟','刚','勇','彬','富','顺','信','弘','璐','凝','晓','欢','霄','枫','青','婷'];
const RandomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; //取某个数值范围内的随机整数
const getRandomValue = list => list[RandomInt(0, list.length - 1)]; //取某个数组内的随机数值
let EmployeeName = ''; //初始化
first = getRandomValue(FirstName); //随机取一个姓氏
second = getRandomValue(Names); //随机取Names的一个字
hasThird = RandomInt(0, 1); //使用RandomInt函数判断是否取名字的第二个字
third = "";
if (hasThird == 1)
{ third = Names[Math.floor(Math.random()*(Names.length-1))];}
var ChineseName = first + second + third;
pm.globals.set("Name",ChineseName);
console.log('time:',ChineseName)