mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-15 18:55:13 +08:00
自定义菜单加入对小程序的支持 #170
This commit is contained in:
@@ -94,42 +94,37 @@ public class WxMpMenuServiceImplTest {
|
||||
|
||||
@Test
|
||||
public void testCreateMenu_by_json() throws WxErrorException {
|
||||
String a = "{\n"
|
||||
+ " \"menu\": {\n"
|
||||
+ " \"button\": [\n"
|
||||
+ " {\n"
|
||||
+ " \"type\": \"click\",\n"
|
||||
+ " \"name\": \"今日歌曲\",\n"
|
||||
+ " \"key\": \"V1001_TODAY_MUSIC\"\n"
|
||||
+ " },\n"
|
||||
+ " {\n"
|
||||
+ " \"type\": \"click\",\n"
|
||||
+ " \"name\": \"歌手简介\",\n"
|
||||
+ " \"key\": \"V1001_TODAY_SINGER\"\n"
|
||||
+ " },\n"
|
||||
+ " {\n"
|
||||
+ " \"name\": \"菜单\",\n"
|
||||
+ " \"sub_button\": [\n"
|
||||
+ " {\n"
|
||||
+ " \"type\": \"view\",\n"
|
||||
+ " \"name\": \"搜索\",\n"
|
||||
+ " \"url\": \"http://www.soso.com/\"\n"
|
||||
+ " },\n"
|
||||
+ " {\n"
|
||||
+ " \"type\": \"view\",\n"
|
||||
+ " \"name\": \"视频\",\n"
|
||||
+ " \"url\": \"http://v.qq.com/\"\n"
|
||||
+ " },\n"
|
||||
+ " {\n"
|
||||
+ " \"type\": \"click\",\n"
|
||||
+ " \"name\": \"赞一下我们\",\n"
|
||||
+ " \"key\": \"V1001_GOOD\"\n"
|
||||
+ " }\n"
|
||||
+ " ]\n"
|
||||
+ " }\n"
|
||||
+ " ]\n"
|
||||
+ " }\n"
|
||||
+ "}";
|
||||
String a = "{\n" +
|
||||
" \"button\": [\n" +
|
||||
" {\n" +
|
||||
" \"type\": \"click\",\n" +
|
||||
" \"name\": \"今日歌曲\",\n" +
|
||||
" \"key\": \"V1001_TODAY_MUSIC\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"name\": \"菜单\",\n" +
|
||||
" \"sub_button\": [\n" +
|
||||
" {\n" +
|
||||
" \"type\": \"view\",\n" +
|
||||
" \"name\": \"搜索\",\n" +
|
||||
" \"url\": \"http://www.soso.com/\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"type\": \"miniprogram\",\n" +
|
||||
" \"name\": \"wxa\",\n" +
|
||||
" \"url\": \"http://mp.weixin.qq.com\",\n" +
|
||||
" \"appid\": \"wx286b93c14bbf93aa\",\n" +
|
||||
" \"pagepath\": \"pages/lunar/index.html\"\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"type\": \"click\",\n" +
|
||||
" \"name\": \"赞一下我们\",\n" +
|
||||
" \"key\": \"V1001_GOOD\"\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
|
||||
WxMenu menu = WxMenu.fromJson(a);
|
||||
System.out.println(menu.toJson());
|
||||
@@ -157,9 +152,11 @@ public class WxMpMenuServiceImplTest {
|
||||
button1.setKey("V1001_TODAY_MUSIC");
|
||||
|
||||
WxMenuButton button2 = new WxMenuButton();
|
||||
button2.setType(WxConsts.BUTTON_CLICK);
|
||||
button2.setName("歌手简介");
|
||||
button2.setKey("V1001_TODAY_SINGER");
|
||||
button2.setType(WxConsts.BUTTON_MINIPROGRAM);
|
||||
button2.setName("小程序");
|
||||
button2.setAppId("wx286b93c14bbf93aa");
|
||||
button2.setPagePath("pages/lunar/index.html");
|
||||
button2.setUrl("http://mp.weixin.qq.com");
|
||||
|
||||
WxMenuButton button3 = new WxMenuButton();
|
||||
button3.setName("菜单");
|
||||
|
Reference in New Issue
Block a user