This commit is contained in:
xxj
2023-12-22 15:29:51 +08:00
parent 57b4b77a40
commit f1aa07be12
2 changed files with 3 additions and 3 deletions

BIN
mydraw/out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

View File

@@ -128,8 +128,7 @@ func (_wx *wxTools) GetAPITicket() (ticket string, err error) {
// GetJsTicket 获取微信js ticket
func (_wx *wxTools) GetJsTicket() (ticket string, err error) {
//先从缓存中获取
cache := mycache.NewCache("weixin_js_ticket")
err = cache.Value("base", &ticket)
err = _wx.cache.Value("weixin_js_ticket", &ticket)
if err == nil {
return
}
@@ -156,11 +155,12 @@ func (_wx *wxTools) GetJsTicket() (ticket string, err error) {
err = e2
return
}
mylog.Error(string(body))
var result APITicket
json.Unmarshal(body, &result)
ticket = result.Ticket
//保存缓存
cache.Add("base", ticket, 7000*time.Second)
_wx.cache.Add("base", ticket, 7000*time.Second)
return
}