xiachangming 2 лет назад
Родитель
Сommit
11cd51df3b
2 измененных файлов с 70 добавлено и 40 удалено
  1. 29 27
      wwwroot/mes/login.ashx
  2. 41 13
      wwwroot/mes/login.html

+ 29 - 27
wwwroot/mes/login.ashx

@@ -43,33 +43,35 @@ public class login : IHttpHandler, IRequiresSessionState
         //AD域名校验
         if (context.Request["m"].ToString() == "1")
         {
-            //获取ad验证
-            string url = "http://127.0.0.1:60123/hgws/get_ad_code";
-            //定义一个result用来存放接收到的json数据
-            string result = "";
-            //请求url
-            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
-            //请求方法为Get
-            req.Method = "Get";
-            try
-            {
-                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
-                Stream stream = resp.GetResponseStream();
-                //获取内容
-                using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
-                {
-                    result = reader.ReadToEnd();
-                }
-            }
-            catch (Exception ex)
-            {
-                JsonResult rs = new JsonResult();
-                rs.success = false;
-                rs.status = 0;
-                rs.message = "验证失败";
-                context.Response.Write(rs.ToJson());
-                return;
-            }
+
+            ////获取ad验证
+            //string url = "http://127.0.0.1:60123/hgws/get_ad_code";
+            ////定义一个result用来存放接收到的json数据
+            //string result = "";
+            ////请求url
+            //HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
+            ////请求方法为Get
+            //req.Method = "Get";
+            //try
+            //{
+            //    HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
+            //    Stream stream = resp.GetResponseStream();
+            //    //获取内容
+            //    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
+            //    {
+            //        result = reader.ReadToEnd();
+            //    }
+            //}
+            //catch (Exception ex)
+            //{
+            //    JsonResult rs = new JsonResult();
+            //    rs.success = false;
+            //    rs.status = 0;
+            //    rs.message = "验证失败";
+            //    context.Response.Write(rs.ToJson());
+            //    return;
+            //}
+            string result = context.Request["ADresult"];
             JsonResult jr = dkmes.LoginByAD1(result);
             if (jr.success)
             {

+ 41 - 13
wwwroot/mes/login.html

@@ -27,9 +27,9 @@
         <div class="w-div" style="padding-top:8px;">
             <a href="javascript:void(0)" id="tbSave" class="easyui-linkbutton" onclick="submitForm()" style="margin-left:48px; width:250px;height:32px;">登录</a>
         </div>
-        <div class="w-div" style="padding-top:8px;">
+        <!--<div class="w-div" style="padding-top:8px;">
             <a href="javascript:void(0)" id="tbADSave" class="easyui-linkbutton" onclick="ADsubmitForm()" style="margin-left:48px; width:250px;height:32px;">AD域验证</a>
-        </div>
+        </div>-->
     </form>
     <!--</div>-->
 
@@ -60,21 +60,49 @@
             }
         }
 
-        function ADsubmitForm() {
-            $.get('login.ashx?m=1&r=' + Math.random(), $('#ff').serialize(), function (data) {
-                var json = JSON.parse(data);
-                if (json['success'] == true) {
-                    parent.window.location.href = 'main.html';
-                }
-                else {
-                    $.messager.alert('用户登录', json['message'], 'warning');
-                }
-            });
-        }
+        //function ADsubmitForm() {
+        //    var s = GetAD();
+        //    $.ajax({
+        //        url: 'http://127.0.0.1:60123/hgws/get_ad_code',
+        //        contentType: 'application/json',
+        //        dataType: 'jsonp',
+        //        jsonp: 'jsoncallback', //默认callback
+        //        jsonpCallback:'jsonpFn',
+        //        type: 'GET',
+        //        success: function (data) {
+        //            console.log(data)
+        //            //$.get('login.ashx?m=1&=' + Math.random(), { "ADresult": data }, function (data) {
+        //            //    var json = JSON.parse(data);
+        //            //    if (json['success'] == true) {
+        //            //        parent.window.location.href = 'main.html';
+        //            //    }
+        //            //    else {
+        //            //        $.messager.alert('用户登录', json['message'], 'warning');
+        //            //    }
+        //            //});
+        //        }
+        //    })
+        //    //$.get('http://127.0.0.1:60123/hgws/get_ad_code', function (data) {
+        //    //    $.get('login.ashx?m=1&=' + Math.random(), { "ADresult": data} , function (data) {
+        //    //        var json = JSON.parse(data);
+        //    //        if (json['success'] == true) {
+        //    //            parent.window.location.href = 'main.html';
+        //    //        }
+        //    //        else {
+        //    //            $.messager.alert('用户登录', json['message'], 'warning');
+        //    //        }
+        //    //    });
+        //    //});
 
+            
+        //}
+        function GetAD(data) {
+            return data;
+        }
         function keyLogin() {
             if (event.keyCode == 13) submitForm();
         }
     </script>
+    <!--<script src="http://127.0.0.1:60123/hgws/get_ad_code?callback=GetAD"></script>-->
 </body>
 </html>