config.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. function getUrlParam(name)
  2. {
  3. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  4. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  5. if (r != null) return unescape(r[2]); return null; //返回参数值
  6. }
  7. function login()
  8. {
  9. var html = '<div class="form-item"><i class="ico-email"></i><input type="text" placeholder="邮箱" id="email" name="email"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="密码" id="password" name="password"></div><div class="form-links"><a href="javascript:;" onclick="forget()">忘记密码?</a><a href="javascript:;" onclick="reg()">注册用户</a></div><div class="btn-wrap">';
  10. return layer('login', '登录', html, '登录');
  11. }
  12. function reg()
  13. {
  14. var html = '<div class="form-item"><i class="ico-email"></i><input type="text" placeholder="邮箱" id="email" name="email"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="密码" id="password" name="password"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="确认密码" id="cpassword" name="cpassword"></div><div class="form-links align-right"><a href="javascript:;" onclick="login()">已有账号?点此登录</a></div>';
  15. return layer('reg', '注册', html, '注册');
  16. }
  17. function forget()
  18. {
  19. var html = '<div class="form-item"><i class="ico-email"></i><input type="text" placeholder="邮箱" id="email" name="email"></div><div class="form-links align-right"><a href="javascript:;" onclick="login()">点此登录</a><span>|</span><a href="javascript:;" onclick="reg()">点此注册</a></div>';
  20. return layer('find_password', '找回密码', html, '确认');
  21. }
  22. function edit_password()
  23. {
  24. var signature = getUrlParam('signature');
  25. var email = getUrlParam('email');
  26. var html = '<div class="form-item"><i class="ico-email"></i><input type="hidden" id="signature" name="signature" value="'+signature+'"><input type="text" placeholder="邮箱" id="email" name="email" value="'+email+'" readonly></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="密码" id="password" name="password"></div><div class="form-item"><i class="ico-password"></i><input type="password" placeholder="确认密码" id="cpassword" name="cpassword"></div><div class="form-links align-right"><a href="javascript:;" onclick="login()">已有账号?点此登录</a></div>';
  27. return layer('edit_password', '密码重置', html, '确认');
  28. }
  29. function layer(id, title, content, button)
  30. {
  31. var refer = location.href;
  32. var mask = '<div class="mask">';
  33. var html = '';
  34. html += '<div class="layer">';
  35. html += '<h4><span>'+title+'</span></h4>';
  36. html += '<form id="layer_form">';
  37. html += content;
  38. html += '<div class="btn-wrap"><a href="javascript:;" id="'+id+'" class="btn">'+button+'</a><input type="hidden" id="refer" name="refer" value="'+refer+'"></div>';
  39. html += '</form>';
  40. html += '</div>';
  41. if (!$('.mask').length) {
  42. $('body').append(mask + html + '</div>');
  43. } else {
  44. $('.mask').html(html);
  45. }
  46. $('.mask').show();
  47. Dever.User().Init();
  48. }
  49. //定义用户相关的一些信息
  50. Dever.User().config =
  51. {
  52. //初始化,绑定click
  53. 'click' :
  54. {
  55. //登录
  56. 0 : '#login'
  57. //注册
  58. ,1 : '#reg'
  59. //找回密码
  60. ,2 : '#find_password'
  61. //找回密码
  62. ,3 : '#edit_password'
  63. }
  64. //登录信息
  65. ,0 :
  66. {
  67. 'input' :
  68. {
  69. 'email' : '#email'
  70. ,'password' : '#password'
  71. ,'refer' : '#refer|'
  72. }
  73. //错误提示的div
  74. ,'status' : '#dever_alert'
  75. //错误提示
  76. ,'error' : '您的邮箱或密码错误'
  77. //登录要提交的url
  78. ,'url' : Dever.Host('passport', 'login.action')
  79. }
  80. //注册信息
  81. ,1 :
  82. {
  83. 'input' :
  84. {
  85. 'email' : '#email'
  86. ,'username' : '#email'
  87. ,'password' : '#password'
  88. ,'cpassword' : '#cpassword'
  89. ,'refer' : '#refer|'
  90. }
  91. //错误提示的div
  92. ,'status' : '#dever_alert'
  93. //错误提示
  94. ,'error' : '您填写的信息有误'
  95. //登录要提交的url
  96. ,'url' : Dever.Host('passport', 'reg.action')
  97. }
  98. //找回密码发送邮件
  99. ,2 :
  100. {
  101. 'input' :
  102. {
  103. 'email' : '#email'
  104. ,'refer' : '#refer|'
  105. }
  106. //错误提示的div
  107. ,'status' : '#dever_alert'
  108. //错误提示
  109. ,'error' : '您填写的信息有误'
  110. //找回密码发送邮件
  111. ,'url' : Dever.Host('passport', 'reg.forget_email')
  112. }
  113. ,3 :
  114. {
  115. 'input' :
  116. {
  117. 'email' : '#email'
  118. ,'password' : '#password'
  119. ,'cpassword' : '#cpassword'
  120. ,'signature' : '#signature'
  121. ,'refer' : '#refer|'
  122. }
  123. //错误提示的div
  124. ,'status' : '#dever_alert'
  125. //错误提示
  126. ,'error' : '您填写的信息有误'
  127. //找回密码操作
  128. ,'url' : Dever.Host('passport', 'reg.forget')
  129. }
  130. };
  131. $(document).ready(function()
  132. {
  133. var html = location.href;
  134. if (html.indexOf('signature') != -1) {
  135. edit_password();
  136. }
  137. });