Skip to content

Commit

Permalink
feat: wxa:mock增加银行卡模拟
Browse files Browse the repository at this point in the history
  • Loading branch information
szyuan committed Jan 21, 2020
1 parent f3114ab commit 6faca00
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/wxa-cli/src/resolvers/directive/mock/mock-extends.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default function extend(random) {
return {
// 身份证号
idNo,
bankcardNo,
// 星座
constellation
}
Expand All @@ -13,6 +14,10 @@ function idNo(oldest, youngest) {
return getIDCardNo(this, oldest, youngest);
}

function bankcardNo() {
return getBankCardNo(this);
}

function constellation(rule) {
let constellations = ['白羊座', '金牛座', '双子座', '巨蟹座', '狮子座', '处女座', '天秤座', '天蝎座', '射手座', '摩羯座', '水瓶座', '双鱼座']
return this.pick(constellations)
Expand Down Expand Up @@ -44,8 +49,22 @@ function getIDCardNo(mock, oldest, youngest) {
}


// 生成银行卡号
function getBankCardNo(mock) {
let prefixList = ['622202','622848','622700','622262','621661'];
let noList = [1,2,3,4,5,6,7,8,9,0]
let prefixNo = mock.pick(prefixList);
let cardNo = prefixNo;
let cardNoLen = 7;
for(let i = 0; i < cardNoLen; i++) {
cardNo += mock.pick(noList);
}
return cardNo;
}

function paddingZero(num) {
let number = num + '';
let res = (Number(num) > 9) ? number : 0 + number;
return res;
}

0 comments on commit 6faca00

Please sign in to comment.