From 6f4a517c7609cada695e9ab6219e009c887fa90e Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 10 Aug 2023 14:43:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=AC=E4=BC=97=E5=8F=B7=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/md/md_wechat_menu.go | 8 ++++++++ app/svc/svc_wechat.go | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/app/md/md_wechat_menu.go b/app/md/md_wechat_menu.go index 03599f8..e246b33 100644 --- a/app/md/md_wechat_menu.go +++ b/app/md/md_wechat_menu.go @@ -2,6 +2,11 @@ package md type WechatButton struct { Name string `json:"name"` + Type string `json:"type"` + Url string `json:"url"` + Appid string `json:"appid,omitempty"` + Pagepath string `json:"pagepath"` + Key string `json:"key,omitempty"` SubButton []WechatSubButton `json:"sub_button,omitempty"` } type WechatSubButton struct { @@ -16,6 +21,9 @@ type OffcialWechatButton struct { Type string `json:"type,omitempty"` Name string `json:"name"` Key string `json:"key,omitempty"` + Url string `json:"url"` + Appid string `json:"appid,omitempty"` + Pagepath string `json:"pagepath"` SubButton SubButtonMap `json:"sub_button,omitempty"` } type SubButtonMap struct { diff --git a/app/svc/svc_wechat.go b/app/svc/svc_wechat.go index d9cfd6c..1ea1a18 100644 --- a/app/svc/svc_wechat.go +++ b/app/svc/svc_wechat.go @@ -9,6 +9,7 @@ import ( "applet/app/utils/cache" "encoding/json" "errors" + "fmt" "github.com/gin-gonic/gin" "github.com/tidwall/gjson" ) @@ -28,11 +29,16 @@ func GetMenu(c *gin.Context) { } var offcialMenuList = make([]md.OffcialWechatButton, 0) menu, err := utils.GetWechatSelfMenu(token) + fmt.Println(menu) menuStr := gjson.Get(menu, "selfmenu_info.button").String() json.Unmarshal([]byte(menuStr), &offcialMenuList) for _, v := range offcialMenuList { var tmp = md.WechatButton{ Name: v.Name, + Type: v.Type, + Url: v.Url, + Pagepath: v.Pagepath, + Appid: v.Appid, SubButton: []md.WechatSubButton{}, } for _, v1 := range v.SubButton.List { @@ -57,8 +63,16 @@ func GetMenu(c *gin.Context) { } sysCfgDb.SysCfgUpdate("wechat_menu", utils.SerializeStr(menuList)) } + replyContentSet := []map[string]string{ + {"msgType": "text", "name": "文本"}, + {"msgType": "image", "name": "图片"}, + {"msgType": "video", "name": "视频"}, + {"msgType": "voice", "name": "语音"}, + {"msgType": "article", "name": "文章"}, + } res := map[string]interface{}{ - "button": menuList, + "button": menuList, + "replyContentSet": replyContentSet, } e.OutSuc(c, res, nil) }