This commit is contained in:
苏尹岚
2021-04-20 14:44:27 +08:00
parent a2b440172e
commit 7ab406d18f
2 changed files with 16 additions and 4 deletions

View File

@@ -139,10 +139,17 @@ func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{},
//https://union.meituan.com/v2/apiDetail?id=8
//https://runion.meituan.com/generateLink
func (a *API) GenerateLink(actID int, userID string) (url string, err error) {
_, err = a.AccessAPI("miniCode", false, map[string]interface{}{
"sid": userID,
result, err := a.AccessAPI("miniCode", false, map[string]interface{}{
"sid": strings.ToLower(userID),
"actId": actID,
})
if err == nil {
if utils.MustInterface2Int64(result["status"]) != 0 {
return "",fmt.Errorf(result["des"].(string))
}else {
return result["data"].(string),err
}
}
return url, err
}

View File

@@ -1,6 +1,7 @@
package mtunionapi
import (
"fmt"
"strings"
"testing"
@@ -27,11 +28,11 @@ func init() {
}
func TestGenerateLink(t *testing.T) {
_, err := api.GenerateLink(2, strings.ToLower("EFA9876238FC11EB9101525400C36BDA"))
result, err := api.GenerateLink(2, strings.ToLower("EFA9876238FC11EB9101525400C36BDA"))
if err != nil {
t.Fatal(err)
}
// t.Log(utils.Format4Output(result, false))
t.Log(utils.Format4Output(result, false))
}
func TestActivityList(t *testing.T) {
@@ -39,5 +40,9 @@ func TestActivityList(t *testing.T) {
if err != nil {
t.Fatal(err)
}
for _ , v := range result {
fmt.Println(utils.Str2Time(v.DateBound[:strings.LastIndex(v.DateBound, "至")-1]))
fmt.Println(utils.Str2Time(v.DateBound[strings.LastIndex(v.DateBound, "至")+4:]))
}
t.Log(utils.Format4Output(result, false))
}