mobilePage.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const importPhone = document.querySelector('.import-phone');
  2. const importCode = document.querySelector('.import-code');
  3. const gain = document.querySelector('.gain');
  4. const loginbtn = document.querySelector('.loginbtn');
  5. var time = 120;
  6. //.addEventListener('click',bindingPhone ,false)
  7. //gain.addEventListener('click',bindingCode ,false)
  8. function bindingPhone () {
  9. var phoneValue = importPhone.value;
  10. var codeValue = importCode.value;
  11. 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}$/;
  12. if ( phoneValue == '' ) {
  13. alert('请输入手机号');
  14. } else{
  15. if(myreg.test(phoneValue)) {
  16. alert ('请输入正确的手机号');
  17. }else if(codeValue == '') {
  18. alert('请输入验证码');
  19. }
  20. }
  21. }
  22. function bindingCode () {
  23. //获取验证码
  24. var theCountdown;
  25. theCountdown = setInterval(function(){
  26. time--;
  27. gain.innerHTML = time + "秒重新获取"
  28. gain.setAttribute('disabled', true)
  29. if(time < 1) {
  30. clearInterval(theCountdown)
  31. time = 120;
  32. gain.innerHTML = "发送验证码";
  33. gain.setAttribute('disabled', false);
  34. }
  35. }, 1000)
  36. }
  37. //调用示例dialog(false);
  38. //弹窗方法success如果true则绑定成功否则绑定失败
  39. function dialog (success) {
  40. var dialog = document.createElement('div');
  41. dialog.className = 'dialog';
  42. var bindTxt = document.createElement('img');
  43. bindTxt.className = 'bind-txt';
  44. var cha = document.createElement('img');
  45. cha.className = 'cha';
  46. cha.setAttribute('src', 'http://ottbase.ai160.com/templates/image/cha.png')
  47. if(success) {
  48. bindTxt.setAttribute('src', 'http://ottbase.ai160.com/templates/image/bind_success.png')
  49. }else {
  50. bindTxt.setAttribute('src', 'http://ottbase.ai160.com/templates/image/bind_error.png')
  51. }
  52. dialog.appendChild(bindTxt);
  53. dialog.appendChild(cha);
  54. document.querySelector('.container').appendChild(dialog);
  55. cha.onclick = function () {
  56. dialog.style.display = 'none';
  57. }
  58. }