|
@@ -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)
|
|
|
|
+}
|