0235699曾露 10 часов назад
Родитель
Сommit
0a3ce2dc18
2 измененных файлов с 51 добавлено и 24 удалено
  1. 25 2
      common-page/pages/web-view/index.js
  2. 26 22
      index.js

+ 25 - 2
common-page/pages/web-view/index.js

@@ -21,13 +21,32 @@ Page({
         // 解码 URL
         let path = decodeURIComponent(options.path || '');
 
-        // 拼接额外参数
+        console.log('===========================================');
+        console.log('======= web-view 页面加载 =======');
+        console.log('原始 options.path:', options.path);
+        console.log('解码后的 path:', path);
+        console.log('===========================================');
+
+        // 拼接额外参数(避免重复添加已存在的参数)
         let hasQuery = path.indexOf('?') !== -1;
         let parsm = hasQuery ? '&' : '?';
         let params = [];
+        
+        // 提取 path 中已有的参数
+        let existingParams = new Set();
+        if (hasQuery) {
+            const queryString = path.split('?')[1];
+            if (queryString) {
+                queryString.split('&').forEach(param => {
+                    const key = param.split('=')[0];
+                    existingParams.add(key);
+                });
+            }
+        }
 
+        // 只添加 path 中不存在的参数
         for (const key in options) {
-            if(key != 'path' && key != 'url'){
+            if(key != 'path' && key != 'url' && !existingParams.has(key)){
                 params.push(key + '=' + options[key]);
             }
         }
@@ -37,6 +56,10 @@ Page({
             path = path + parsm;
         }
 
+        console.log('最终 web-view URL:', path);
+        console.log('URL 长度:', path.length);
+        console.log('===========================================');
+
         this.setData({
             path: path
         })

+ 26 - 22
index.js

@@ -773,19 +773,21 @@ Page({
       console.log('===========================================');
       
       const currentUser = Parse.User.current();
-      if (!currentUser) {
-        console.error('❌ 用户未登录,无法跳转');
-        return;
-      }
+      const token = currentUser ? currentUser.getSessionToken() : null;
       
-      const token = currentUser.getSessionToken();
-      if (!token) {
-        console.error('❌ 无法获取 Session Token');
-        return;
+      // 构建产品详情的 H5 URL(不要在这里编码,后面统一编码)
+      let h5Url = `https://app.fmode.cn/dev/pobingfeng/owner/nav/products?storeId=${storeId}`;
+      
+      // 如果有 token,添加到 URL
+      if (token) {
+        h5Url += `&token=${token}`;
+      } else {
+        // 如果没有 token,使用游客模式
+        h5Url += `&guestMode=true`;
       }
       
-      // 构建产品详情的 H5 URL
-      let h5Url = `https://app.fmode.cn/dev/pobingfeng/owner/nav/products?storeId=${storeId}&token=${token}&productId=${encodeURIComponent(productId)}`;
+      // 添加产品ID(不要在这里编码,避免双重编码)
+      h5Url += `&productId=${productId}`;
       
       // 如果有合作伙伴ID,也添加到URL中
       if (partnerId) {
@@ -794,7 +796,7 @@ Page({
       
       console.log('🌐 H5 URL:', h5Url);
       
-      // 编码 URL
+      // 编码 URL(统一在这里编码一次)
       const encodedUrl = encodeURIComponent(h5Url);
       
       // 构建 web-view 页面路径
@@ -840,19 +842,21 @@ Page({
       console.log('===========================================');
       
       const currentUser = Parse.User.current();
-      if (!currentUser) {
-        console.error('❌ 用户未登录,无法跳转');
-        return;
-      }
+      const token = currentUser ? currentUser.getSessionToken() : null;
       
-      const token = currentUser.getSessionToken();
-      if (!token) {
-        console.error('❌ 无法获取 Session Token');
-        return;
+      // 构建案例详情的 H5 URL(不要在这里编码,后面统一编码)
+      let h5Url = `https://app.fmode.cn/dev/pobingfeng/owner/nav/cases?storeId=${storeId}`;
+      
+      // 如果有 token,添加到 URL
+      if (token) {
+        h5Url += `&token=${token}`;
+      } else {
+        // 如果没有 token,使用游客模式
+        h5Url += `&guestMode=true`;
       }
       
-      // 构建案例详情的 H5 URL
-      let h5Url = `https://app.fmode.cn/dev/pobingfeng/owner/nav/cases?storeId=${storeId}&token=${token}&caseId=${encodeURIComponent(caseId)}`;
+      // 添加案例ID(不要在这里编码,避免双重编码)
+      h5Url += `&caseId=${caseId}`;
       
       // 如果有合作伙伴ID,也添加到URL中
       if (partnerId) {
@@ -861,7 +865,7 @@ Page({
       
       console.log('🌐 H5 URL:', h5Url);
       
-      // 编码 URL
+      // 编码 URL(统一在这里编码一次)
       const encodedUrl = encodeURIComponent(h5Url);
       
       // 构建 web-view 页面路径