|
@@ -495,35 +495,38 @@ func wxsearhWebContententMp(querymap map[string]string, n *Wxsearch, reqType str
|
|
|
|
|
|
//获取名片名称
|
|
|
func (n *Wxsearch) WxMingpian() error {
|
|
|
- res := make(map[string]string)
|
|
|
- res["name"] = ""
|
|
|
- res["on"] = "y"
|
|
|
+ res := make(map[string]interface{})
|
|
|
+ names := []string{}
|
|
|
+ res["on"] = "y" //y正常,n调用频繁或超出调用次数
|
|
|
if n.GetSession("s_m_openid") != nil {
|
|
|
serverId := n.GetString("serverId")
|
|
|
ret := coreutil.WxDownloadImg(serverId)
|
|
|
if len(ret) > 1 {
|
|
|
log.Println("picpath", ret[1])
|
|
|
res["on"] = ret[0]
|
|
|
- names := coreutil.CardRecognition(ret[1])
|
|
|
- for _, v := range names {
|
|
|
+ code, tmps := coreutil.CardRecognition(ret[1])
|
|
|
+ if code == "434" {
|
|
|
+ res["on"] = "n"
|
|
|
+ }
|
|
|
+ tmps2 := []string{}
|
|
|
+ for _, v := range tmps {
|
|
|
name := fmt.Sprint(v)
|
|
|
if mpian_reg.MatchString(name) {
|
|
|
- res["name"] = name
|
|
|
- break
|
|
|
+ names = append(names, name)
|
|
|
+ } else {
|
|
|
+ tmps2 = append(tmps2, name)
|
|
|
}
|
|
|
}
|
|
|
- var name = ""
|
|
|
- if res["name"] == "" {
|
|
|
- for _, v := range names {
|
|
|
- tmp := fmt.Sprint(v)
|
|
|
- if len(name) < len(tmp) {
|
|
|
- name = tmp
|
|
|
+ if len(names) < 5 {
|
|
|
+ for _, v := range tmps2 {
|
|
|
+ if len(v) > 5 && len(names) < 6 {
|
|
|
+ names = append(names, v)
|
|
|
}
|
|
|
}
|
|
|
- res["name"] = name
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ res["names"] = names
|
|
|
n.ServeJson(&res)
|
|
|
return nil
|
|
|
}
|