frontRouter.go 6.1 KB

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