frontRouter.go 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. package front
  2. import (
  3. "fmt"
  4. "jfw/config"
  5. "jfw/public"
  6. "jfw/wx"
  7. "qfw/util/jy"
  8. "regexp"
  9. "strings"
  10. "github.com/go-xweb/xweb"
  11. )
  12. //前端通用路由
  13. type CommonRouter struct {
  14. *xweb.Action
  15. wxCommonPage xweb.Mapper `xweb:"/weixin/frontPage/(.*)/(sess|free)/(.*)"` //新的历时推送记录
  16. pcCommonPage xweb.Mapper `xweb:"/swordfish/frontPage/(.*)/(sess|free)/(.*)"` //新的历时推送记录
  17. //积分页面路由
  18. integralIndex xweb.Mapper `xweb:"/swordfish/integral/"`
  19. integralPage xweb.Mapper `xweb:"/swordfish/integral/(.*)"`
  20. //文库页面路由
  21. docsIndex xweb.Mapper `xweb:"/swordfish/docs/"`
  22. docsPage xweb.Mapper `xweb:"/swordfish/docs/(.*)"`
  23. //线上课程
  24. xspcIndex xweb.Mapper `xweb:"/jyxspc/"`
  25. xspcPage xweb.Mapper `xweb:"/jyxspc/(.*)"`
  26. //卡卷页面路由
  27. couponIndex xweb.Mapper `xweb:"/swordfish/coupon/"`
  28. couponPage xweb.Mapper `xweb:"/swordfish/coupon/(.*)"`
  29. couponActive xweb.Mapper `xweb:"/swordfish/CA"`
  30. //商机管理
  31. entpcIndex xweb.Mapper `xweb:"/entpc/"`
  32. entpcPage xweb.Mapper `xweb:"/entpc/(.*)"`
  33. //pc大会员
  34. bigpcIndex xweb.Mapper `xweb:"/swordfish/page_big_pc/"`
  35. bigpcPage xweb.Mapper `xweb:"/swordfish/page_big_pc/(.*)"`
  36. //双十一活动留资
  37. activityLeads xweb.Mapper `xweb:"/weixin/leads/(.*)"`
  38. }
  39. func init() {
  40. xweb.AddAction(&CommonRouter{})
  41. jy.InitBigVipService(public.Mysql)
  42. }
  43. func (this *CommonRouter) WxCommonPage(folder, loginSign, htmlPage string) error {
  44. if loginSign != "free" {
  45. openid, _ := this.GetSession("s_m_openid").(string)
  46. if openid != "" {
  47. ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false)
  48. if !ok {
  49. openid = ""
  50. }
  51. }
  52. if openid == "" {
  53. return this.Redirect("/swordfish/about")
  54. }
  55. }
  56. this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
  57. return this.Render(fmt.Sprintf("/frontRouter/wx/%s/%s/%s.html", folder, loginSign, htmlPage))
  58. }
  59. func (this *CommonRouter) PcCommonPage(folder, loginSign, htmlPage string) error {
  60. var shareid = this.GetString("id")
  61. if len(shareid) == 0 {
  62. shareid = "10"
  63. }
  64. this.T["shareid"] = se.EncodeString(shareid)
  65. if loginSign != "free" {
  66. if userid, _ := this.GetSession("userId").(string); userid == "" {
  67. var shareid = this.GetString("id")
  68. if len(shareid) == 0 {
  69. shareid = "10"
  70. }
  71. this.T["logid"] = config.Seoconfig["jysskzy"].(string)
  72. this.T["shareid"] = se.EncodeString(shareid)
  73. return this.Render("/pc/notin.html", &this.T)
  74. }
  75. }
  76. if folder == "collection" {
  77. this.T["logid"] = config.Seoconfig["collection"].(string)
  78. }
  79. return this.Render(fmt.Sprintf("/frontRouter/pc/%s/%s/%s.html", folder, loginSign, htmlPage))
  80. }
  81. //积分
  82. func (this *CommonRouter) IntegralIndex() error {
  83. return this.doIntegralPage()
  84. }
  85. func (this *CommonRouter) IntegralPage(htmlPage string) error {
  86. return this.doIntegralPage()
  87. }
  88. func (this *CommonRouter) doIntegralPage() error {
  89. userid, _ := this.GetSession("userId").(string)
  90. if userid == "" {
  91. return this.Redirect("/notin/page")
  92. }
  93. return this.Render(fmt.Sprintf("/frontRouter/pc/integral/sess/index.html"))
  94. }
  95. //文库
  96. func (this *CommonRouter) DocsIndex() error {
  97. return this.doDocsPage()
  98. }
  99. func (this *CommonRouter) DocsPage(htmlPage string) error {
  100. return this.doDocsPage()
  101. }
  102. func (this *CommonRouter) doDocsPage() error {
  103. userid, _ := this.GetSession("userId").(string)
  104. if userid == "" {
  105. return this.Redirect("/notin/page")
  106. }
  107. return this.Render(fmt.Sprintf("/frontRouter/pc/docs/sess/index.html"))
  108. }
  109. //线上课程
  110. func (this *CommonRouter) XspcIndex() error {
  111. return this.doXspcPage()
  112. }
  113. func (this *CommonRouter) XspcPage(htmlPage string) error {
  114. return this.doXspcPage()
  115. }
  116. func (this *CommonRouter) doXspcPage() error {
  117. userid, _ := this.GetSession("userId").(string)
  118. if userid == "" {
  119. return this.Redirect("/notin/page")
  120. }
  121. return this.Render(fmt.Sprintf("/frontRouter/pc/xspc/sess/index.html"))
  122. }
  123. //商机管理
  124. func (this *CommonRouter) EntpcIndex() error {
  125. return this.doEntpcPage()
  126. }
  127. func (this *CommonRouter) EntpcPage(htmlPage string) error {
  128. return this.doEntpcPage()
  129. }
  130. func (this *CommonRouter) doEntpcPage() error {
  131. userid, _ := this.GetSession("userId").(string)
  132. if userid == "" {
  133. return this.Redirect("/notin/page")
  134. }
  135. return this.Render(fmt.Sprintf("/frontRouter/pc/entpc/sess/index.html"))
  136. }
  137. //大会员
  138. func (this *CommonRouter) BigpcIndex() error {
  139. return this.doPcBigPage("", "")
  140. }
  141. func (this *CommonRouter) BigpcPage(htmlPage string) error {
  142. types := this.GetString("type")
  143. return this.doPcBigPage(htmlPage, types)
  144. }
  145. var bigVipFreePageReg = regexp.MustCompile(`set_.*|free|unit_portrayal|analysis_(search|result)|pro_follow_detail|client_portrayal`)
  146. func (this *CommonRouter) doPcBigPage(pageSign, types string) error {
  147. page := pageSign
  148. userid, _ := this.GetSession("userId").(string)
  149. //没有登录跳转登录页面
  150. if userid == "" {
  151. return this.Redirect("/notin/page")
  152. }
  153. //没有购买大会员跳转大会员介绍页
  154. if !strings.HasPrefix(pageSign, "svip/ent_ser_portrait") {
  155. for _, v := range strings.Split(pageSign, "/") {
  156. if v == "" || v == "desktop" {
  157. continue
  158. }
  159. pageSign = v
  160. break
  161. }
  162. bigBaseMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW)
  163. if !bigVipFreePageReg.MatchString(pageSign) && pageSign != "index" {
  164. if bigBaseMsg.Status <= 0 && bigBaseMsg.Vip_BuySet.Upgrade != 1 {
  165. return this.Redirect("/big/page/index")
  166. }
  167. //大会员页面权限判断
  168. if pageSign != "" && !bigBaseMsg.CheckBigVipFrontPower(pageSign) {
  169. return this.Redirect("/big/page/index")
  170. }
  171. }
  172. //限制超级订阅用户不能进入购买页
  173. if page == "free/svip/buy" && bigBaseMsg.VipStatus > 0 && types != "upgrade" {
  174. return this.Redirect("/front/subscribe.html")
  175. }
  176. }
  177. return this.Render(fmt.Sprintf("/frontRouter/pc/page_big_pc/sess/index.html"))
  178. }
  179. //卡卷
  180. func (this *CommonRouter) CouponIndex() error {
  181. return this.doCouponPage()
  182. }
  183. func (this *CommonRouter) CouponPage(htmlPage string) error {
  184. return this.doCouponPage()
  185. }
  186. func (this *CommonRouter) doCouponPage() error {
  187. userid, _ := this.GetSession("userId").(string)
  188. if userid == "" {
  189. return this.Redirect("/notin/page")
  190. }
  191. return this.Render(fmt.Sprintf("/frontRouter/pc/coupon/sess/index.html"))
  192. }
  193. //卡卷活动中转页
  194. func (this *CommonRouter) CouponActive() error {
  195. var url = "/"
  196. if this.GetString("url") != "" {
  197. url = this.GetString("url")
  198. }
  199. userid, _ := this.GetSession("userId").(string)
  200. if userid == "" {
  201. this.T["ref"] = url
  202. var shareid = this.GetString("id")
  203. if len(shareid) == 0 {
  204. shareid = "10"
  205. }
  206. this.T["logid"] = config.Seoconfig["jysskzy"].(string)
  207. this.T["shareid"] = se.EncodeString(shareid)
  208. return this.Render("/pc/notin.html", &this.T)
  209. }
  210. return this.Redirect(url)
  211. }
  212. //活动留资
  213. func (this *CommonRouter) ActivityLeads(sign string) error {
  214. userid, _ := this.GetSession("userId").(string)
  215. if data, ok := mongodb.FindOne("saleLeads", map[string]interface{}{
  216. "userid": userid,
  217. "source": sign,
  218. }); data != nil && ok && len(*data) > 0 {
  219. return this.Redirect(config.ActiveConfig.Lottery)
  220. }
  221. return this.Redirect(fmt.Sprintf("/weixin/frontPage/bigmember/free/perfect_info?source=%v", sign))
  222. }