UNPKG

yqb

Version:

Static Package Manager

147 lines (128 loc) 4.1 kB
/* * * author: <%= author %> * version: <%= version %> * website: http://www.431103.com */ // @require api.js // @require sms.js // 全局配置 var config = { "businessId": $('.paf_register_module').data('businessid'), "channelId": $('.paf_register_module').data('channelid'), "activityId": until.GetUrlParms()['activityId'], "mcId": until.GetUrlParms()['WT.mc_id'], "oldCustomerId": until.GetUrlParms()['newCustomerId'] || until.GetUrlParms()['oldCustomerId'], "mobilePhone": '', "verifyCode": '', "isPassword": $('#pwd-control').data('pwd') }; var reg = new register(config); if (config.isPassword == true) { // 隐藏设置密码文本框 $('#pwd-control').show(); $.ajax({ contentType: "application/json", type: 'post', dataType: 'json', data: JSON.stringify({ operationType: 'op_query_public_key' }), url: until.getMTPURL() + '/mtp-web/h5/op_query_public_key.json', success: function(data) { if (data.resultCode == '1000') { window.PassEncryptor = { getData: function() { return { ts: data.timestamp, aPK: data.controllerPublicKey, hPK: data.securityPublicKey }; } }; } else { //console.log('公钥在哪呢?' + data.resultMsg); } }, error: function(data) { console.log('服务器被您玩坏了!!!'); } }); } else { // 活动是否进行中 reg.checkActivityStatus(function(code) {}, function(code) { // 活动已经结束 $.dialog({ content: '很遗憾,本次活动已结束,您可登录壹钱包关注其他活动', ok: function() { window.location.href = 'http://d.1qianbao.com/youqian/'; return false; } }); }); } var sms = new sendSMS(); $('#mobile-input').blur(sms.checkMobile); $('#reg').on('click tap', function() { // 校验表单不为空 if (!sms.checkMobile()) return; if (!sms.verifyOtp()) return; // 更新手机号&注册码 config.mobilePhone = $('#mobile-input').val(); config.verifyCode = $('#otp-input').val(); if (config.isPassword) { config.password = encryptorPassword($('#pwd-control').val()); // 密码强度 config.pwdStrength = setPwdStrength('#pwd-input'); } // reg.sendUserInfo(function(message, data) { var url = $('.paf_register_module').data('compeleteurl'); url += '?activityId=' + config.activityId; url += '&phone=' + config.mobilePhone; url += '&WT.mc_id=' + config.mcId; url += '&oldCustomerId=' + config.oldCustomerId; url += '&newCustomerId=' + data.uid; url += '&v=' + Math.random(); window.location.href = url; }, function(message, data) { // 注册失败提示信息 $('#otp-control').tips({ content: message }) }); // TJ.update($('.paf_register_module').data('agent'), config); }); // ------------------------------- function setPwdStrength(element) { var $element = $(element); var value = $element.val(); var strength = 0; if (/\d/.exec(value)) { strength++; } if (/[a-z]/.exec(value)) { strength++; } if (/[A-Z]/.exec(value)) { strength++; } if (/[-`=\\\[\];',.\/~!@#$%^&*()_+|{}:"<>?]+/.exec(value)) { strength++; } // if($element.length < 6) { // strength--; // } switch (strength) { case 0: case 1: console.log(strength) return "C"; case 2: return "B"; case 3: case 4: return "A"; } }