+SetJdCookie

This commit is contained in:
gazebo
2019-11-27 14:56:27 +08:00
parent 29d6571243
commit caac72c232
2 changed files with 11 additions and 3 deletions

View File

@@ -20,6 +20,9 @@ const (
getStoreURL = "https://daojia.jd.com"
accessStorePageCookieName = "shop.o2o.jd.com1"
accessStorePageCookieName2 = "lsp-store1.jddj.com"
accessStorePageCookieName3 = "josl-privilege1.jddj.com"
htmlResponeURL = "login-o2o.jddj.com/jpuser/"
)
type SkuPageImg struct {
@@ -234,6 +237,12 @@ const (
ResultKeyResult = "result"
)
func (a *API) SetJdCookie(cookieValue string) {
a.SetCookie(accessStorePageCookieName, cookieValue)
a.SetCookie(accessStorePageCookieName2, cookieValue)
a.SetCookie(accessStorePageCookieName3, cookieValue)
}
func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, isPost bool, resultKey string) (retVal interface{}, err error) {
if a.GetCookieCount() == 0 {
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
@@ -281,7 +290,7 @@ func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, is
if jsonResult1 == nil {
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
}
if jsonResult1[platformapi.KeyData] != nil {
if strings.Index(fullURL, htmlResponeURL) >= 0 && jsonResult1[platformapi.KeyData] != nil {
retVal = bodyStr
return platformapi.ErrLevelSuccess, nil
}