@@ -94,42 +94,37 @@ public void testDeleteConditionalMenu() throws WxErrorException {
94
94
95
95
@ Test
96
96
public void testCreateMenu_by_json () throws WxErrorException {
97
- String a = "{\n "
98
- + " \" menu\" : {\n "
99
- + " \" button\" : [\n "
100
- + " {\n "
101
- + " \" type\" : \" click\" ,\n "
102
- + " \" name\" : \" 今日歌曲\" ,\n "
103
- + " \" key\" : \" V1001_TODAY_MUSIC\" \n "
104
- + " },\n "
105
- + " {\n "
106
- + " \" type\" : \" click\" ,\n "
107
- + " \" name\" : \" 歌手简介\" ,\n "
108
- + " \" key\" : \" V1001_TODAY_SINGER\" \n "
109
- + " },\n "
110
- + " {\n "
111
- + " \" name\" : \" 菜单\" ,\n "
112
- + " \" sub_button\" : [\n "
113
- + " {\n "
114
- + " \" type\" : \" view\" ,\n "
115
- + " \" name\" : \" 搜索\" ,\n "
116
- + " \" url\" : \" http://www.soso.com/\" \n "
117
- + " },\n "
118
- + " {\n "
119
- + " \" type\" : \" view\" ,\n "
120
- + " \" name\" : \" 视频\" ,\n "
121
- + " \" url\" : \" http://v.qq.com/\" \n "
122
- + " },\n "
123
- + " {\n "
124
- + " \" type\" : \" click\" ,\n "
125
- + " \" name\" : \" 赞一下我们\" ,\n "
126
- + " \" key\" : \" V1001_GOOD\" \n "
127
- + " }\n "
128
- + " ]\n "
129
- + " }\n "
130
- + " ]\n "
131
- + " }\n "
132
- + "}" ;
97
+ String a = "{\n " +
98
+ " \" button\" : [\n " +
99
+ " {\n " +
100
+ " \" type\" : \" click\" ,\n " +
101
+ " \" name\" : \" 今日歌曲\" ,\n " +
102
+ " \" key\" : \" V1001_TODAY_MUSIC\" \n " +
103
+ " },\n " +
104
+ " {\n " +
105
+ " \" name\" : \" 菜单\" ,\n " +
106
+ " \" sub_button\" : [\n " +
107
+ " {\n " +
108
+ " \" type\" : \" view\" ,\n " +
109
+ " \" name\" : \" 搜索\" ,\n " +
110
+ " \" url\" : \" http://www.soso.com/\" \n " +
111
+ " },\n " +
112
+ " {\n " +
113
+ " \" type\" : \" miniprogram\" ,\n " +
114
+ " \" name\" : \" wxa\" ,\n " +
115
+ " \" url\" : \" http://mp.weixin.qq.com\" ,\n " +
116
+ " \" appid\" : \" wx286b93c14bbf93aa\" ,\n " +
117
+ " \" pagepath\" : \" pages/lunar/index.html\" \n " +
118
+ " },\n " +
119
+ " {\n " +
120
+ " \" type\" : \" click\" ,\n " +
121
+ " \" name\" : \" 赞一下我们\" ,\n " +
122
+ " \" key\" : \" V1001_GOOD\" \n " +
123
+ " }\n " +
124
+ " ]\n " +
125
+ " }\n " +
126
+ " ]\n " +
127
+ "}" ;
133
128
134
129
WxMenu menu = WxMenu .fromJson (a );
135
130
System .out .println (menu .toJson ());
@@ -157,9 +152,11 @@ public Object[][] getMenu() {
157
152
button1 .setKey ("V1001_TODAY_MUSIC" );
158
153
159
154
WxMenuButton button2 = new WxMenuButton ();
160
- button2 .setType (WxConsts .BUTTON_CLICK );
161
- button2 .setName ("歌手简介" );
162
- button2 .setKey ("V1001_TODAY_SINGER" );
155
+ button2 .setType (WxConsts .BUTTON_MINIPROGRAM );
156
+ button2 .setName ("小程序" );
157
+ button2 .setAppId ("wx286b93c14bbf93aa" );
158
+ button2 .setPagePath ("pages/lunar/index.html" );
159
+ button2 .setUrl ("http://mp.weixin.qq.com" );
163
160
164
161
WxMenuButton button3 = new WxMenuButton ();
165
162
button3 .setName ("菜单" );
0 commit comments