|
|
@@ -11,7 +11,6 @@ import ( |
|
|
|
"encoding/xml" |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"github.com/tidwall/gjson" |
|
|
|
"log" |
|
|
|
"net/http" |
|
|
|
"strings" |
|
|
@@ -113,19 +112,29 @@ func WXMsgReceive(c *gin.Context) { |
|
|
|
WXMsgReply(c, eventMsg.ToUserName, eventMsg.FromUserName, err.Error()) |
|
|
|
} |
|
|
|
} |
|
|
|
if eventMsg.Event == "click" { //公众号点击 |
|
|
|
if eventMsg.Event == "CLICK" { //公众号点击 |
|
|
|
if strings.Contains(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply") { |
|
|
|
id := strings.ReplaceAll(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply_", "") |
|
|
|
var mod model.SysModule |
|
|
|
db.Db.Where("mod_id=?", id).Get(&mod) |
|
|
|
fmt.Println(mod) |
|
|
|
if mod.Data == "" { |
|
|
|
fmt.Println(333) |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
if gjson.Get(mod.Data, "msgType").String() == "text" { |
|
|
|
svc.WXMsgTextReply(c, msg.ToUserName, msg.FromUserName, gjson.Get(mod.Data, "text.content").String()) |
|
|
|
} |
|
|
|
if gjson.Get(mod.Data, "msgType").String() == "image" { |
|
|
|
svc.WXMsgImageReply(c, msg.ToUserName, msg.FromUserName, gjson.Get(mod.Data, "image.mediaId").String()) |
|
|
|
var data []md.ReplyContent |
|
|
|
json.Unmarshal([]byte(mod.Data), &data) |
|
|
|
for _, v := range data { |
|
|
|
if v.MsgType == "text" { |
|
|
|
fmt.Println(1111) |
|
|
|
|
|
|
|
svc.WXMsgTextReply(c, msg.ToUserName, msg.FromUserName, v.Text.Content) |
|
|
|
} |
|
|
|
if v.MsgType == "image" { |
|
|
|
fmt.Println(22222) |
|
|
|
svc.WXMsgImageReply(c, msg.ToUserName, msg.FromUserName, v.Image.MediaId) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|