github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/card/color.go (about) 1 package card 2 3 import ( 4 "github.com/chanxuehong/wechat/mp/core" 5 ) 6 7 type Color struct { 8 Name string `json:"name"` 9 Value string `json:"value"` 10 } 11 12 // 获取卡券最新的颜色列表. 13 func GetColors(clt *core.Client) (colors []Color, err error) { 14 var result struct { 15 core.Error 16 Colors []Color `json:"colors"` 17 } 18 19 incompleteURL := "https://api.weixin.qq.com/card/getcolors?access_token=" 20 if err = clt.GetJSON(incompleteURL, &result); err != nil { 21 return 22 } 23 24 if result.ErrCode != core.ErrCodeOK { 25 err = &result.Error 26 return 27 } 28 colors = result.Colors 29 return 30 }