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) }