瀏覽代碼

Merge branch 'master' of http://39.106.8.246:3003/sagacloud/sagacloud-sagacare-weChat

anxiaoxia 1 年之前
父節點
當前提交
05819bfe08
共有 5 個文件被更改,包括 21 次插入12 次删除
  1. 1 2
      src/common/request.js
  2. 1 1
      src/packagesEnv/pages/home/index.wpy
  3. 3 3
      src/pages/index.wpy
  4. 15 6
      src/service/user.js
  5. 1 0
      src/store/user.js

+ 1 - 2
src/common/request.js

@@ -100,14 +100,13 @@ export default function (info) {
             wx.redirectTo({ url: '/packagesEnv/pages/home/index' });
           } else { // 续约
             if (!store.state.user.refreshUse) {
-              console.log("开始续约--");
               store.commit('setRefreshUse', true);
               refreshTokenPage().then(res => {
                 store.commit('setRefreshUse', false);
               }).catch((err) => {
+                store.commit('setRefreshUse', false);
                 store.commit('clearToken', '');
                 wx.redirectTo({ url: '/packagesEnv/pages/home/index' });
-                store.commit('setRefreshUse', false);
               })
             }
           }

+ 1 - 1
src/packagesEnv/pages/home/index.wpy

@@ -463,7 +463,7 @@ wepy.page({
     checkLoginNew()
       .then(() => {
         console.log("触发了")
-        // checkHasUserInfo();
+        checkHasUserInfo();
         //获取项目list
         getCompanyDataByPhone()
           .then((res) => {

+ 3 - 3
src/pages/index.wpy

@@ -47,7 +47,7 @@ page {
    <div class="login">
        <image src="{{h5StaticPath +'/page-bind-tenant/logo_title.png'}}" alt=""/>
        <button class="bind-btn"
-        @click="goBindTenant">登录</button>
+        @click.stop="goBindTenant">登录</button>
    </div>
   </div>
 </template>
@@ -70,8 +70,7 @@ wepy.page({
       isActivated: state => state.user.isActivated
     })
   },
-  onLoad() {},
-  onShow() {
+  onLoad() {
     if (this.isActivated && this.isActivated == 1) {
       this.goHome();
     } else {
@@ -79,6 +78,7 @@ wepy.page({
       this.checkTenantRegist();
     }
   },
+  onShow() {},
   methods: {
     goBindTenant() {
       this.goAuth();

+ 15 - 6
src/service/user.js

@@ -18,11 +18,12 @@ function checkHasUserInfo() {
       if (minute < 20) {
         refreshTokenPage().then(() => {
           clearTimeout(timer);
-          checkHasUserInfo(1000);
+          checkHasUserInfo(600000);
         });
-        console.log("minute==", minute)
+      } else {
+        clearTimeout(timer);
+        checkHasUserInfo(600000);
       }
-      // console.log("minute==", minute)
     } else {
       clearTimeout(timer);
       checkHasUserInfo(600000);
@@ -34,6 +35,7 @@ function checkHasUserInfo() {
 
 // 登录
 function wxLogin(type) {
+  console.log("执行了登录")
   // type=1 如果type未激活和作废不需要跳转到登录页面
   return new Promise((resolve, reject) => {
     wx.login({
@@ -63,7 +65,7 @@ function wxLogin(type) {
                 // store.commit('setProjectId', data.tokenUser.projectId);
               } else {
                 if (!type) {
-                  wx.redirectTo({ url: '/pages/index' });
+                  refreshLogin()
                 }
                 store.commit('setUserInfo', {});
               }
@@ -136,6 +138,7 @@ function refreshTokenPage() {
           refreshTokenExpireTime: data.refreshTokenExpireTime,
           refreshToken: data.refreshToken
         };
+        console.log(data);
         store.commit('setToken', data.token);
         store.commit('setActivated', data.isActivated);
         store.commit('setTokenInfo', tokenInfo);
@@ -144,7 +147,8 @@ function refreshTokenPage() {
           resolve(data)
         } else {
           store.commit('clearToken', '');
-          refreshHome()
+          // 去登录页面
+          refreshLogin()
           resolve(data)
         }
       } else {
@@ -165,6 +169,10 @@ function refreshHome() {
   // wx.redirectTo({ url: '/pages/index' });
   wx.redirectTo({ url: '/packagesEnv/pages/home/index' });
 }
+function refreshLogin() {
+  wx.redirectTo({ url: '/pages/index' });
+  // wx.redirectTo({ url: '/packagesEnv/pages/home/index' });
+}
 // 检查用户是否有空间控制权限
 function checkUserControl() {
   return new Promise((resolve, reject) => {
@@ -214,6 +222,7 @@ function checkLoginNew() {
     let token = store.state.user.token;
     let storeTokenInfo = store.state.user.tokenInfo
     let refreshToken = storeTokenInfo && storeTokenInfo.refreshToken ? storeTokenInfo.refreshToken : '';
+    console.log("执行checkLoginNew--", token, refreshToken);
     console.log("执行checkLoginNew--");
     if (!token || !refreshToken) {
       wxLogin().then((res) => {
@@ -235,7 +244,7 @@ function checkLoginNew() {
           resolve(res)
         }).catch((error) => {
           reject("登录失败!");
-        });;
+        });
       } else if (flag == 3) {  // 未过期
         resolve({
           isActivated: store.state.user.isActivated

+ 1 - 0
src/store/user.js

@@ -24,6 +24,7 @@ export default {
     // 设置token
     setToken(state, token) {
       wx.setStorageSync('token', token);
+      console.log("设置token--")
       state.token = token;
     },
     //设置租户状态