package front import ( "fmt" "jfw/config" "jfw/public" "jfw/wx" "qfw/util/jy" "regexp" "strings" "github.com/go-xweb/xweb" ) //前端通用路由 type CommonRouter struct { *xweb.Action wxCommonPage xweb.Mapper `xweb:"/weixin/frontPage/(.*)/(sess|free)/(.*)"` //新的历时推送记录 pcCommonPage xweb.Mapper `xweb:"/swordfish/frontPage/(.*)/(sess|free)/(.*)"` //新的历时推送记录 //积分页面路由 integralIndex xweb.Mapper `xweb:"/swordfish/integral/"` integralPage xweb.Mapper `xweb:"/swordfish/integral/(.*)"` //文库页面路由 docsIndex xweb.Mapper `xweb:"/swordfish/docs/"` docsPage xweb.Mapper `xweb:"/swordfish/docs/(.*)"` //线上课程 xspcIndex xweb.Mapper `xweb:"/jyxspc/"` xspcPage xweb.Mapper `xweb:"/jyxspc/(.*)"` //卡卷页面路由 couponIndex xweb.Mapper `xweb:"/swordfish/coupon/"` couponPage xweb.Mapper `xweb:"/swordfish/coupon/(.*)"` couponActive xweb.Mapper `xweb:"/swordfish/CA"` //商机管理 entpcIndex xweb.Mapper `xweb:"/entpc/"` entpcPage xweb.Mapper `xweb:"/entpc/(.*)"` //pc大会员 bigpcIndex xweb.Mapper `xweb:"/swordfish/page_big_pc/"` bigpcPage xweb.Mapper `xweb:"/swordfish/page_big_pc/(.*)"` //双十一活动留资 activityLeads xweb.Mapper `xweb:"/weixin/leads/(.*)"` //组织机构:organizational structure orgpcIndex xweb.Mapper `xweb:"/orgpc/"` orgpcPage xweb.Mapper `xweb:"/orgpc/(.*)"` } func init() { xweb.AddAction(&CommonRouter{}) jy.InitBigVipService(public.Mysql) } func (this *CommonRouter) WxCommonPage(folder, loginSign, htmlPage string) error { if loginSign != "free" { openid, _ := this.GetSession("s_m_openid").(string) if openid != "" { ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false) if !ok { openid = "" } } if openid == "" { return this.Redirect("/swordfish/about") } } this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url()) return this.Render(fmt.Sprintf("/frontRouter/wx/%s/%s/%s.html", folder, loginSign, htmlPage)) } func (this *CommonRouter) PcCommonPage(folder, loginSign, htmlPage string) error { var shareid = this.GetString("id") if len(shareid) == 0 { shareid = "10" } this.T["shareid"] = se.EncodeString(shareid) if loginSign != "free" { if userid, _ := this.GetSession("userId").(string); userid == "" { var shareid = this.GetString("id") if len(shareid) == 0 { shareid = "10" } this.T["logid"] = config.Seoconfig["jysskzy"].(string) this.T["shareid"] = se.EncodeString(shareid) return this.Render("/pc/notin.html", &this.T) } } if folder == "collection" { this.T["logid"] = config.Seoconfig["collection"].(string) } return this.Render(fmt.Sprintf("/frontRouter/pc/%s/%s/%s.html", folder, loginSign, htmlPage)) } //积分 func (this *CommonRouter) IntegralIndex() error { return this.doIntegralPage() } func (this *CommonRouter) IntegralPage(htmlPage string) error { return this.doIntegralPage() } func (this *CommonRouter) doIntegralPage() error { userid, _ := this.GetSession("userId").(string) if userid == "" { return this.Redirect("/notin/page") } return this.Render(fmt.Sprintf("/frontRouter/pc/integral/sess/index.html")) } //文库 func (this *CommonRouter) DocsIndex() error { return this.doDocsPage() } func (this *CommonRouter) DocsPage(htmlPage string) error { return this.doDocsPage() } func (this *CommonRouter) doDocsPage() error { userid, _ := this.GetSession("userId").(string) if userid == "" { return this.Redirect("/notin/page") } return this.Render(fmt.Sprintf("/frontRouter/pc/docs/sess/index.html")) } //线上课程 func (this *CommonRouter) XspcIndex() error { return this.doXspcPage() } func (this *CommonRouter) XspcPage(htmlPage string) error { return this.doXspcPage() } func (this *CommonRouter) doXspcPage() error { userid, _ := this.GetSession("userId").(string) if userid == "" { return this.Redirect("/notin/page") } return this.Render(fmt.Sprintf("/frontRouter/pc/xspc/sess/index.html")) } //商机管理 func (this *CommonRouter) EntpcIndex() error { return this.doEntpcPage() } func (this *CommonRouter) EntpcPage(htmlPage string) error { return this.doEntpcPage() } func (this *CommonRouter) doEntpcPage() error { userid, _ := this.GetSession("userId").(string) if userid == "" { return this.Redirect("/notin/page") } return this.Render(fmt.Sprintf("/frontRouter/pc/entpc/sess/index.html")) } //大会员 func (this *CommonRouter) BigpcIndex() error { return this.doPcBigPage("", "") } func (this *CommonRouter) BigpcPage(htmlPage string) error { types := this.GetString("type") return this.doPcBigPage(htmlPage, types) } var bigVipFreePageReg = regexp.MustCompile(`set_.*|free|unit_portrayal|analysis_(search|result)|pro_follow_detail|client_portrayal`) func (this *CommonRouter) doPcBigPage(pageSign, types string) error { page := pageSign userid, _ := this.GetSession("userId").(string) //没有登录跳转登录页面 if userid == "" { return this.Redirect("/notin/page") } //没有购买大会员跳转大会员介绍页 if !strings.HasPrefix(pageSign, "svip/ent_ser_portrait") { for _, v := range strings.Split(pageSign, "/") { if v == "" || v == "desktop" { continue } pageSign = v break } bigBaseMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW) if !bigVipFreePageReg.MatchString(pageSign) && pageSign != "index" { if bigBaseMsg.Status <= 0 && bigBaseMsg.Vip_BuySet.Upgrade != 1 { return this.Redirect("/big/page/index") } //大会员页面权限判断 if pageSign != "" && !bigBaseMsg.CheckBigVipFrontPower(pageSign) { return this.Redirect("/big/page/index") } } //限制超级订阅用户不能进入购买页 if page == "free/svip/buy" && bigBaseMsg.VipStatus > 0 && types != "upgrade" { return this.Redirect("/front/subscribe.html") } } return this.Render(fmt.Sprintf("/frontRouter/pc/page_big_pc/sess/index.html")) } //卡卷 func (this *CommonRouter) CouponIndex() error { return this.doCouponPage() } func (this *CommonRouter) CouponPage(htmlPage string) error { return this.doCouponPage() } func (this *CommonRouter) doCouponPage() error { userid, _ := this.GetSession("userId").(string) if userid == "" { return this.Redirect("/notin/page") } return this.Render(fmt.Sprintf("/frontRouter/pc/coupon/sess/index.html")) } //卡卷活动中转页 func (this *CommonRouter) CouponActive() error { var url = "/" if this.GetString("url") != "" { url = this.GetString("url") } userid, _ := this.GetSession("userId").(string) if userid == "" { this.T["ref"] = url var shareid = this.GetString("id") if len(shareid) == 0 { shareid = "10" } this.T["logid"] = config.Seoconfig["jysskzy"].(string) this.T["shareid"] = se.EncodeString(shareid) return this.Render("/pc/notin.html", &this.T) } return this.Redirect(url) } //活动留资 func (this *CommonRouter) ActivityLeads(sign string) error { userid, _ := this.GetSession("userId").(string) if data, ok := mongodb.FindOne("saleLeads", map[string]interface{}{ "userid": userid, "source": sign, }); data != nil && ok && len(*data) > 0 { return this.Redirect(config.ActiveConfig.Lottery) } return this.Redirect(fmt.Sprintf("/weixin/frontPage/bigmember/free/perfect_info?source=%v", sign)) } //组织架构 func (this *CommonRouter) OrgpcIndex() error { return this.doEntpcPage() } func (this *CommonRouter) OrgpcPage(htmlPage string) error { return this.doOrgpcPage() } func (this *CommonRouter) doOrgpcPage() error { userid, _ := this.GetSession("userId").(string) if userid == "" { return this.Redirect("/notin/page") } return this.Render(fmt.Sprintf("/frontRouter/pc/page_entbase_pc/sess/index.html")) }