luohailiang 2 years ago
parent
commit
ac92cdd214
1 changed files with 54 additions and 40 deletions
  1. 54 40
      static/scripts/transfer.js

+ 54 - 40
static/scripts/transfer.js

@@ -8,53 +8,67 @@ function setCookie(name, value, day, path, domain)
     if(domain) str += 'domain=' + domain;
     if(domain) str += 'domain=' + domain;
     document.cookie = str;
     document.cookie = str;
 }
 }
-let zlb_token = '';
-if (location.search.includes('zlb_token')) {
-    zlb_token = location.search.substring(11);
-    const requestURL = 'https://tyyxopenapi.txhlwxx.com/openapi/oauth/zlb/checkticket.php';
-    $.ajax({
-        url: requestURL,
-        async: false,
-        type: "POST",
-        timeout: 30000,
-        dataType: 'json',
-        data: {
-            type:'login',
-            zlb_token: zlb_token,
-            client:'h5'
-        },
-        success: (res) => {
-            if (res.code === '1') {
-                localStorage.setItem('userInfo', JSON.stringify(res.data));
-                setCookie('token', res.data.token, 30, '/');
-                setTimeout(() => {
-                    location.href = './index.html';
-                }, 500)
-            } else if(res.code === '501'){
-                this.$message({
-                    message:res.msg,
-                    type: 'warning',
-                    showClose: true,
-                    duration: '1500',
-                    onClose:()=>{
+new Vue({
+    el:'#transfer',
+    data() {
+        return {
+
+        }
+    },
+    methods:{
+
+    },
+    mounted() {
+        let zlb_token = '';
+        if (location.search.includes('zlb_token')) {
+            zlb_token = location.search.substring(11);
+            const requestURL = 'https://tyyxopenapi.txhlwxx.com/openapi/oauth/zlb/checkticket.php';
+            $.ajax({
+                url: requestURL,
+                async: false,
+                type: "POST",
+                timeout: 30000,
+                dataType: 'json',
+                data: {
+                    type:'login',
+                    zlb_token: zlb_token,
+                    client:'h5'
+                },
+                success: (res) => {
+                    if (res.code === '1') {
                         localStorage.setItem('userInfo', JSON.stringify(res.data));
                         localStorage.setItem('userInfo', JSON.stringify(res.data));
                         setCookie('token', res.data.token, 30, '/');
                         setCookie('token', res.data.token, 30, '/');
                         setTimeout(() => {
                         setTimeout(() => {
                             location.href = './index.html';
                             location.href = './index.html';
                         }, 500)
                         }, 500)
+                    } else if(res.code === '501'){
+                        this.$message({
+                            message:res.msg,
+                            type: 'warning',
+                            showClose: true,
+                            duration: '1500',
+                            onClose:()=>{
+                                localStorage.setItem('userInfo', JSON.stringify(res.data));
+                                setCookie('token', res.data.token, 30, '/');
+                                setTimeout(() => {
+                                    location.href = './index.html';
+                                }, 500)
+                            }
+                        });
+                    } else {
+                        this.$message({
+                            message: res.msg,
+                            type: 'error',
+                            showClose: true,
+                            duration: '1500'
+                        });
                     }
                     }
-                });
-            } else {
-                this.$message({
-                    message: res.msg,
-                    type: 'error',
-                    showClose: true,
-                    duration: '1500'
-                });
-            }
+                }
+            });
         }
         }
-    });
-}
+    }
+})
+
 // if(location.search.includes('token')) {
 // if(location.search.includes('token')) {
 //     location_search = location.search.split('&');
 //     location_search = location.search.split('&');
 //     for(let i in location_search) {
 //     for(let i in location_search) {