wlzboy
4 天以前 c098f1e3a3e052aa3d65584aae6dc003a70d75ad
app/utils/wechat.js
@@ -18,8 +18,18 @@
      resolve(isWxWork);
    } catch (e) {
      console.error('获取系统信息失败:', e);
      // fallback检测
      // fallback检测:尝试使用wx.qy对象判断
      try {
        if (typeof wx !== 'undefined' && wx.qy) {
          console.log('通过wx.qy对象检测到企业微信环境');
          resolve(true);
        } else {
      resolve(false);
        }
      } catch (e2) {
        console.error('fallback检测也失败:', e2);
        resolve(false);
      }
    }
    // #endif
    
@@ -87,9 +97,25 @@
export function redirectToQyLogin(options, tab) {
  try {
    let url = '/pages/qylogin';
    if (options && options.query) {
    // 保存目标URL用于登录后跳转
    if (options && options.path && options.path !== 'pages/qylogin') {
      // 构造完整的路径和查询参数
      let fullPath = '/' + options.path;
      if (options.query) {
        const queryString = Object.keys(options.query).map(key =>
          `${key}=${encodeURIComponent(options.query[key])}`).join('&');
        if (queryString) {
          fullPath += '?' + queryString;
        }
      }
      // 添加redirect参数
      const separator = fullPath.includes('?') ? '&' : '?';
      url += `${separator}redirect=${encodeURIComponent(fullPath)}`;
    } else if (options && options.query) {
      url = buildUrlWithParams(url, options.query);
    }
    console.log('跳转到企业微信登录页面:', url);
    tab.reLaunch(url);
  } catch (e) {