wuqy-methods
Version:
测试API时使用的方法
43 lines (42 loc) • 2.62 kB
JavaScript
function randomName() {
// prettier-ignore
const lastNames = ['赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '褚', '卫', '蒋', '沈', '韩', '杨', '朱', '秦', '尤', '许', '何', '吕', '施', '张', '孔', '曹', '严', '华', '金', '魏', '陶', '姜', '戚', '谢', '邹', '喻', '柏', '水', '窦', '章', '云', '苏', '潘', '葛', '奚', '范', '彭', '郎', '鲁', '韦', '昌', '马', '苗', '凤', '花', '方', '俞', '任', '袁', '柳', '酆', '鲍', '史', '唐', '费', '廉', '岑', '薛', '雷', '贺', '倪', '汤', '滕', '殷', '罗'];
// prettier-ignore
const firstNames = ["建国", "志强", "子轩", "小义", "明明", "永强", "虹", "志宏", "雅轩", "雨晴", "雪月", "小雪", "流星", "小雨", "无缺", "媛媛", "小妮", "小美", "白", "月亮", "伟", "国强", "诗雅", "杰伦", "杰", "英伦", "珍珠", "颖", "秀丽", "秀英", "桂英", "秀兰", "玉兰", "桂兰", "秀珍", "凤英", "玉珍", "玉英", "兰英", "欣怡", "梓涵", "诗涵", "梓宣", "子涵", "紫涵", "佳怡", "雨涵", "雨欣", "一诺", "星辰", "云山", "枕书", "念远", "枫", "松风", "泽同", "清宇", "浩然", "睿泽", "星河", "月华", "云霞", "山水", "清风", "明月", "碧海", "紫陌", "墨香", "锦绣", "瑞雪", "鸿鹄", "锦程", "雅致", "静谧", "永浩", "志豪", "广志", "智深", "飞燕", "雪莉", "雨婷", "雨蝶", "雪莲", "莉", "鹂", "鹏", "树人", "迅", "源", "亮", "飞", "雨墨", "留香", "云菲", "博", "立军", "志伟", "志高", "小鱼", "星宇", "星悦"];
return (
lastNames[Math.floor(Math.random() * lastNames.length)] +
firstNames[Math.floor(Math.random() * firstNames.length)]
);
}
function randomPhone() {
let phoneNumber = "1";
for (let i = 0; i < 10; i++) {
phoneNumber += Math.floor(Math.random() * 9);
}
return phoneNumber;
}
function randomOpenId() {
return "wx-1" + Math.floor(Math.random() * 1000000000);
}
// 阿拉伯数字转中文数字
function numberToZhNumber(num) {
const _num = num.toString();
const numArray = _num.split("");
const m = new Map();
m.set("1", "一");
m.set("2", "二");
m.set("3", "三");
m.set("4", "四");
m.set("5", "五");
m.set("6", "六");
m.set("7", "七");
m.set("8", "八");
m.set("9", "九");
m.set("0", "零");
const zhNumArray = numArray.map((v) => m.get(v));
return zhNumArray.join("");
}
function age() {
return Math.floor(Math.random() * 40 + 18);
}
export { randomName, randomPhone, randomOpenId, numberToZhNumber, age };