张金坤 9 سال پیش
والد
کامیت
5f93562252

+ 2 - 2
core/src/qfw/coreutil/weixinrpc.go

@@ -112,8 +112,8 @@ func GetShareQR(url uint32) string {
 }
 
 //根据mediaid下载图片
-func WxDownloadImg(mediaid string) string {
-	var ret string
+func WxDownloadImg(mediaid string) []string {
+	var ret []string
 	util.Try(func() {
 		client, err := rpc.DialHTTP("tcp", rpcserver)
 		defer client.Close()

+ 1 - 0
core/src/qfw/search/search.go

@@ -13,6 +13,7 @@ type Search struct {
 	sim               xweb.Mapper `xweb:"POST /search/sim"`                          //即时搜索
 	searchEntSer      xweb.Mapper `xweb:"/searchEntSer/(.*)"`                        //获取企业的服务列表
 	entCommunity      xweb.Mapper `xweb:"/front/entCommunity.html"`
+	wxMingpian        xweb.Mapper `xweb:"/wx/search/enterprise/mingpian"` //获取名片
 }
 
 func init() {

+ 32 - 1
core/src/qfw/search/searchService.go

@@ -8,8 +8,10 @@ import (
 	"gopkg.in/mgo.v2/bson"
 	"html/template"
 	"log"
+	"qfw/coreutil"
 	"qfw/front"
 	. "qfw/member"
+	"qfw/mobile"
 	. "qfw/util"
 	"qfw/util/consts"
 	"qfw/util/credit"
@@ -35,7 +37,8 @@ type EntInfo struct {
 func (search *Search) EntCommunity() error {
 	ismobile := strings.Index(search.Header("User-Agent"), "Mobile")
 	if ismobile > -1 {
-		search.Render("/member/incmobile/index.html")
+		search.T["signature"] = mobile.GetSignature(search.Url())
+		search.Render("/member/incmobile/index.html", &search.T)
 		return nil
 	}
 	//新认证企业
@@ -763,3 +766,31 @@ func searhWebContententMp(querymap map[string]string, n *Search, reqType string,
 	pagination := front.MakePagination(1, 1, 1, querymap, "/wx/search/enterprise/"+reqType+"ent_%s.html")
 	return &res, &pagination, has
 }
+
+//获取名片名称
+func (s *Search) WxMingpian() error {
+	res := make(map[string]string)
+	res["name"] = ""
+	res["on"] = "y"
+	if s.GetSession("s_m_openid") != nil {
+		serverId := s.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 k, v := range names {
+				name := fmt.Sprint(v)
+				if mpian_reg.MatchString(name) {
+					res["name"] = name
+					break
+				}
+				if k == len(names)-1 {
+					res["name"] = name
+				}
+			}
+		}
+	}
+	s.ServeJson(&res)
+	return nil
+}

+ 0 - 2
core/src/qfw/search/wxsearch.go

@@ -10,8 +10,6 @@ import (
 
 type Wxsearch struct {
 	*xweb.Action
-	wxEnterprise        xweb.Mapper `xweb:"/wx/search/enterprise/index.html"`             //查询首页
-	wxMingpian          xweb.Mapper `xweb:"/wx/search/enterprise/mingpian"`               //获取名片
 	wxgetEnterpriseList xweb.Mapper `xweb:"/wx/search/enterprise/([^.]*)ent([^.]*).html"` //查询企业列表
 	wxsearchEntSer      xweb.Mapper `xweb:"/wx/searchEntSer/(.*)"`                        //获取企业的服务列表
 }

+ 0 - 31
core/src/qfw/search/wxsearchservice.go

@@ -7,10 +7,8 @@ import (
 	"github.com/go-xweb/xweb"
 	"html/template"
 	"log"
-	"qfw/coreutil"
 	"qfw/front"
 	. "qfw/member"
-	"qfw/mobile"
 	. "qfw/util"
 	"qfw/util/consts"
 	"qfw/util/elastic"
@@ -21,35 +19,6 @@ import (
 	"strings"
 )
 
-//微信企业查询首页
-func (s *Wxsearch) WxEnterprise() error {
-	s.T["signature"] = mobile.GetSignature(s.Url())
-	return s.Render("/member/incombile/index.html", &s.T)
-}
-
-//获取名片名称
-func (s *Wxsearch) WxMingpian() error {
-	res := make(map[string]string)
-	if s.GetSession("s_m_openid") != nil {
-		serverId := s.GetString("serverId")
-		picpath := coreutil.WxDownloadImg(serverId)
-		log.Println("picpath", picpath)
-		names := coreutil.CardRecognition(picpath)
-		for k, v := range names {
-			name := fmt.Sprint(v)
-			if mpian_reg.MatchString(name) {
-				res["name"] = name
-				break
-			}
-			if k == len(names)-1 {
-				res["name"] = name
-			}
-		}
-	}
-	s.ServeJson(&res)
-	return nil
-}
-
 //获取某个企业服务列表数据
 func (search *Wxsearch) WxsearchEntSer(id string) error {
 	if search.Method() == "POST" {

+ 19 - 7
weixin/src/qfw/weixin/rpc/downimg.go

@@ -5,19 +5,31 @@ import (
 	"log"
 	"os"
 	"qfw/util"
+	wutil "qfw/weixin/util"
 	wf "qfw/weixinconfig"
 	"time"
 )
 
-func (wxrpc *WeiXinRpc) DownloadMingpian(mediaid string, picpath *string) error {
-	*picpath = getSavePath()
-	err := wxrpc.wx.DownloadMediaToFile(mediaid, *picpath)
-	if err != nil {
-		log.Println("DownloadMingpian err", err.Error())
-		*picpath = ""
+func (wxrpc *WeiXinRpc) DownloadMingpian(mediaid string, ret *[]string) error {
+	p := []string{}
+	b := wutil.CheckLimit()
+	if b {
+		p = append(p, "n")
+		p = append(p, "")
 	} else {
-		log.Println("图片路径", *picpath)
+		picpath := getSavePath()
+		err := wxrpc.wx.DownloadMediaToFile(mediaid, picpath)
+		if err != nil {
+			log.Println("DownloadMingpian err", err.Error())
+			p = append(p, "y")
+			p = append(p, picpath)
+		} else {
+			p = append(p, "y")
+			p = append(p, picpath)
+			log.Println("图片路径", picpath)
+		}
 	}
+	*ret = p
 	return nil
 }