0235699曾露 пре 1 дан
родитељ
комит
6bc3c30f75

+ 2 - 0
.vscode/settings.json

@@ -0,0 +1,2 @@
+{
+}

+ 97 - 11
common-page/pages/map-open/index.js

@@ -5,43 +5,129 @@
  * 示例: wx.miniProgram.navigateTo({url: '/common-page/pages/map-open/index?latitude=39.908&longitude=116.397&name=天安门&address=北京市东城区'})
  */
 Page({
-  data: {},
+  data: {
+    loading: true,
+    errorMsg: ''
+  },
 
   onLoad: function (options) {
+    console.log('===========================================');
+    console.log('======= 地图导航页面 =======');
+    console.log('接收参数:', options);
+    console.log('===========================================');
+    
     const { latitude, longitude, name, address } = options;
 
+    // 参数验证
     if (!latitude || !longitude) {
+      console.error('❌ 缺少位置信息');
+      this.setData({
+        loading: false,
+        errorMsg: '缺少位置信息'
+      });
+      
       wx.showToast({
         title: '缺少位置信息',
-        icon: 'none'
+        icon: 'none',
+        duration: 2000
       });
+      
       setTimeout(() => {
-        wx.navigateBack();
-      }, 1500);
+        wx.navigateBack({
+          fail: () => {
+            // 如果返回失败,跳转到首页
+            wx.switchTab({
+              url: '/pages/index/index',
+              fail: () => {
+                wx.reLaunch({
+                  url: '/pages/index/index'
+                });
+              }
+            });
+          }
+        });
+      }, 2000);
       return;
     }
 
+    // 解码参数
+    const decodedName = name ? decodeURIComponent(name) : '目的地';
+    const decodedAddress = address ? decodeURIComponent(address) : '';
+    
+    console.log('📍 位置信息:');
+    console.log('   - 纬度:', latitude);
+    console.log('   - 经度:', longitude);
+    console.log('   - 名称:', decodedName);
+    console.log('   - 地址:', decodedAddress);
+
     // 直接打开地图导航
+    this.openLocation(latitude, longitude, decodedName, decodedAddress);
+  },
+  
+  /**
+   * 打开地图
+   */
+  openLocation(latitude, longitude, name, address) {
     wx.openLocation({
       latitude: parseFloat(latitude),
       longitude: parseFloat(longitude),
-      name: decodeURIComponent(name || ''),
-      address: decodeURIComponent(address || ''),
+      name: name,
+      address: address,
       scale: 18,
       success: () => {
         console.log('✅ 地图打开成功');
+        this.setData({ loading: false });
       },
       fail: (err) => {
         console.error('❌ 打开地图失败:', err);
-        wx.showToast({
-          title: '打开地图失败',
-          icon: 'none'
+        
+        this.setData({
+          loading: false,
+          errorMsg: '打开地图失败'
+        });
+        
+        wx.showModal({
+          title: '提示',
+          content: '打开地图失败,请检查是否授权位置权限',
+          showCancel: true,
+          cancelText: '返回',
+          confirmText: '重试',
+          success: (res) => {
+            if (res.confirm) {
+              // 重试
+              this.openLocation(latitude, longitude, name, address);
+            } else {
+              // 返回
+              wx.navigateBack({
+                fail: () => {
+                  wx.switchTab({
+                    url: '/pages/index/index',
+                    fail: () => {
+                      wx.reLaunch({
+                        url: '/pages/index/index'
+                      });
+                    }
+                  });
+                }
+              });
+            }
+          }
         });
       },
       complete: () => {
-        // 打开地图后返回上一页
-        wx.navigateBack();
+        // 打开地图后延迟返回,给用户时间查看
+        setTimeout(() => {
+          wx.navigateBack({
+            fail: () => {
+              console.log('返回失败,可能是首页');
+            }
+          });
+        }, 500);
       }
     });
+  },
+  
+  onUnload: function () {
+    console.log('地图导航页面卸载');
   }
 });

+ 10 - 1
common-page/pages/map-open/index.wxml

@@ -1,3 +1,12 @@
 <view class="container">
-  <van-loading size="24px" vertical>正在打开地图...</van-loading>
+  <view wx:if="{{loading}}" class="loading-wrapper">
+    <van-loading size="24px" vertical>正在打开地图...</van-loading>
+  </view>
+  
+  <view wx:else class="error-wrapper">
+    <van-empty
+      image="error"
+      description="{{errorMsg}}"
+    />
+  </view>
 </view>

+ 8 - 0
common-page/pages/map-open/index.wxss

@@ -5,3 +5,11 @@
   height: 100vh;
   background-color: #f6f5fa;
 }
+
+.loading-wrapper,
+.error-wrapper {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  justify-content: center;
+}

+ 74 - 0
index.js

@@ -508,6 +508,13 @@ Page({
         scanCount
       });
       
