ソースを参照

给ajax方法设置请求头

huangxiaojing 4 年 前
コミット
c29d43c8bf
共有2 個のファイルを変更した22 個の追加19 個の削除を含む
  1. 11 0
      microserviceUserH5/static/css/invite.css
  2. 11 19
      microserviceUserH5/vcloud/invite.html

+ 11 - 0
microserviceUserH5/static/css/invite.css

@@ -6,6 +6,17 @@ html, body, div, ul, li, p {
 ul, li {
   list-style: none;
 }
+@media only screen and (max-width: 750px) {
+  html {
+    font-size: calc(100vw / 7.5);
+  }
+}
+
+@media only screen and (min-width: 750px) {
+  html {
+    font-size: calc(750px / 7.5);
+  }
+}
 .invite-container {
   width: 7.5rem;
   margin: 0 auto;

+ 11 - 19
microserviceUserH5/vcloud/invite.html

@@ -57,28 +57,10 @@
     <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="passwordCopy" value="">
     <input type="text" style="opacity: 0;z-index: -10;position: fixed;" id="inviteCopy" value="">
     <script>
-        window.onload = window.onresize = function () {
-            verticalAlign()
-        }
-
-        function verticalAlign() {
-            var html = document.documentElement;
-            var BodyWidth = html.getBoundingClientRect().width;
-            if (BodyWidth > 750) {
-                html.style.fontSize = 750 / 7.5 + 'px';
-            } else {
-                html.style.fontSize = BodyWidth / 7.5 + 'px';
-            }
-        }
-    </script>
-    <script>
         toastr.options.positionClass = 'toast-center-center';
         toastr.options.timeOut = '3000';
     </script>
     <script type="text/javascript" th:inline="javascript">
-        var url = window.location.href;
-        url = url.split('/')
-        //   var baseUrl = url[0] + '//' + url[2]
         var loc = window.location.search;
         var n1 = loc.length;//地址的总长度
         var n2 = loc.indexOf("=");//取得=号的位置
@@ -136,9 +118,13 @@
                     str = '<div class="no-data">还没有邀请到好友哦~</div>'
                 }
                 $('#goode').append(str);
-            }, error: function () {
+            }, 
+            error: function () {
                 str = '<div class="no-data">还没有邀请到好友哦~</div>'
                 $('#goode').append(str)
+            },
+            beforeSend: function(xhr) {
+                xhr.setRequestHeader("Content-Type", "text/html;charset=utf-8");
             }
         })
 
@@ -186,6 +172,9 @@
                         } catch (error) {
                             console.log(error)
                         }
+                    },
+                    beforeSend: function(xhr) {
+                        xhr.setRequestHeader("Content-Type", "text/html;charset=utf-8");
                     }
                 })
             } else if (isAndroid) {
@@ -211,6 +200,9 @@
                         // 执行浏览器复制命令
                         document.execCommand("copy");
                         toastr.error('复制成功')
+                    },
+                    beforeSend: function(xhr) {
+                        xhr.setRequestHeader("Content-Type", "text/html;charset=utf-8");
                     }
                 })
             }