Sfoglia il codice sorgente

debug vip login fix bug

lushuncheng 6 anni fa
parent
commit
c39fc5fdc1
1 ha cambiato i file con 18 aggiunte e 18 eliminazioni
  1. 18 18
      plugins/nuxtAxios.js

+ 18 - 18
plugins/nuxtAxios.js

@@ -44,19 +44,6 @@ export default function({ $axios, redirect, req, ...args }) {
 
 	$axios.onResponse((res) => {
 		const data = res.data;
-		// 不跳转到login的页面reg list
-		const excludePath = [ '/user/register', '/cert/type/:id', '/type/vip/', '/cert/', '/user/:id' ];
-		const includePath = [ '/user/register', '/cert/type/:id', '/type/vip/', '/cert/', '/user/:id' ];
-		const needLogin = (path) => {
-			let result = false;
-			excludePath.forEach((reg) => {
-				reg = reg.replace(/:id/, '');
-				if (RegExp(reg).test(path)) {
-					result = false;
-				}
-			});
-			return result;
-		};
     /**
      * 设备判断
      */
@@ -85,16 +72,29 @@ export default function({ $axios, redirect, req, ...args }) {
       }
     }
     console.log('res:::::::::')
-    console.log(res);
+    // console.log(res);
     console.log(res.config)
+    console.log(data)
 		// req && req.url && needLogin(req.url)
+    let needLogin = false
+    if (res.config && res.config.data) {
+      const queryData = res.config.data
+      //将多cookie切割为多个名/值对
+      const arrQuery = queryData.split("&");
+      //遍历cookie数组,处理每个cookie对
+      for(let i=0; i<arrQuery.length; i++){
+        const arr = arrQuery[i].split("=");
+        //找到名称为x_app的cookie,并返回它的值
+        if ("needLogin" === arr[0] && (arr[1] === 'true' || arr[1] === true)){
+          needLogin = true;
+          break;
+        }
+      }
+    }
 		if (data.status === 1 || data.filename) {
-		} else if (res.config && res.config.data && res.config.data.needLogin && data.status === -99) {
-      // alert('not login ..');
+		} else if (needLogin && data.status === -99) {
       const deviceType = getDeviceType();
-      // alert('deviceType ..' + deviceType);
       if (deviceType === 'ios' || deviceType === 'android') {
-        // alert('redirect to login:' + 'proginn://login')
         if (process.server) {
           redirect('proginn://login')
         } else {