提交 6bdbadcbac8b20e0f75e5477b02fcbcfe69273e1

作者 pangy
1 个父辈 9ffa318c

邮箱 银行卡

... ... @@ -887,6 +887,18 @@ Page({
887 887 this.showtoast('手机号码有误');
888 888 return
889 889 }
  890 + if (formdata.email && formdata.email.length > 0 && !regEmail.test(formdata.email)) {
  891 + this.showtoast('邮箱格式有误');
  892 + return
  893 + }
  894 + if (formdata.bank_account && formdata.bank_account.length > 0 && !format.banknoCheck(formdata.bank_account)) {
  895 + wx.showToast({
  896 + title: '银行卡号格式有误',
  897 + duration: 2000,
  898 + icon: 'none'
  899 + })
  900 + return
  901 + }
890 902 this.goCommit(formdata);
891 903 // else if (this.data.personstatusData.selected.length < 1) {
892 904 // this.showtoast('有必填项未填写');
... ... @@ -904,10 +916,6 @@ Page({
904 916 // this.showtoast('有必填项未填写');
905 917 // return
906 918 // } else
907   - // if (formdata.email && formdata.email.length > 0 && !regEmail.test(formdata.email)) {
908   - // this.showtoast('请输入正确邮箱');
909   - // return
910   - // }
911 919 //else if (this.data.investInfo.selected.length < 1) {
912 920 // this.showtoast('有必填项未填写');
913 921 // return
... ...
... ... @@ -114,7 +114,7 @@
114 114
115 115 <view class='item_body'>
116 116 <text class='text_666_30 float_left head_in' style='line-height: 90rpx'>电子邮箱</text>
117   - <input class='input_wrap' name='email' value='{{taxInfo.email}}' placeholder='请输入电子邮箱' placeholder-class='text_999_30' maxlength='20'></input>
  117 + <input class='input_wrap' name='email' value='{{taxInfo.email}}' placeholder='请输入电子邮箱' placeholder-class='text_999_30' maxlength='32'></input>
118 118 </view>
119 119 </view>
120 120
... ... @@ -148,7 +148,7 @@
148 148 <view class="divide_line_30"></view>
149 149 <view class='item_body'>
150 150 <text class='text_666_30 float_left head_in' style='line-height: 90rpx'>银行账号</text>
151   - <input class='input_wrap' name='bank_account' value='{{taxInfo.bank_account}}' placeholder-class='text_999_30' placeholder='请输入银行账号' maxlength='24' type='number'></input>
  151 + <input class='input_wrap' name='bank_account' value='{{taxInfo.bank_account}}' placeholder-class='text_999_30' placeholder='请输入银行账号' maxlength='19' type='number'></input>
152 152 </view>
153 153 <view class="divide_line_30"></view>
154 154 <template is="picker_cell_normal" data="{{...disabilityInfo}}" />
... ...
... ... @@ -165,6 +165,66 @@ function getAge(birthdate) {
165 165 return age;
166 166 }
167 167
  168 +//银行卡号码检测
  169 +function banknoCheck(bankno) {
  170 + var lastNum = bankno.substr(bankno.length - 1, 1); //取出最后一位(与luhn进行比较)
  171 + var first15Num = bankno.substr(0, bankno.length - 1); //前15或18位
  172 + var newArr = new Array();
  173 + for (var i = first15Num.length - 1; i > -1; i--) { //前15或18位倒序存进数组
  174 + newArr.push(first15Num.substr(i, 1));
  175 + }
  176 + var arrJiShu = new Array(); //奇数位*2的积 <9
  177 + var arrJiShu2 = new Array(); //奇数位*2的积 >9
  178 + var arrOuShu = new Array(); //偶数位数组
  179 + for (var j = 0; j < newArr.length; j++) {
  180 + if ((j + 1) % 2 == 1) { //奇数位
  181 + if (parseInt(newArr[j]) * 2 < 9) arrJiShu.push(parseInt(newArr[j]) * 2);
  182 + else arrJiShu2.push(parseInt(newArr[j]) * 2);
  183 + } else //偶数位
  184 + arrOuShu.push(newArr[j]);
  185 + }
  186 +
  187 + var jishu_child1 = new Array(); //奇数位*2 >9 的分割之后的数组个位数
  188 + var jishu_child2 = new Array(); //奇数位*2 >9 的分割之后的数组十位数
  189 + for (var h = 0; h < arrJiShu2.length; h++) {
  190 + jishu_child1.push(parseInt(arrJiShu2[h]) % 10);
  191 + jishu_child2.push(parseInt(arrJiShu2[h]) / 10);
  192 + }
  193 +
  194 + var sumJiShu = 0; //奇数位*2 < 9 的数组之和
  195 + var sumOuShu = 0; //偶数位数组之和
  196 + var sumJiShuChild1 = 0; //奇数位*2 >9 的分割之后的数组个位数之和
  197 + var sumJiShuChild2 = 0; //奇数位*2 >9 的分割之后的数组十位数之和
  198 + var sumTotal = 0;
  199 + for (var m = 0; m < arrJiShu.length; m++) {
  200 + sumJiShu = sumJiShu + parseInt(arrJiShu[m]);
  201 + }
  202 +
  203 + for (var n = 0; n < arrOuShu.length; n++) {
  204 + sumOuShu = sumOuShu + parseInt(arrOuShu[n]);
  205 + }
  206 +
  207 + for (var p = 0; p < jishu_child1.length; p++) {
  208 + sumJiShuChild1 = sumJiShuChild1 + parseInt(jishu_child1[p]);
  209 + sumJiShuChild2 = sumJiShuChild2 + parseInt(jishu_child2[p]);
  210 + }
  211 + //计算总和
  212 + sumTotal = parseInt(sumJiShu) + parseInt(sumOuShu) + parseInt(sumJiShuChild1) + parseInt(sumJiShuChild2);
  213 +
  214 + //计算luhn值
  215 + var k = parseInt(sumTotal) % 10 == 0 ? 10 : parseInt(sumTotal) % 10;
  216 + var luhn = 10 - k;
  217 +
  218 + if (lastNum == luhn) {
  219 + // $("#banknoInfo").html("luhn验证通过");
  220 + return true;
  221 + } else {
  222 + // $("#banknoInfo").html("银行卡号必须符合luhn校验");
  223 + return false;
  224 + }
  225 +}
  226 +
  227 +
168 228 module.exports = {
169 229 formatTime: formatTime,
170 230 formatTime_date: formatTime_date,
... ... @@ -178,5 +238,6 @@ module.exports = {
178 238 analyzeIDCard: analyzeIDCard,
179 239 checkNumber: checkNumber,
180 240 isMobile: isMobile,
181   - getAge: getAge
  241 + getAge: getAge,
  242 + banknoCheck: banknoCheck
182 243 }
... ...
注册登录 后发表评论