login.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*登录时是否为空判断*/
  2. /*密码登录*/
  3. var bool=true;
  4. var mobile=null;
  5. var yanzhengma=null;
  6. $('#login-pwd').on('click', function() {
  7. var phone=$("input[name='phone']").val();
  8. var pwd = $("input[name='pwd']").val();
  9. if(phone==null || phone==undefined ||phone==""){
  10. alert("电话号码为空无法登录");
  11. }else{
  12. checkPhone();
  13. }
  14. if(pwd==null || pwd==undefined ||pwd==""){
  15. alert("请输入密码");
  16. }
  17. });
  18. /*手机验证码登录*/
  19. $('#login-mobile').on('click', function() {
  20. var mobile=$("input[name='mobile']").val();
  21. yanzhengma = $("input[name='yanzhengma']").val();
  22. if(mobile==null || mobile==undefined ||mobile==""){
  23. alert("电话号码为空无法登录");
  24. bool = false;
  25. }else if(!(/^1[34578]\d{9}$/.test(mobile))){
  26. alert("手机号码格式错误");
  27. bool = false;
  28. }
  29. if(yanzhengma==null || yanzhengma==undefined ||yanzhengma==""){
  30. alert("验证码为空");
  31. bool = false;
  32. }else if(yanzhengma.length<6){
  33. alert("验证码为6位");
  34. bool = false;
  35. }
  36. });
  37. function checkPhone(){
  38. var phone = $("phone").val();
  39. if(!(/^1[34578]\d{9}$/.test(phone))){
  40. alert("手机号码格式错误");
  41. bool= false;
  42. }
  43. }
  44. /*点击短信登录*/
  45. $("#message").click(function(){
  46. $(this).css("display","none");
  47. $("#user-phone").css("display","block");
  48. $("#phone-pwdd").css("display","none");
  49. $("#phone-yanzhengma").css("display","block");
  50. $("#111").css("display","none");
  51. $("#222").css("display","block")
  52. })
  53. $("#user-phone").click(function(){
  54. $(this).css("display","none");
  55. $("#222").css("display","none");
  56. $("#111").css("display","block");
  57. $("#message").css("display","block");
  58. $("#phone-yanzhengma").css("display","none");
  59. $("#phone-pwdd").css("display","block");
  60. })
  61. $("#callback").click(function(){
  62. $("#bbb").css("display","none");
  63. $("#aaa").css("display","block");
  64. })
  65. $("#weixin-login").click(function(){
  66. $("#bbb").css("display","block");
  67. $("#aaa").css("display","none");
  68. })
  69. /*验证码倒数60s*/
  70. $('#getting').click(function(){
  71. mobile=$("input[name='mobile']").val();
  72. debugger
  73. if(mobile==null || mobile==undefined ||mobile==""){
  74. alert("电话号码为空无法获取验证码");
  75. bool = false;
  76. }else{
  77. var btn = $(this);
  78. var count = 60;
  79. var resend = setInterval(function(){
  80. count--;
  81. if (count > 0){
  82. btn.val(count+"秒后可重新获取");
  83. $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
  84. }else {
  85. clearInterval(resend);
  86. btn.val("获取验证码").removeAttr('disabled style');
  87. }
  88. }, 1000);
  89. btn.attr('disabled',true).css('cursor','not-allowed');
  90. }
  91. });
  92. /*忘记密码弹框*/
  93. $(function ($) {
  94. //弹出登录
  95. $("#example").hover(function () {
  96. $(this).stop().animate({
  97. opacity: '1'
  98. }, 600);
  99. }, function () {
  100. $(this).stop().animate({
  101. opacity: '0.6'
  102. }, 1000);
  103. }).on('click', function () {
  104. debugger
  105. $("body").append("<div id='mask'></div>");
  106. $("#mask").addClass("mask").fadeIn("slow");
  107. $("#LoginBox").fadeIn("slow");
  108. });
  109. //
  110. //按钮的透明度
  111. $("#loginbtn").hover(function () {
  112. $(this).stop().animate({
  113. opacity: '1'
  114. }, 600);
  115. }, function () {
  116. $(this).stop().animate({
  117. opacity: '0.8'
  118. }, 1000);
  119. });
  120. //文本框不允许为空---按钮触发
  121. $("#loginbtn").on('click', function () {
  122. var txtName = $("#txtName").val();
  123. var txtPwd = $("#txtPwd").val();
  124. if (txtName == "" || txtName == undefined || txtName == null) {
  125. if (txtPwd == "" || txtPwd == undefined || txtPwd == null) {
  126. $(".warning").css({ display: 'block' });
  127. }
  128. else {
  129. $("#warn").css({ display: 'block' });
  130. $("#warn2").css({ display: 'none' });
  131. }
  132. }
  133. else {
  134. if (txtPwd == "" || txtPwd == undefined || txtPwd == null) {
  135. $("#warn").css({ display: 'none' });
  136. $(".warn2").css({ display: 'block' });
  137. }
  138. else {
  139. $(".warning").css({ display: 'none' });
  140. }
  141. }
  142. });
  143. //文本框不允许为空---单个文本触发
  144. $("#txtName").on('blur', function () {
  145. var txtName = $("#txtName").val();
  146. if (txtName == "" || txtName == undefined || txtName == null) {
  147. $("#warn").css({ display: 'block' });
  148. }
  149. else {
  150. $("#warn").css({ display: 'none' });
  151. }
  152. });
  153. $("#txtName").on('focus', function () {
  154. $("#warn").css({ display: 'none' });
  155. });
  156. //
  157. $("#txtPwd").on('blur', function () {
  158. var txtName = $("#txtPwd").val();
  159. if (txtName == "" || txtName == undefined || txtName == null) {
  160. $("#warn2").css({ display: 'block' });
  161. }
  162. else {
  163. $("#warn2").css({ display: 'none' });
  164. }
  165. });
  166. $("#txtPwd").on('focus', function () {
  167. $("#warn2").css({ display: 'none' });
  168. });
  169. //关闭
  170. $(".close_btn").hover(function () { $(this).css({ color: 'black' }) }, function () { $(this).css({ color: '#999' }) }).on('click', function () {
  171. $("#LoginBox").fadeOut("fast");
  172. $("#mask").css({ display: 'none' });
  173. });
  174. });
  175. /*注册校验*/
  176. $("#register-phone").click(function(){
  177. debugger
  178. mobile=$("input[name='registerPhone']").val();
  179. yanzhengma = $("input[name='registerYanzhengma']").val();
  180. var Newpassword= $("input[name='Newpassword']").val();
  181. if(mobile==null || mobile==undefined ||mobile==""){
  182. alert("电话号码为空无法登录");
  183. bool = false;
  184. }else if(!(/^1[34578]\d{9}$/.test(mobile))){
  185. alert("手机号码格式错误");
  186. bool = false;
  187. }
  188. if(yanzhengma==null || yanzhengma==undefined ||yanzhengma==""){
  189. alert("验证码为空");
  190. bool = false;
  191. }else if(yanzhengma.length<6){
  192. alert("验证码为6位");
  193. bool = false;
  194. }
  195. if(Newpassword==null || Newpassword==undefined ||Newpassword==""){
  196. alert("请设置密码");
  197. }
  198. });
  199. /*注册验证码*/
  200. $('#getting1').click(function(){
  201. mobile=$("input[name='registerPhone']").val();
  202. debugger
  203. if(mobile==null || mobile==undefined ||mobile==""){
  204. alert("电话号码为空无法获取验证码");
  205. bool = false;
  206. }else{
  207. var btn = $(this);
  208. var count = 60;
  209. var resend = setInterval(function(){
  210. count--;
  211. if (count > 0){
  212. btn.val(count+"秒后可重新获取");
  213. $.cookie("captcha", count, {path: '/', expires: (1/86400)*count});
  214. }else {
  215. clearInterval(resend);
  216. btn.val("获取验证码").removeAttr('disabled style');
  217. }
  218. }, 1000);
  219. btn.attr('disabled',true).css('cursor','not-allowed');
  220. }
  221. });