|
@@ -11,7 +11,6 @@ import ( |
|
|
"encoding/xml" |
|
|
"encoding/xml" |
|
|
"errors" |
|
|
"errors" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/tidwall/gjson" |
|
|
|
|
|
"log" |
|
|
"log" |
|
|
"net/http" |
|
|
"net/http" |
|
|
"strings" |
|
|
"strings" |
|
@@ -113,19 +112,29 @@ func WXMsgReceive(c *gin.Context) { |
|
|
WXMsgReply(c, eventMsg.ToUserName, eventMsg.FromUserName, err.Error()) |
|
|
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") { |
|
|
if strings.Contains(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply") { |
|
|
id := strings.ReplaceAll(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply_", "") |
|
|
id := strings.ReplaceAll(strings.ToLower(eventMsg.EventKey), "official_account_custom_reply_", "") |
|
|
var mod model.SysModule |
|
|
var mod model.SysModule |
|
|
db.Db.Where("mod_id=?", id).Get(&mod) |
|
|
db.Db.Where("mod_id=?", id).Get(&mod) |
|
|
|
|
|
fmt.Println(mod) |
|
|
if mod.Data == "" { |
|
|
if mod.Data == "" { |
|
|
|
|
|
fmt.Println(333) |
|
|
|
|
|
|
|
|
return |
|
|
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) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|