+      // 如果有产品ID,直接跳转到产品详情的 H5 页面
+      if (productId) {
+        console.log('🎯 检测到产品ID,跳转到产品详情页');
+        await this.redirectToProductDetail(storeId, productId, partnerId);
+        return;
+      }
+      
       // 获取默认首页路径并跳转
       let url = getApp().globalData.rootPage || getApp().globalData.defaultTabBar.list[0].pagePath;
       url += `?storeId=${storeId}`;
@@ -589,6 +596,73 @@ Page({
     }
   },
   
+  /**
+   * 跳转到产品详情的 H5 页面
+   * @param {string} storeId - 店铺 ID
+   * @param {string} productId - 产品 ID
+   * @param {string} partnerId - 可选的合作伙伴 ID
+   */
+  async redirectToProductDetail(storeId, productId, partnerId = null) {
+    try {
+      console.log('===========================================');
+      console.log('======= 跳转到产品详情页 =======');
+      console.log('店铺 ID:', storeId);
+      console.log('产品 ID:', productId);
+      if (partnerId) console.log('合作伙伴 ID:', partnerId);
+      console.log('===========================================');
+      
+      const currentUser = Parse.User.current();
+      if (!currentUser) {
+        console.error('❌ 用户未登录,无法跳转');
+        return;
+      }
+      
+      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=${token}&productId=${encodeURIComponent(productId)}`;
+      
+      // 如果有合作伙伴ID,也添加到URL中
+      if (partnerId) {
+        h5Url += `&partnerId=${partnerId}`;
+      }
+      
+      console.log('🌐 H5 URL:', h5Url);
+      
+      // 编码 URL
+      const encodedUrl = encodeURIComponent(h5Url);
+      
+      // 构建 web-view 页面路径
+      let webViewPath = `/common-page/pages/web-view/index?path=${encodedUrl}&storeId=${storeId}`;
+      
+      console.log('📄 web-view 页面路径:', webViewPath.substring(0, 100) + '...');
+      console.log('===========================================');
+      
+      wx.redirectTo({
+        url: webViewPath,
+        success: () => {
+          console.log('✅ 跳转到产品详情页成功');
+        },
+        fail: (err) => {
+          console.error('❌ 跳转失败:', err);
+          // 如果 redirectTo 失败,尝试 reLaunch
+          wx.reLaunch({
+            url: webViewPath,
+            fail: (err2) => {
+              console.error('❌ reLaunch 也失败:', err2);
+            }
+          });
+        }
+      });
+    } catch (error) {
+      console.error('❌ 跳转到产品详情页失败:', error);
+    }
+  },
+  
   /**
    * 记录扫码统计信息
    * @param {Object} params - 扫码参数对象

+ 16 - 3
nova-pbf/components/home/index.js

@@ -338,9 +338,11 @@ Component({
 
     /**
      * 跳转到产品中心页面
+     * @param {string} productId - 可选的产品ID,用于直接跳转到特定产品详情
      */
-    async navigateToProducts() {
-      await this.navigateToH5Page('owner/nav/products');
+    async navigateToProducts(productId = null) {
+      const params = productId ? { productId } : {};
+      await this.navigateToH5Page('owner/nav/products', params);
     },
 
     /**
@@ -353,8 +355,9 @@ Component({
     /**
      * 通用 H5 页面跳转方法
      * @param {string} pagePath - H5 页面路径(例如: 'owner/nav/cases')
+     * @param {object} extraParams - 额外的URL参数对象(例如: { productId: 'xxx' })
      */
-    async navigateToH5Page(pagePath) {
+    async navigateToH5Page(pagePath, extraParams = {}) {
       console.log('===========================================');
       console.log(`======= 小程序跳转 H5: ${pagePath} =======`);
       console.log('===========================================');
@@ -435,6 +438,16 @@ Component({
       
       h5Url += `token=${token}`;
       
+      // 添加额外的参数(如 productId)
+      if (extraParams && Object.keys(extraParams).length > 0) {
+        for (const [key, value] of Object.entries(extraParams)) {
+          if (value) {
+            h5Url += `&${key}=${encodeURIComponent(value)}`;
+            console.log(`   - 添加参数 ${key}:`, value);
+          }
+        }
+      }
+      
       // 编码后的 URL
       const encodedUrl = encodeURIComponent(h5Url);
       

+ 1 - 13
nova-pbf/components/home/index.wxml

@@ -42,21 +42,9 @@
         </view>
       </swiper-item>
       
-      <!-- 第3屏:全程跟踪 -->
+      <!-- 第3屏:AI专属顾问 -->
       <swiper-item>
         <view class="swiper-item-content swiper-item-3">
-          <view class="feature-icon">✅</view>
-          <view class="feature-title">全程跟踪 安心无忧</view>
-          <view class="feature-desc">
-            <text>订单进度实时查看</text>
-            <text>安装售后全程保障</text>
-          </view>
-        </view>
-      </swiper-item>
-      
-      <!-- 第4屏:AI专属顾问 -->
-      <swiper-item>
-        <view class="swiper-item-content swiper-item-4">
           <view class="feature-icon">🤖</view>
           <view class="feature-title">AI专属顾问 智能推荐</view>
           <view class="feature-desc">