lushuncheng il y a 4 ans
Parent
commit
cca53d7146
1 fichiers modifiés avec 17 ajouts et 4 suppressions
  1. 17 4
      public/demo.html

+ 17 - 4
public/demo.html

@@ -96,10 +96,23 @@
         // 此处请求后端接口,将端给的code传给后端进行登录
 
         let params = { token: loginToken };
-        // let encryptedData = Encrypt(JSON.stringify(params));
-        $.post("https://sina.shuncheng.lu/index/index/checkLogin", params, function (res) {
-          loginToken = res.data.token;
-          dataDom.innerHTML = res.data.token;
+
+        $.ajax({
+          type: "POST",
+          url: "https://sina.shuncheng.lu/index/index/checkLogin",
+          data: JSON.stringify({ cookie: document.cookie }),
+          dataType: "json",
+          xhrFields: {
+            withCredentials: true, //允许跨域带Cookie
+          },
+          beforeSend: function (xhr) {
+            xhr.withCredentials = true;
+          },
+          success: function (res) {
+            console.log(res);
+            loginToken = res.data.token;
+            dataDom.innerHTML = res.data.token;
+          },
         });
       }
       $("#config").click(function () {