0235699曾露 23 часов назад
Родитель
Сommit
88a8e95bf6

+ 2 - 1
app.json

@@ -7,7 +7,8 @@
       "root": "common-page",
       "name": "common",
       "pages": [
-        "pages/web-view/index"
+        "pages/web-view/index",
+        "pages/map-open/index"
       ]
     },
     {

+ 47 - 0
common-page/pages/map-open/index.js

@@ -0,0 +1,47 @@
+/**
+ * 地图导航页面
+ * H5 通过 wx.miniProgram.navigateTo 跳转到此页面
+ * 参数: latitude, longitude, name, address
+ * 示例: wx.miniProgram.navigateTo({url: '/common-page/pages/map-open/index?latitude=39.908&longitude=116.397&name=天安门&address=北京市东城区'})
+ */
+Page({
+  data: {},
+
+  onLoad: function (options) {
+    const { latitude, longitude, name, address } = options;
+
+    if (!latitude || !longitude) {
+      wx.showToast({
+        title: '缺少位置信息',
+        icon: 'none'
+      });
+      setTimeout(() => {
+        wx.navigateBack();
+      }, 1500);
+      return;
+    }
+
+    // 直接打开地图导航
+    wx.openLocation({
+      latitude: parseFloat(latitude),
+      longitude: parseFloat(longitude),
+      name: decodeURIComponent(name || ''),
+      address: decodeURIComponent(address || ''),
+      scale: 18,
+      success: () => {
+        console.log('✅ 地图打开成功');
+      },
+      fail: (err) => {
+        console.error('❌ 打开地图失败:', err);
+        wx.showToast({
+          title: '打开地图失败',
+          icon: 'none'
+        });
+      },
+      complete: () => {
+        // 打开地图后返回上一页
+        wx.navigateBack();
+      }
+    });
+  }
+});

+ 4 - 0
common-page/pages/map-open/index.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "地图导航",
+  "usingComponents": {}
+}

+ 3 - 0
common-page/pages/map-open/index.wxml

@@ -0,0 +1,3 @@
+<view class="container">
+  <van-loading size="24px" vertical>正在打开地图...</van-loading>
+</view>

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

@@ -0,0 +1,7 @@
+.container {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 100vh;
+  background-color: #f6f5fa;
+}

+ 5 - 0
index.js

@@ -517,6 +517,11 @@ Page({
         url += `&productId=${productId}`;
       }
       
+      // 如果有异业合作伙伴ID,添加到URL参数中传回web-view
+      if (partnerId) {
+        url += `&partnerId=${partnerId}`;
+      }
+      
       console.log('✅ 跳转到店铺页面:', url);
       
       wx.redirectTo({