Browse Source

feat:获取邀请用户信息

wangshan 3 năm trước cách đây
mục cha
commit
fac896ff76

+ 3 - 1
src/config.json

@@ -308,5 +308,7 @@
     "pcSessionFlag":true,
     "sessionTimeout":168,
     "pcSessionTimeout":168,
-    "shareRedisName":"other"
+    "shareRedisName":"other",
+    "wxWebdomain": "https://web-ws.jydev.jianyu360.com",
+    "wxOrgUrl": "/orgstructure/invpage.html"
 }

+ 1 - 0
src/jfw/front/front.go

@@ -167,6 +167,7 @@ func init() {
 	sewx = util.SimpleEncrypt{Key: "topnet"}
 	xweb.AddAction(&Front{})
 	xweb.AddAction(&Short{})
+	xweb.AddAction(&OrgStructure{})
 	urlMap = config.Sysconfig["redirect"].(map[string]interface{})
 	//userPoolSize = util.IntAllDef(config.Sysconfig["userPoolSize"], userPoolSize)
 	//up.user = make(map[string]*map[string]interface{})

+ 85 - 0
src/jfw/front/org_structure.go

@@ -0,0 +1,85 @@
+/**
+组织结构
+大会员&商机管理 企业组织架构优化
+2022-2-11
+王山
+**/
+
+package front
+
+import (
+	"fmt"
+	"jfw/config"
+	"jfw/jyutil"
+	"jfw/public"
+	"log"
+	"net/url"
+
+	"qfw/util"
+
+	"github.com/SKatiyar/qr"
+	"github.com/go-xweb/xweb"
+)
+
+type OrgStructure struct {
+	*xweb.Action
+	invitationQR   xweb.Mapper `xweb:"/orgstructure/invaction/(.*)"` //邀请加入组织的二维码 参数是部门id
+	invitationPage xweb.Mapper `xweb:"/orgstructure/invpage.html"`   //邀请页面
+}
+
+//
+func (this *OrgStructure) InvitationQR(depId string) {
+	wxWebdomain := util.ObjToString(config.Sysconfig["wxWebdomain"])
+	wxOrgUrl := util.ObjToString(config.Sysconfig["wxOrgUrl"])
+	from := this.GetString("from") //邀请人
+	if wxWebdomain != "" {
+		qrUrl := wxWebdomain + wxOrgUrl + "?from=" + from + "&depId=" + depId
+		log.Println("qrUrl:", qrUrl)
+		//生二维码
+		_r, err := qr.Encode(qrUrl, qr.L)
+		if err != nil {
+			log.Println(err.Error())
+		} else {
+			w := this.ResponseWriter
+			w.Header().Set("Cache-Control", "no-cache,no-store,must-revalidate")
+			w.Header().Set("Prama", "no-cache")
+			w.Header().Set("Expires", "0")
+			w.Header().Set("Content-Type", "image/png")
+			w.Write((*_r).PNG())
+		}
+	}
+}
+
+//
+func (this *OrgStructure) InvitationPage() error {
+	openId := util.ObjToString(this.Session().Get("s_m_openid"))
+	unionId := ""
+	isSubscribe := false //是否关注
+	if openId == "" {
+		if this.GetString("state") == "wx" {
+			//微信跳回来的
+			code := this.GetString("code")
+			if code != "" {
+				openId = jyutil.Getopenid(code)
+			}
+		} else {
+			if public.CheckWxBrowser(this.Request) {
+				//所有参数都不再使用,跳到微信验证用户
+				return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
+			}
+		}
+	}
+	if openId != "" {
+		isSubscribe = CheckUserIsSubscribe(openId)
+		if isSubscribe {
+			FindUserAndCreateSess(openId, this.Session(), "wx", false)
+		} else { //获取未关注用户uninoid
+			unionId = public.GetUnionid(openId)
+		}
+		this.T["openId"] = util.SE.EncodeString(openId)
+		this.T["unionId"] = util.SE.EncodeString(unionId)
+		this.T["isSubscribe"] = isSubscribe
+		this.T["phone"] = util.If(this.GetSession("phone") != nil, this.GetSession("phone"), "")
+	}
+	return this.Render("/weixin/orgStructure/invitationPage.html", &this.T)
+}

+ 1 - 0
src/web/templates/weixin/orgStructure/invitationPage.html

@@ -0,0 +1 @@
+你来了?