Skip to content

Commit

Permalink
Merge pull request #2963 from JaneConan/bugfix/#2804-SelfMenuConfigRe…
Browse files Browse the repository at this point in the history
…sult

Bugfix/#2804 self menu config result
  • Loading branch information
JeffreySu authored Dec 2, 2023
2 parents a3f015a + 503e2e0 commit 479ecb4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public class MenuFull_RootButton


public List<MenuFull_RootButton> sub_button { get; set; }

}

#endregion

#region Conditional(个性化菜单)相关
Expand All @@ -93,6 +95,38 @@ public class MenuTryMatchResult : WxJsonResult
public List<MenuFull_RootButton> button { get; set; }
}

public class SelfMenuFull_ButtonGroup
{
public List<SelfMenuFull_RootButton> button { get; set; }
}
public class SelfMenuFull_RootButton
{
public string type { get; set; }
public string key { get; set; }
public string name { get; set; }
public string url { get; set; }

public NewsInfo news_info { get; set; }

#region 小程序

public string appid { get; set; }
public string pagepath { get; set; }

#endregion

public string media_id { get; set; }

public string article_id { get; set; }


public Sub_Button sub_button { get; set; }

}
public class Sub_Button
{
public List<MenuFull_RootButton> list { get; set; }
}
/// <summary>
/// 自定义菜单配置
/// </summary>
Expand All @@ -106,7 +140,7 @@ public class SelfMenuConfigResult : WxJsonResult
/// <summary>
/// 菜单信息
/// </summary>
public MenuFull_ButtonGroup selfmenu_info { get; set; }
public SelfMenuFull_ButtonGroup selfmenu_info { get; set; }

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Senparc.Weixin.MP;
using Senparc.Weixin.MP.CommonAPIs;
using System;
using System.Collections.Generic;
using System.Text;
Expand Down Expand Up @@ -33,5 +35,34 @@ public void SendThrowTest()

Senparc.Weixin.Config.ThrownWhenJsonResultFaild = true;//还原
}

[TestMethod]
public void GetCurrentSelfMenuInfoTest()
{
var result = CommonApi.GetCurrentSelfMenuInfo("75_eGhUgdbNzwM8IcroXssnKN4sP9QSWPcMJUJe5Ka3UTTisGP_UorAZYLb1UCZyQtdsp798EwLdbURX-cfdbacKB-IuDJ_QHMnjTHYANlch3h8_YRAw_oyfZ4mwf8LODdACAUXM");

Console.WriteLine(result);
if (result.ErrorCodeValue == 0)
{
Assert.IsTrue(true);
}
else
{
Assert.IsTrue(false);
}

string json = "{\"is_menu_open\":1,\"selfmenu_info\":{\"button\":[{\"type\":\"click\",\"name\":\"今日歌曲\",\"key\":\"V1001_TODAY_MUSIC\"},{\"name\":\"菜单\",\"sub_button\":{\"list\":[{\"type\":\"view\",\"name\":\"搜索\",\"url\":\"http:\\/\\/www.soso.com\\/\"},{\"type\":\"click\",\"name\":\"赞一下我们\",\"key\":\"V1001_GOOD\"}]}}]}}";
try
{
var test = Newtonsoft.Json.JsonConvert.DeserializeObject<SelfMenuConfigResult>(json);
Console.WriteLine(test);
Assert.IsTrue(true);
}
catch (Exception)
{
Assert.IsTrue(false);
throw;
}
}
}
}

0 comments on commit 479ecb4

Please sign in to comment.