|
@@ -1,6 +1,7 @@
|
1
|
1
|
package wechatmenu
|
2
|
2
|
|
3
|
3
|
import (
|
|
4
|
+ "bytes"
|
4
|
5
|
"encoding/json"
|
5
|
6
|
"strings"
|
6
|
7
|
"wechat-conf/controllers"
|
|
@@ -38,7 +39,7 @@ type Wehchatmenu struct {
|
38
|
39
|
}
|
39
|
40
|
type WechatMenuDetailSub struct {
|
40
|
41
|
Name string `json:"name"`
|
41
|
|
- Type string `json:"type"`
|
|
42
|
+ Type string `json:"type,omitempty"`
|
42
|
43
|
Value string `json:"value,omitempty"`
|
43
|
44
|
Url string `json:"url,omitempty"`
|
44
|
45
|
Media_Id string `json:"media_id,omitempty"`
|
|
@@ -46,7 +47,7 @@ type WechatMenuDetailSub struct {
|
46
|
47
|
}
|
47
|
48
|
type WechatMenuDetail struct {
|
48
|
49
|
Name string `json:"name"`
|
49
|
|
- Type string `json:"type"`
|
|
50
|
+ Type string `json:"type,omitempty"`
|
50
|
51
|
Value string `json:"value,omitempty"`
|
51
|
52
|
Url string `json:"url,omitempty"`
|
52
|
53
|
Media_Id string `json:"media_id,omitempty"`
|
|
@@ -71,7 +72,6 @@ func (c *MenuController) GetMenuList() {
|
71
|
72
|
c.ResponseError(err)
|
72
|
73
|
}
|
73
|
74
|
menu, err := client.GetMenu()
|
74
|
|
- beego.Error(menu)
|
75
|
75
|
var keyList []*model.TaWechatKeyValue
|
76
|
76
|
var imgList []*model.TaWechatImg
|
77
|
77
|
if menu != nil {
|
|
@@ -202,14 +202,20 @@ func (c *MenuController) RefreshMenu() {
|
202
|
202
|
utils.LogInfo(wechatmenu)
|
203
|
203
|
var upwechat WechatMenu
|
204
|
204
|
upwechat.Button = wechatmenu
|
205
|
|
- menuData, err := json.Marshal(upwechat)
|
206
|
|
- if err != nil {
|
207
|
|
- c.ResponseError(err)
|
208
|
|
- }
|
209
|
|
- beego.Error(string(menuData))
|
|
205
|
+
|
|
206
|
+ b := bytes.NewBuffer([]byte{})
|
|
207
|
+ jsonEncoder := json.NewEncoder(b)
|
|
208
|
+ jsonEncoder.SetEscapeHTML(false)
|
|
209
|
+ jsonEncoder.Encode(upwechat)
|
|
210
|
+ // menuData, err := json.Marshal(upwechat)
|
|
211
|
+ // if err != nil {
|
|
212
|
+ // c.ResponseError(err)
|
|
213
|
+ // }
|
|
214
|
+ menuData := b.String()
|
|
215
|
+ beego.Error(menuData)
|
210
|
216
|
utils.LogInfo("↓↓↓↓_________________________↓↓↓↓wechamenu when upload(upload)↓↓↓↓___________________↓↓↓↓")
|
211
|
|
- utils.LogInfo(string(menuData))
|
212
|
|
- err = c.dao.UpdateWechatMenu(string(menuData), user.OrgId)
|
|
217
|
+ utils.LogInfo(menuData)
|
|
218
|
+ err = c.dao.UpdateWechatMenu(menuData, user.OrgId)
|
213
|
219
|
if err != nil {
|
214
|
220
|
c.ResponseError(err)
|
215
|
221
|
}
|
|
@@ -221,7 +227,7 @@ func (c *MenuController) RefreshMenu() {
|
221
|
227
|
if err != nil {
|
222
|
228
|
c.ResponseError(err)
|
223
|
229
|
}
|
224
|
|
- err = client.RefreshMenu(menuData)
|
|
230
|
+ err = client.RefreshMenu([]byte(menuData))
|
225
|
231
|
if err != nil {
|
226
|
232
|
c.ResponseError(err)
|
227
|
233
|
}
|