github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/bizwifi/homepage/set.go (about) 1 package homepage 2 3 import ( 4 "github.com/chanxuehong/wechat/mp/core" 5 ) 6 7 // 默认模板 8 func NewSetParameters1(shopId int64) interface{} { 9 return &struct { 10 ShopId int64 `json:"shop_id"` 11 TemplateId int64 `json:"template_id"` 12 }{ 13 ShopId: shopId, 14 TemplateId: 0, 15 } 16 } 17 18 // 自定义url 19 func NewSetParameters2(shopId int64, url string) interface{} { 20 para := struct { 21 ShopId int64 `json:"shop_id"` 22 TemplateId int64 `json:"template_id"` 23 Struct struct { 24 URL string `json:"url"` 25 } `json:"struct"` 26 }{ 27 ShopId: shopId, 28 TemplateId: 1, 29 } 30 31 para.Struct.URL = url 32 return ¶ 33 } 34 35 // 设置商家主页 36 // 37 // 要求 para 经过 encoding/json 后满足指定的格式要求 38 func Set(clt *core.Client, para interface{}) (err error) { 39 var result core.Error 40 41 incompleteURL := "https://api.weixin.qq.com/bizwifi/homepage/set?access_token=" 42 if err = clt.PostJSON(incompleteURL, para, &result); err != nil { 43 return 44 } 45 46 if result.ErrCode != core.ErrCodeOK { 47 err = &result 48 return 49 } 50 return 51 }