seyanew 2 днів тому
батько
коміт
17214dd817

+ 38 - 1
fhKeeper/formulahousekeeper/management-crm/src/main/java/com/management/platform/controller/WechatAccountController.java

@@ -605,7 +605,7 @@ public class WechatAccountController {
      */
     public  boolean createMenuWithMiniProgram(String accessToken) {
         // 构建菜单JSON
-        String menuJson = buildMenuJson();
+        String menuJson = buildHrefMenuJson();
 
         // 设置请求头
         HttpHeaders headers = new HttpHeaders();
@@ -641,6 +641,43 @@ public class WechatAccountController {
 
     }
 
+    private static String buildHrefMenuJson() {
+        // 示例菜单结构:主菜单包含3个子菜单,其中一个是小程序链接
+        JSONObject menu = new JSONObject();
+
+        // 第二个菜单项 - 包含子菜单
+        JSONObject button2 = new JSONObject();
+        button2.put("type", "view");
+        button2.put("name", "临研GCP培训");
+        button2.put("url", "http://mobclass.m-clitrial.com/");
+
+        /*JSONObject subButton1 = new JSONObject();
+        subButton1.put("type", "view");
+        subButton1.put("name", "官网首页");
+        subButton1.put("url", "https://www.yourdomain.com");*/
+
+//        JSONObject subButton2 = new JSONObject();
+//        subButton2.put("type", "miniprogram");
+//        subButton2.put("name", "打开小程序");
+//        subButton2.put("url", "https://mp.weixin.qq.com/"); // 不支持小程序的老版本客户端将打开此url
+//        subButton2.put("appid", "wxaaf19cfbbe1ff950"); // 小程序appid
+//        subButton2.put("pagepath", "pages/training/training"); // 小程序页面路径
+
+//        button2.put("sub_button", new JSONObject[]{ subButton2});
+
+        // 第三个菜单项 - 普通点击菜单
+//        JSONObject button3 = new JSONObject();
+//        button3.put("type", "click");
+//        button3.put("name", "联系我们");
+//        button3.put("key", "V1001_CONTACT_US");
+
+//        menu.put("button", new JSONObject[]{button2,button3});
+
+        menu.put("button", new JSONObject[]{button2});
+
+        return menu.toJSONString();
+    }
+
     /**
      * 构建包含小程序链接的菜单JSON
      */