瀏覽代碼

Merge branch 'master' of http://git.choozmo.com:3000/choozmo/AI_Anchor_2

huai-sian 3 年之前
父節點
當前提交
0900cd166c
共有 1 個文件被更改,包括 19 次插入17 次删除
  1. 19 17
      html/pricing.html

+ 19 - 17
html/pricing.html

@@ -269,25 +269,27 @@
     <script type="text/javascript" src="static/lan.js"></script>
     <script src="static/common.js"></script>
     <script>
-        const btnLoginPage = document.querySelector('.btn-login');
-        const btnUserProfile = document.querySelector('.btn-userProfile');
-        const btnLogout = document.querySelector('.btn-logout');
-        btnLoginPage.style.display = 'none';
-        btnLogout.style.display = 'none';
-        btnUserProfile.style.display = 'none';
+        $('.btn-login').hide();
+        $('.btn-userProfile').hide();
+        $('.btn-logout').hide();
         function get_jwt_token(){
             if(!document.cookie) {
                 return
             }
-            jwt_raw = document.cookie.split(';').filter(s=>s.includes('jwt_token'))[0]
-            return jwt_raw.split('=')[1]
+            try {
+                jwt_raw = document.cookie.split(';').filter(s=>s.includes('jwt_token'))[0];
+                return jwt_raw.split('=')[1];
+            } catch (e) {
+                return undefined;
+            }
         }
         function checkRoute() {
             let jwt_token = get_jwt_token();
             if(jwt_token == undefined) {
-                btnLoginPage.style.display = 'block';
-                btnLogout.style.display = 'none';
-                btnUserProfile.style.display = 'none';
+                console.log(jwt_token); // test
+                $('.btn-login').show();
+                $('.btn-userProfile').hide();
+                $('.btn-logout').hide();
                 return;
             }
             axios({
@@ -300,13 +302,13 @@
             }).then(res => {
                 console.log(res.data);
                 if(res.status !== 200) {
-                    btnLoginPage.style.display = 'block';
-                    btnLogout.style.display = 'none';
-                    btnUserProfile.style.display = 'none';
+                    $('.btn-login').show();
+                    $('.btn-userProfile').hide();
+                    $('.btn-logout').hide();
                 }
-                btnLoginPage.style.display = 'none';
-                btnLogout.style.display = 'block';
-                btnUserProfile.style.display = 'block';
+                $('.btn-login').hide();
+                $('.btn-userProfile').show();
+                $('.btn-logout').show();
             }).catch(err => {
                 console.log(err);
             });