login.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var clientHeight = 0;
  2. $(document).ready(function() {
  3. // 初始化 传入dom id
  4. // var victor = new Victor("container", "output");
  5. // var color = ["#3b5ffc", "#076583"];
  6. // victor(color).set();
  7. // $("#output canvas").eq(0).remove();
  8. getHeight();
  9. });
  10. window.onresize = function() {
  11. getHeight();
  12. }
  13. function getHeight() {
  14. if($(window).height() > $(window).width()) {
  15. clientHeight = $(window).height();
  16. } else {
  17. clientHeight = ($(window).width()) * 1.3;
  18. }
  19. $(".lg-window").height(clientHeight);
  20. }
  21. //60秒倒计时事件
  22. var c = 60;
  23. var setbtn;
  24. function showLogin(url) {
  25. c -= 1;
  26. $("#lgWait").html(c + " s");
  27. if(c <= 0) {
  28. clearInterval(setbtn);
  29. $("#yzmParent").find("#lgWait").remove();
  30. $("#yzmParent").append('<button data-url="'+window._url+'" class="lg-list-btn" onclick="indentifying(this)">重新获取</button>');
  31. c = 60;
  32. }
  33. }
  34. //倒计时按钮
  35. function wait(obj) {
  36. alert('操作太过频繁!');
  37. }
  38. //获取验证码
  39. var apiurl = "";
  40. var datastr = {};
  41. window._url = "";
  42. function indentifying(obj) {
  43. if(!(/^1[34578]\d{9}$/.test($("#phone").val()))){
  44. layer.open({
  45. content: '手机号码格式错误!'
  46. ,skin: 'msg'
  47. ,time: 2 //2秒后自动关闭
  48. });
  49. return false;
  50. }
  51. var authenticate = $(document).find('#authenticate').val();
  52. var send_token_str = $(document).find('#send_token_str').val();
  53. if(authenticate=='' || send_token_str==''){
  54. layer.open({
  55. content: '滑块验证失败,请重新验证!'
  56. ,skin: 'msg'
  57. ,time: 2 //2秒后自动关闭
  58. });
  59. return false;
  60. }
  61. sendSms($(obj).data('url'));
  62. window._url = $(obj).data('url');
  63. // 验证码发送
  64. $(obj).remove();
  65. $("#yzmParent").append('<button id="lgWait" class="lg-list-btn" onclick="wait(this)" disabled="disabled">60&nbsp;s</button>');
  66. setbtn = setInterval("showLogin()", 1000);
  67. }
  68. function sendSms(url) {
  69. var _mobile = $(document).find('#phone').val();
  70. var authenticate = $(document).find('#authenticate').val();
  71. var send_token_str = $(document).find('#send_token_str').val();
  72. $.ajax({
  73. type: "post",
  74. url: url,
  75. dataType: 'json',
  76. data: {
  77. phone: _mobile,
  78. send_token_str: send_token_str,
  79. authenticate: authenticate,
  80. _token: $("#_token").val()
  81. },
  82. success:function (data) {
  83. if( data.code*1 == 1 ){
  84. layer.open({
  85. content: '发送成功'
  86. ,skin: 'msg'
  87. ,time: 2 //2秒后自动关闭
  88. });
  89. }else{
  90. layer.open({
  91. content: data.msg
  92. ,skin: 'msg'
  93. ,time: 2 //2秒后自动关闭
  94. });
  95. }
  96. }
  97. });
  98. }