diff --git a/CoreCms.Net.Model/CoreCms.Net.Model.xml b/CoreCms.Net.Model/CoreCms.Net.Model.xml
index 12274dd0..90b5e8ef 100644
--- a/CoreCms.Net.Model/CoreCms.Net.Model.xml
+++ b/CoreCms.Net.Model/CoreCms.Net.Model.xml
@@ -13450,6 +13450,61 @@
订单号
+
+
+ 公众号菜单按钮提交参数类
+
+
+
+
+ 按钮列表
+
+
+
+
+ 按钮具体类型
+
+
+
+
+ 菜单的响应动作类型,view表示网页类型,click表示点击类型,miniprogram表示小程序类型
+
+
+
+
+ 菜单KEY值,用于消息接口推送,不超过128字节
+
+
+
+
+ 菜单标题,不超过16个字节,子菜单不超过60个字节
+
+
+
+
+ 网页 链接,用户点击菜单可打开链接,不超过1024字节。 type为miniprogram时,不支持小程序的老版本客户端将打开本url。
+
+
+
+
+ 小程序的appid(仅认证公众号可配置)
+
+
+
+
+ 小程序的页面路径
+
+
+
+
+ 调用新增永久素材接口返回的合法media_id
+
+
+
+
+ 二级菜单数组,个数应为1~5个
+
+
扩展 表示 [POST] /wxa/business/getliveinfo 接口的请求。
diff --git a/CoreCms.Net.Model/WeChatEntites/MenuFull_ButtonGroupForSkit.cs b/CoreCms.Net.Model/WeChatEntites/MenuFull_ButtonGroupForSkit.cs
index cb87ca85..f0cc7f81 100644
--- a/CoreCms.Net.Model/WeChatEntites/MenuFull_ButtonGroupForSkit.cs
+++ b/CoreCms.Net.Model/WeChatEntites/MenuFull_ButtonGroupForSkit.cs
@@ -7,8 +7,14 @@ using SKIT.FlurlHttpClient.Wechat.Api.Models;
namespace CoreCms.Net.Model.WeChatEntites
{
+ ///
+ /// 公众号菜单按钮提交参数类
+ ///
public class MenuFull_ButtonGroupForSkit
{
- public List button { get; set; }
+ ///
+ /// 按钮列表
+ ///
+ public List button { get; set; }
}
}
diff --git a/CoreCms.Net.Model/WeChatEntites/MenuFull_RootButton.cs b/CoreCms.Net.Model/WeChatEntites/MenuFull_RootButton.cs
new file mode 100644
index 00000000..3d603683
--- /dev/null
+++ b/CoreCms.Net.Model/WeChatEntites/MenuFull_RootButton.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CoreCms.Net.Model.WeChatEntites
+{
+ ///
+ /// 按钮具体类型
+ ///
+ public class MenuFull_RootButton
+ {
+ ///
+ /// 菜单的响应动作类型,view表示网页类型,click表示点击类型,miniprogram表示小程序类型
+ ///
+ public string type { get; set; }
+
+ ///
+ /// 菜单KEY值,用于消息接口推送,不超过128字节
+ ///
+ public string key { get; set; }
+
+ ///
+ /// 菜单标题,不超过16个字节,子菜单不超过60个字节
+ ///
+ public string name { get; set; }
+
+ ///
+ /// 网页 链接,用户点击菜单可打开链接,不超过1024字节。 type为miniprogram时,不支持小程序的老版本客户端将打开本url。
+ ///
+ public string url { get; set; }
+
+ ///
+ /// 小程序的appid(仅认证公众号可配置)
+ ///
+ public string appid { get; set; }
+
+ ///
+ /// 小程序的页面路径
+ ///
+ public string pagepath { get; set; }
+
+ ///
+ /// 调用新增永久素材接口返回的合法media_id
+ ///
+ public string media_id { get; set; }
+
+ ///
+ /// 二级菜单数组,个数应为1~5个
+ ///
+ public List sub_button { get; set; }
+ }
+}
diff --git a/CoreCms.Net.Web.Admin/Controllers/WeChat/WeChatMenuController.cs b/CoreCms.Net.Web.Admin/Controllers/WeChat/WeChatMenuController.cs
index 095decf5..1d87dc0b 100644
--- a/CoreCms.Net.Web.Admin/Controllers/WeChat/WeChatMenuController.cs
+++ b/CoreCms.Net.Web.Admin/Controllers/WeChat/WeChatMenuController.cs
@@ -18,6 +18,7 @@ using SKIT.FlurlHttpClient.Wechat.Api.Models;
using CoreCms.Net.WeChat.Service.HttpClients;
using CoreCms.Net.WeChat.Service.Enums;
using SKIT.FlurlHttpClient.Wechat.Api;
+using Microsoft.IdentityModel.Tokens;
namespace CoreCms.Net.Web.Admin.Controllers.Api.WeChat
{
@@ -70,6 +71,53 @@ namespace CoreCms.Net.Web.Admin.Controllers.Api.WeChat
public async Task CreateMenu(MenuFull_ButtonGroupForSkit menu)
{
var jm = new AdminUiCallBack();
+
+ if (!menu.button.Any())
+ {
+ jm.msg = "请不要提交空的菜单数据";
+ return jm;
+ }
+
+ var skitButtons = new List();
+
+ foreach (var itemParent in menu.button)
+ {
+ if (string.IsNullOrEmpty(itemParent.name) && string.IsNullOrEmpty(itemParent.name)) continue;
+
+ var bt = new CgibinMenuCreateRequest.Types.Button
+ {
+ Type = itemParent.type,
+ Key = itemParent.key,
+ Name = itemParent.name,
+ Url = itemParent.url,
+ MiniProgramAppId = itemParent.appid,
+ MiniProgramPagePath = itemParent.pagepath,
+ MediaId = itemParent.media_id,
+ ArticleId = "",
+ SubButtonList = new List()
+ };
+
+ if (!itemParent.sub_button.Any()) continue;
+
+ foreach (var btChild in from itemChild in itemParent.sub_button
+ where !string.IsNullOrEmpty(itemChild.key) || !string.IsNullOrEmpty(itemChild.name)
+ select new CgibinMenuCreateRequest.Types.Button
+ {
+ Type = itemChild.type,
+ Key = itemChild.key,
+ Name = itemChild.name,
+ Url = itemChild.url,
+ MiniProgramAppId = itemChild.appid,
+ MiniProgramPagePath = itemChild.pagepath,
+ MediaId = itemChild.media_id,
+ ArticleId = ""
+ })
+ {
+ bt.SubButtonList.Add(btChild);
+ }
+ skitButtons.Add(bt);
+ }
+
try
{
var client = _weChatApiHttpClientFactory.CreateWeXinClient();
@@ -77,7 +125,7 @@ namespace CoreCms.Net.Web.Admin.Controllers.Api.WeChat
var request = new CgibinMenuCreateRequest()
{
AccessToken = accessToken,
- ButtonList = menu.button
+ ButtonList = skitButtons
};
var response = await client.ExecuteCgibinMenuCreateAsync(request, HttpContext.RequestAborted);
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/wechatoffiaccount/menusetting/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/wechatoffiaccount/menusetting/index.html
index 8ab983dd..99ba0d0d 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/wechatoffiaccount/menusetting/index.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/wechatoffiaccount/menusetting/index.html
@@ -9,8 +9,15 @@