frontRouter.go 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. //组织机构:organizational structure
  39. orgpcIndex xweb.Mapper `xweb:"/orgpc/"`
  40. orgpcPage xweb.Mapper `xweb:"/orgpc/(.*)"`
  41. }
  42. func init() {
  43. xweb.AddAction(&CommonRouter{})
  44. jy.InitBigVipService(public.Mysql)
  45. }
  46. func (this *CommonRouter) WxCommonPage(folder, loginSign, htmlPage string) error {
  47. if loginSign != "free" {
  48. openid, _ := this.GetSession("s_m_openid").(string)
  49. if openid != "" {
  50. ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false)
  51. if !ok {
  52. openid = ""
  53. }
  54. }
  55. if openid == "" {
  56. return this.Redirect("/swordfish/about")
  57. }
  58. }
  59. this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
  60. return this.Render(fmt.Sprintf("/frontRouter/wx/%s/%s/%s.html", folder, loginSign, htmlPage))
  61. }
  62. func (this *CommonRouter) PcCommonPage(folder, loginSign, htmlPage string) error {
  63. var shareid = this.GetString("id")
  64. if len(shareid) == 0 {
  65. shareid = "10"
  66. }
  67. this.T["shareid"] = se.EncodeString(shareid)
  68. if loginSign != "free" {
  69. if userid, _ := this.GetSession("userId").(string); userid == "" {
  70. var shareid = this.GetString("id")
  71. if len(shareid) == 0 {
  72. shareid = "10"
  73. }
  74. this.T["logid"] = config.Seoconfig["jysskzy"].(string)
  75. this.T["shareid"] = se.EncodeString(shareid)
  76. return this.Render("/pc/notin.html", &this.T)
  77. }
  78. }
  79. if folder == "collection" {
  80. this.T["logid"] = config.Seoconfig["collection"].(string)
  81. }
  82. return this.Render(fmt.Sprintf("/frontRouter/pc/%s/%s/%s.html", folder, loginSign, htmlPage))
  83. }
  84. //积分
  85. func (this *CommonRouter) IntegralIndex() error {
  86. return this.doIntegralPage()
  87. }
  88. func (this *CommonRouter) IntegralPage(htmlPage string) error {
  89. return this.doIntegralPage()
  90. }
  91. func (this *CommonRouter) doIntegralPage() error {
  92. userid, _ := this.GetSession("userId").(string)
  93. if userid == "" {
  94. return this.Redirect("/notin/page")
  95. }
  96. return this.Render(fmt.Sprintf("/frontRouter/pc/integral/sess/index.html"))
  97. }
  98. //文库
  99. func (this *CommonRouter) DocsIndex() error {
  100. return this.doDocsPage()
  101. }
  102. func (this *CommonRouter) DocsPage(htmlPage string) error {
  103. return this.doDocsPage()
  104. }
  105. func (this *CommonRouter) doDocsPage() error {
  106. userid, _ := this.GetSession("userId").(string)
  107. if userid == "" {
  108. return this.Redirect("/notin/page")
  109. }
  110. return this.Render(fmt.Sprintf("/frontRouter/pc/docs/sess/index.html"))
  111. }
  112. //线上课程
  113. func (this *CommonRouter) XspcIndex() error {
  114. return this.doXspcPage()
  115. }
  116. func (this *CommonRouter) XspcPage(htmlPage string) error {
  117. return this.doXspcPage()
  118. }
  119. func (this *CommonRouter) doXspcPage() error {
  120. userid, _ := this.GetSession("userId").(string)
  121. if userid == "" {
  122. return this.Redirect("/notin/page")
  123. }
  124. return this.Render(fmt.Sprintf("/frontRouter/pc/xspc/sess/index.html"))
  125. }
  126. //商机管理
  127. func (this *CommonRouter) EntpcIndex() error {
  128. return this.doEntpcPage()
  129. }
  130. func (this *CommonRouter) EntpcPage(htmlPage string) error {
  131. return this.doEntpcPage()
  132. }
  133. func (this *CommonRouter) doEntpcPage() error {
  134. userid, _ := this.GetSession("userId").(string)
  135. if userid == "" {
  136. return this.Redirect("/notin/page")
  137. }
  138. return this.Render(fmt.Sprintf("/frontRouter/pc/entpc/sess/index.html"))
  139. }
  140. //大会员
  141. func (this *CommonRouter) BigpcIndex() error {
  142. return this.doPcBigPage("", "")
  143. }
  144. func (this *CommonRouter) BigpcPage(htmlPage string) error {
  145. types := this.GetString("type")
  146. return this.doPcBigPage(htmlPage, types)
  147. }
  148. var bigVipFreePageReg = regexp.MustCompile(`set_.*|free|unit_portrayal|analysis_(search|result)|pro_follow_detail|client_portrayal`)
  149. func (this *CommonRouter) doPcBigPage(pageSign, types string) error {
  150. page := pageSign
  151. userid, _ := this.GetSession("userId").(string)
  152. //没有登录跳转登录页面
  153. if userid == "" {
  154. return this.Redirect("/notin/page")
  155. }
  156. //没有购买大会员跳转大会员介绍页
  157. if !strings.HasPrefix(pageSign, "svip/ent_ser_portrait") {
  158. for _, v := range strings.Split(pageSign, "/") {
  159. if v == "" || v == "desktop" {
  160. continue
  161. }
  162. pageSign = v
  163. break
  164. }
  165. bigBaseMsg := jy.GetBigVipUserBaseMsg(userid, public.Mysql, public.MQFW)
  166. if !bigVipFreePageReg.MatchString(pageSign) && pageSign != "index" {
  167. if bigBaseMsg.Status <= 0 && bigBaseMsg.Vip_BuySet.Upgrade != 1 {
  168. return this.Redirect("/big/page/index")
  169. }
  170. //大会员页面权限判断
  171. if pageSign != "" && !bigBaseMsg.CheckBigVipFrontPower(pageSign) {
  172. return this.Redirect("/big/page/index")
  173. }
  174. }
  175. //限制超级订阅用户不能进入购买页
  176. if page == "free/svip/buy" && bigBaseMsg.VipStatus > 0 && types != "upgrade" {
  177. return this.Redirect("/front/subscribe.html")
  178. }
  179. }
  180. return this.Render(fmt.Sprintf("/frontRouter/pc/page_big_pc/sess/index.html"))
  181. }
  182. //卡卷
  183. func (this *CommonRouter) CouponIndex() error {
  184. return this.doCouponPage()
  185. }
  186. func (this *CommonRouter) CouponPage(htmlPage string) error {
  187. return this.doCouponPage()
  188. }
  189. func (this *CommonRouter) doCouponPage() error {
  190. userid, _ := this.GetSession("userId").(string)
  191. if userid == "" {
  192. return this.Redirect("/notin/page")
  193. }
  194. return this.Render(fmt.Sprintf("/frontRouter/pc/coupon/sess/index.html"))
  195. }
  196. //卡卷活动中转页
  197. func (this *CommonRouter) CouponActive() error {
  198. var url = "/"
  199. if this.GetString("url") != "" {
  200. url = this.GetString("url")
  201. }
  202. userid, _ := this.GetSession("userId").(string)
  203. if userid == "" {
  204. this.T["ref"] = url
  205. var shareid = this.GetString("id")
  206. if len(shareid) == 0 {
  207. shareid = "10"
  208. }
  209. this.T["logid"] = config.Seoconfig["jysskzy"].(string)
  210. this.T["shareid"] = se.EncodeString(shareid)
  211. return this.Render("/pc/notin.html", &this.T)
  212. }
  213. return this.Redirect(url)
  214. }
  215. //活动留资
  216. func (this *CommonRouter) ActivityLeads(sign string) error {
  217. userid, _ := this.GetSession("userId").(string)
  218. if data, ok := mongodb.FindOne("saleLeads", map[string]interface{}{
  219. "userid": userid,
  220. "source": sign,
  221. }); data != nil && ok && len(*data) > 0 {
  222. return this.Redirect(config.ActiveConfig.Lottery)
  223. }
  224. return this.Redirect(fmt.Sprintf("/weixin/frontPage/bigmember/free/perfect_info?source=%v", sign))
  225. }
  226. //组织架构
  227. func (this *CommonRouter) OrgpcIndex() error {
  228. return this.doEntpcPage()
  229. }
  230. func (this *CommonRouter) OrgpcPage(htmlPage string) error {
  231. return this.doOrgpcPage()
  232. }
  233. func (this *CommonRouter) doOrgpcPage() error {
  234. userid, _ := this.GetSession("userId").(string)
  235. if userid == "" {
  236. return this.Redirect("/notin/page")
  237. }
  238. return this.Render(fmt.Sprintf("/frontRouter/pc/page_entbase_pc/sess/index.html"))
  239. }