一直觉得Wiwiz自带的认证页面不太方便,尤其是不支持Cookie,这样每次认证时都需要手动输入认证信息,会比较麻烦。
我利用自定义认证页面的定制代码,加入了记录和处理Cookie的功能,用Javascript实现的。
这里分享给大家,谁需要请拿去用吧。

认证页面效果图:

认证页面HTML代码:

 
  
  1. <html> 
  2. <head> 
  3. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  4. <meta http-equiv="Pragma" content="no-cache"> 
  5. <meta http-equiv="Cache-Control" content="no-cache"> 
  6. <meta name="viewport" content="user-scalable=no, width=device-width" />   
  7.   
  8. <!-- 必须引入AuthPageScript.js --> 
  9. <script src="/as/AuthPageScript.js"></script> 
  10. <script> 
  11.  
  12.  
  13. /* 读写Cookie的函数 */ 
  14. function SetCookie(name,value) { 
  15.     var Days = 180
  16.     var exp  = new Date(); 
  17.     exp.setTime(exp.getTime() + Days*24*60*60*1000); 
  18.     document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
  19.  
  20. function getCookie(name) { 
  21.     var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); 
  22.     if(arr != null)  
  23.         return unescape(arr[2]);  
  24.     return ""; 
  25.  
  26. /* 用于在认证时记录Cookie */ 
  27. function recordCookie() { 
  28.     if(document.getElementById("remember").checked == false) 
  29.         return; 
  30.     else { 
  31.         var u = document.getElementById("username").value; 
  32.         var p = document.getElementById("pswd").value; 
  33.          
  34.         SetCookie("wifi-user", u); 
  35.         SetCookie("wifi-pswd", p); 
  36.     } 
  37.  
  38. /* 页面初始化是读入Cookie并自动按下认证按钮 */ 
  39. function doInit() { 
  40.     var u = getCookie("wifi-user"); 
  41.     var p = getCookie("wifi-pswd"); 
  42.      
  43.     if(u != "") { 
  44.         document.getElementById("username").value = u; 
  45.         document.getElementById("pswd").value = p
  46.          
  47.         document.getElementById("login").click(); 
  48.     } 
  49.   
  50. /* 回调函数。“获取验证码”按钮按下后,将自动调用此函数。可根据code值自行改写该函数。 */ 
  51. function WiwizSmsVerifyMsg(code) { 
  52.     if      (code == "-1") { 
  53.         alert("手机号码不可为空!"); 
  54.     } else if(code == "0") { 
  55.         alert("验证码已通过短信发送至您的手机,请注意查收。然后请在认证页面输入验证码。"); 
  56.     } else if(code == "1") { 
  57.         alert("该热点不允许进行手机号码验证。如有疑问请您联系热点管理员。"); 
  58.     } else if(code == "2") { 
  59.         alert("该热点不允许进行手机号码验证。如有疑问请您联系热点管理员。"); 
  60.     } else if(code == "3") { 
  61.         alert("该手机号码不允许进行验证。如有疑问请您联系热点管理员。"); 
  62.     } else if(code == "4") { 
  63.         alert("手机号码验证过于频繁,请稍后再试。"); 
  64.     } else if(code == "5") { 
  65.         alert("该手机号码进行验证次数已超过今日上限。"); 
  66.     } else if(code == "6") { 
  67.         alert("热点认证服务已暂停,不可进行手机验证。"); 
  68.     } else if(code == "7") { 
  69.         alert("该热点手机验证次数已超过配额。请联系热点管理员。"); 
  70.     } else if(code == "8") { 
  71.         alert("请求已超时,请刷新认证页面。"); 
  72.     } else if(code == "9") { 
  73.         alert("请使用上一次通过短信接收到的验证码。"); 
  74.     } else if(code == "99") { 
  75.         alert("验证短信发送失败。请检查手机号码的有效性,或联系热点管理员。"); 
  76.     } else if(code == "999") { 
  77.         alert("系统异常,验证短信发送失败。请联系热点管理员。"); 
  78.     } else { 
  79.         alert("系统异常。请联系热点管理员。"); 
  80.     } 
  81.   
  82. /* 回调函数。“认证”按钮按下后,如报错将自动调用此函数。可根据code值自行改写该函数。 */ 
  83. function WiwizAuthPageError(code) { 
  84.     if       (code == 1) { 
  85.         alert("您无法使用此网络,除非您认同此协议条款。"); 
  86.     } else if(code == 2) { 
  87.         alert("请输入用户名。"); 
  88.     } else if(code == 3) { 
  89.         alert("用户名或密码错误。"); 
  90.     } else if(code == 4) { 
  91.         alert("电子招待券无效。"); 
  92.     } else if(code == 6) { 
  93.         alert("超过最大在线用户数。"); 
  94.     } else if(code == 7) { 
  95.         alert("请输入手机号码。"); 
  96.     } else if(code == 32) { 
  97.         alert("账户存在异常,暂时锁定中。"); 
  98.     } else if(code == 35) { 
  99.         alert("手机验证码错误或已超时。"); 
  100.     } else { 
  101.         alert("未知错误。错误码:"+ code); 
  102.     } 
  103. </script> 
  104. </head> 
  105. <body onload="doInit();"> 
  106.   
  107. <form name="myform" id="myform" action="" method="post">  
  108.   
  109. <center> 
  110.  
  111. <table width="320" bgcolor="#ffffff"> 
  112. <tr><td align="center"> 
  113. <br> 
  114. <table width="100%" cellspacing="2" cellpadding="2"> 
  115. <tr align="center"><td> 
  116. <font size="+2" color="#000000"><b>Wifi无线网络 - 10M带宽 </b> </font> 
  117. </td></tr> 
  118.  
  119. <tr align="center"><td> 
  120. <img src="/as/img/wiwiz.gif"></img> 
  121. </td></tr> 
  122. </table> 
  123.  
  124. <table width="99%" cellspacing="1" cellpadding="2" style="font-size:12px"> 
  125. <tr align="center"> 
  126.     <td width="100%">    
  127.         <table style="font-size:12px" width="98%"> 
  128.         <tr><td> 
  129.         <font color="#ff1111"> 
  130.         本热点为计费WiFi热点。费率为: 
  131.         3元/日 
  132.         50元/月 
  133.         </font> 
  134.         </td></tr> 
  135.         </table> 
  136.          
  137.  
  138.  
  139.         <table style="font-size:12px" width="100%"> 
  140.         <tr> 
  141.         <td align="center"> 
  142.              
  143.             在使用此网络之前,请您详细阅读使用条款。<br> 
  144.             <textarea readonly rows="4" style="width:87%;font-size:12px">条款内容</textarea> 
  145.             <br> 
  146.             <!-- 参数: agree 代表认同协议 --> 
  147.             <input name="agree" id="agree" type="checkbox" value="1" checked /> 
  148.             <label for="agree">我完全同意此条款的内容。</label> 
  149.         </td> 
  150.         </tr> 
  151.         </table>     
  152.          
  153.     </td> 
  154. </tr> 
  155. </table> 
  156.  
  157. <table width="100%" cellspacing="1" cellpadding="4" style="font-size:12px"> 
  158. <tr align="center"> 
  159.     <td width="100%"> 
  160.      
  161.          
  162.         <table style="font-size:12px"> 
  163.         <tr> 
  164.             <td>用户名: </td> 
  165.             <td><!-- 参数: username 代表用户名 --> 
  166.                 <input name="username" id="username" type="text" value="" style="width:140px" /> 
  167.              
  168.             </td> 
  169.         </tr> 
  170.         <tr> 
  171.             <td>密码: </td> 
  172.             <td><!-- 参数: pswd 代表密码 --> 
  173.                 <input name="pswd" id="pswd" type="password" style="width:140px" /> 
  174.             </td> 
  175.         </tr> 
  176.         </table> 
  177.          
  178.         <input name="remember" id="remember" type="checkbox" value="1" checked /><label for="remember">下次自动登录</label> 
  179.         <br><br> 
  180.         <!-- 用于开始触发认证的按钮,onclick事件必须调用WiwizStartAuth()函数 --> 
  181.         <!-- recordCookie函数用于处理记录Cookie -->      
  182.         <input type="button" name="login" id="login" value="   立即开始使用此网络   " onclick="recordCookie(); WiwizStartAuth();" /> 
  183.          
  184.         <br> 
  185.         <br> 
  186.         <font size="-1"><b><a href="#" onclick="window.open('http://cp.wiwiz.com/as/s/viewhotspot/?gw_id='+ WiwizGetQueryParameter('gw_id')); return false;">更多信息</a></font></b> 
  187.         <br> 
  188.         <br> 
  189.         <font style="font-size:12px"><b> 
  190.         <a href="/as/s/register/" target="_blank">注册</a> &nbsp; | &nbsp;  
  191.         <a href="/as/s/remindpswd/" target="_blank">忘记密码?</a> 
  192.         </b></font>  
  193.     </td> 
  194. </tr> 
  195. </table> 
  196.  
  197. </td></tr></table> 
  198.  
  199. <br> 
  200. </center> 
  201.   
  202. </form> 
  203. </body></html>