1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- const importPhone = document.querySelector('.import-phone');
- const importCode = document.querySelector('.import-code');
- const gain = document.querySelector('.gain');
- const loginbtn = document.querySelector('.loginbtn');
- var time = 120;
- //.addEventListener('click',bindingPhone ,false)
- //gain.addEventListener('click',bindingCode ,false)
- function bindingPhone () {
- var phoneValue = importPhone.value;
- var codeValue = importCode.value;
- const myreg=/^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\\d{8}$/;
- if ( phoneValue == '' ) {
- alert('请输入手机号');
- } else{
- if(myreg.test(phoneValue)) {
- alert ('请输入正确的手机号');
- }else if(codeValue == '') {
- alert('请输入验证码');
- }
- }
- }
- function bindingCode () {
- //获取验证码
- var theCountdown;
- theCountdown = setInterval(function(){
- time--;
- gain.innerHTML = time + "秒重新获取"
- gain.setAttribute('disabled', true)
- if(time < 1) {
- clearInterval(theCountdown)
- time = 120;
- gain.innerHTML = "发送验证码";
- gain.setAttribute('disabled', false);
- }
- }, 1000)
- }
- //调用示例dialog(false);
- //弹窗方法success如果true则绑定成功否则绑定失败
- function dialog (success) {
- var dialog = document.createElement('div');
- dialog.className = 'dialog';
- var bindTxt = document.createElement('img');
- bindTxt.className = 'bind-txt';
- var cha = document.createElement('img');
- cha.className = 'cha';
- cha.setAttribute('src', 'http://ottbase.ai160.com/templates/image/cha.png')
- if(success) {
- bindTxt.setAttribute('src', 'http://ottbase.ai160.com/templates/image/bind_success.png')
- }else {
- bindTxt.setAttribute('src', 'http://ottbase.ai160.com/templates/image/bind_error.png')
- }
- dialog.appendChild(bindTxt);
- dialog.appendChild(cha);
- document.querySelector('.container').appendChild(dialog);
- cha.onclick = function () {
- dialog.style.display = 'none';
- }
- }
|