package front import ( "fmt" "jfw/config" "jfw/public" "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/(.*)"` } 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") } } 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) // return this.Redirect("/notin/page") } } 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 { return this.doPcBigPage(htmlPage) } var bigVipFreePageReg = regexp.MustCompile(`set_*|free_*|unit_portrayal|analysis_(search|result)`) func (this *CommonRouter) doPcBigPage(pageSign string) error { userid, _ := this.GetSession("userId").(string) //没有登录跳转登录页面 if userid == "" { return this.Redirect("/notin/page") } //没有购买大会员跳转大会员介绍页 if !strings.HasPrefix(pageSign, "svip/ent_ser_portrait") { if array := strings.Split(pageSign, "/"); len(array) > 0 { pageSign = array[0] } if !bigVipFreePageReg.MatchString(pageSign) { bigBaseMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW) 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") } } } 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) }