Browse Source

给ajax方法设置请求头

huangxiaojing 4 years ago
parent
commit
a87c24a307
2 changed files with 20 additions and 21 deletions
  1. 0 11
      microserviceUserH5/static/css/invite.css
  2. 20 10
      microserviceUserH5/vcloud/invite.html

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

@@ -6,17 +6,6 @@ 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;

+ 20 - 10
microserviceUserH5/vcloud/invite.html

@@ -57,10 +57,28 @@
     <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">
+    <script type="text/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("=");//取得=号的位置
@@ -86,6 +104,7 @@
             },
             contentType: "application/json",
             dataType: 'json',
+            cache: false,
             success: function (res) {
                 $('#invitationCode').text(res.data.invitationCode)
                 //加载数据
@@ -122,9 +141,6 @@
             error: function () {
                 str = '<div class="no-data">还没有邀请到好友哦~</div>'
                 $('#goode').append(str)
-            },
-            beforeSend: function(xhr) {
-                xhr.setRequestHeader("Content-Type", "text/html;charset=utf-8");
             }
         })
 
@@ -172,9 +188,6 @@
                         } catch (error) {
                             console.log(error)
                         }
-                    },
-                    beforeSend: function(xhr) {
-                        xhr.setRequestHeader("Content-Type", "text/html;charset=utf-8");
                     }
                 })
             } else if (isAndroid) {
@@ -200,9 +213,6 @@
                         // 执行浏览器复制命令
                         document.execCommand("copy");
                         toastr.error('复制成功')
-                    },
-                    beforeSend: function(xhr) {
-                        xhr.setRequestHeader("Content-Type", "text/html;charset=utf-8");
                     }
                 })
             }