ProcessQuestionPic中处理京东返回不正常图片地址的问题

This commit is contained in:
gazebo
2019-11-29 15:29:25 +08:00
parent 581b544864
commit b582b55493
3 changed files with 40 additions and 5 deletions

View File

@@ -10,7 +10,8 @@ import (
)
const (
AfsPicPrefix = "http://img10.360buyimg.com/o2o"
AfsPicPrefix = "http://img10.360buyimg.com/o2o"
AfsPicPrefixHttps = "https://img10.360buyimg.com/o2o"
)
const (
@@ -675,11 +676,19 @@ func (a *API) AfsSubmit(OrderID, pin, questionTypeCode, questionDesc, questionPi
}
func ProcessQuestionPic(questionPic string) (outQuestionPic string) {
const httpsPrefix = "https:"
if questionPic != "" {
picList := strings.Split(questionPic, ",")
picList2 := make([]string, len(picList))
for index, pic := range picList {
picList2[index] = AfsPicPrefix + "/" + pic
var picList2 []string
for _, pic := range picList {
baseURL := AfsPicPrefix
pic2 := strings.ReplaceAll(pic, httpsPrefix, "")
if pic2 != pic {
baseURL = AfsPicPrefixHttps
}
if pic2 = utils.TrimBlankChar(pic2); pic2 != "" {
picList2 = append(picList2, utils.GenerateGetURL(baseURL, pic2, nil))
}
}
outQuestionPic = strings.Join(picList2, ",")
}