frontRouter.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. package front
  2. import (
  3. "app.yhyue.com/moapp/jypkg/public"
  4. "fmt"
  5. "jy/src/jfw/config"
  6. "jy/src/jfw/jyutil"
  7. "jy/src/jfw/wx"
  8. "net/url"
  9. "regexp"
  10. "strings"
  11. "app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
  12. //"strings"
  13. "app.yhyue.com/moapp/jybase/go-xweb/xweb"
  14. )
  15. //前端通用路由
  16. type CommonRouter struct {
  17. *xweb.Action
  18. wxCommonPage xweb.Mapper `xweb:"/weixin/frontPage/(.*)/(sess|free)/(.*)"` //新的历时推送记录
  19. pcCommonPage xweb.Mapper `xweb:"/swordfish/frontPage/(.*)/(sess|free)/(.*)"` //新的历时推送记录
  20. //积分页面路由
  21. integralIndex xweb.Mapper `xweb:"/swordfish/integral/"`
  22. integralPage xweb.Mapper `xweb:"/swordfish/integral/(.*)"`
  23. //文库页面路由
  24. docsIndex xweb.Mapper `xweb:"/swordfish/docs/"`
  25. docsPage xweb.Mapper `xweb:"/swordfish/docs/(.*)"`
  26. //线上课程
  27. xspcIndex xweb.Mapper `xweb:"/jyxspc/"`
  28. xspcPage xweb.Mapper `xweb:"/jyxspc/(.*)"`
  29. //卡卷页面路由
  30. couponIndex xweb.Mapper `xweb:"/swordfish/coupon/"`
  31. couponPage xweb.Mapper `xweb:"/swordfish/coupon/(.*)"`
  32. couponActive xweb.Mapper `xweb:"/swordfish/CA"`
  33. //商机管理
  34. entpcIndex xweb.Mapper `xweb:"/entpc/"`
  35. entpcPage xweb.Mapper `xweb:"/entpc/(.*)"`
  36. //pc大会员
  37. bigpcIndex xweb.Mapper `xweb:"/swordfish/page_big_pc/"`
  38. bigpcPage xweb.Mapper `xweb:"/swordfish/page_big_pc/(.*)"`
  39. //双十一活动留资
  40. activityLeads xweb.Mapper `xweb:"/weixin/leads/(.*)"`
  41. //组织机构:organizational structure
  42. orgpcIndex xweb.Mapper `xweb:"/orgpc/"`
  43. orgpcPage xweb.Mapper `xweb:"/orgpc/(.*)"`
  44. //pcweb
  45. webIndex xweb.Mapper `xweb:"/swordfish/page_web_pc/"`
  46. webPcPage xweb.Mapper `xweb:"/swordfish/page_web_pc/(.*)"`
  47. //socialweb
  48. socialIndex xweb.Mapper `xweb:"/swordfish/page_knowledge_base/"`
  49. socialPcPage xweb.Mapper `xweb:"/swordfish/page_knowledge_base/(.*)"`
  50. //微信端企业订阅设置
  51. toSetEntPushSetPage xweb.Mapper `xweb:"/front/entniche/toSetEntPushSetPage"` //订阅收费推送设置
  52. }
  53. func init() {
  54. xweb.AddAction(&CommonRouter{})
  55. jy.InitBigVipService(public.Mysql)
  56. }
  57. func (this *CommonRouter) WxCommonPage(folder, loginSign, htmlPage string) error {
  58. if loginSign != "free" {
  59. openid, _ := this.GetSession("s_m_openid").(string)
  60. if openid == "" || (openid != "" && !CheckUserIsSubscribe(openid)) {
  61. stateKey := this.GetString("state")
  62. if stateKey == "" { //公众号回调
  63. return this.Redirect(fmt.Sprintf(config.Wxoauth, url.QueryEscape(this.Site()+this.Url()), "wx"), 302)
  64. }
  65. openid = jyutil.Getopenid(this.GetString("code"))
  66. if ok, _, _ := FindUserAndCreateSess(openid, this.Session(), "wx", false, true); !ok {
  67. return this.Redirect("/swordfish/about")
  68. }
  69. }
  70. if !CheckUserIsSubscribe(openid) {
  71. return this.Redirect("/swordfish/about")
  72. }
  73. }
  74. this.T["signature"] = wx.SignJSSDK(this.Site() + this.Url())
  75. return this.Render(fmt.Sprintf("/frontRouter/wx/%s/%s/%s.html", folder, loginSign, htmlPage))
  76. }
  77. func (this *CommonRouter) PcCommonPage(folder, loginSign, htmlPage string) error {
  78. var shareid = this.GetString("id")
  79. if len(shareid) == 0 {
  80. shareid = "10"
  81. }
  82. this.T["shareid"] = se.EncodeString(shareid)
  83. if loginSign != "free" {
  84. if userid, _ := this.GetSession("userId").(string); userid == "" {
  85. var shareid = this.GetString("id")
  86. if len(shareid) == 0 {
  87. shareid = "10"
  88. }
  89. this.T["logid"] = config.Seoconfig["jysskzy"].(string)
  90. this.T["shareid"] = se.EncodeString(shareid)
  91. return this.Render("/pc/notin.html", &this.T)
  92. }
  93. }
  94. if folder == "collection" {
  95. this.T["logid"] = config.Seoconfig["collection"].(string)
  96. }
  97. return this.Render(fmt.Sprintf("/frontRouter/pc/%s/%s/%s.html", folder, loginSign, htmlPage))
  98. }
  99. // WebIndex 前端vue页面公共路由
  100. func (this *CommonRouter) WebIndex() error {
  101. return this.Render(fmt.Sprintf("/micro/web-pc/index.html"))
  102. }
  103. // WebPcPage 前端vue页面公共路由
  104. func (this *CommonRouter) WebPcPage(page string) error {
  105. return this.Render(fmt.Sprintf("/micro/web-pc/index.html"))
  106. }
  107. // SocialIndex 前端vue页面公共路由
  108. func (this *CommonRouter) SocialIndex() error {
  109. return this.Render(fmt.Sprintf("/micro/social-pc/index.html"))
  110. }
  111. // SocialPcPage 前端vue页面公共路由
  112. func (this *CommonRouter) SocialPcPage(page string) error {
  113. return this.Render(fmt.Sprintf("/micro/social-pc/index.html"))
  114. }
  115. // 积分
  116. func (this *CommonRouter) IntegralIndex() error {
  117. return this.doIntegralPage()
  118. }
  119. func (this *CommonRouter) IntegralPage(htmlPage string) error {
  120. return this.doIntegralPage()
  121. }
  122. func (this *CommonRouter) doIntegralPage() error {
  123. userid, _ := this.GetSession("userId").(string)
  124. if userid == "" {
  125. return this.Redirect("/notin/page")
  126. }
  127. return this.Render(fmt.Sprintf("/frontRouter/pc/integral/sess/index.html"))
  128. }
  129. // 文库
  130. func (this *CommonRouter) DocsIndex() error {
  131. return this.doDocsPage()
  132. }
  133. func (this *CommonRouter) DocsPage(htmlPage string) error {
  134. return this.doDocsPage()
  135. }
  136. func (this *CommonRouter) doDocsPage() error {
  137. //userid, _ := this.GetSession("userId").(string)
  138. //if userid == "" {
  139. // return this.Redirect("/notin/page")
  140. //}
  141. return this.Render(fmt.Sprintf("/frontRouter/pc/docs/sess/index.html"))
  142. }
  143. // XspcIndex 线上课程
  144. func (this *CommonRouter) XspcIndex() error {
  145. return this.doXspcPage()
  146. }
  147. func (this *CommonRouter) XspcPage(htmlPage string) error {
  148. return this.doXspcPage()
  149. }
  150. func (this *CommonRouter) doXspcPage() error {
  151. //userid, _ := this.GetSession("userId").(string)
  152. //if userid == "" {
  153. // return this.Redirect("/notin/page")
  154. //}
  155. return this.Render(fmt.Sprintf("/frontRouter/pc/xspc/sess/index.html"))
  156. }
  157. // 商机管理
  158. func (this *CommonRouter) EntpcIndex() error {
  159. return this.doEntpcPage()
  160. }
  161. func (this *CommonRouter) EntpcPage(htmlPage string) error {
  162. return this.doEntpcPage()
  163. }
  164. func (this *CommonRouter) doEntpcPage() error {
  165. //P325 采购单位搜索调整,未登录用户也能访问采购单位画像
  166. ///entpc/unit_portrayal/天津银行股份有限公司
  167. userid, _ := this.GetSession("userId").(string)
  168. if userid == "" {
  169. return this.Redirect("/notin/page")
  170. }
  171. return this.Render(fmt.Sprintf("/frontRouter/pc/entpc/sess/index.html"))
  172. }
  173. // 大会员
  174. func (this *CommonRouter) BigpcIndex() error {
  175. return this.doPcBigPage("", "")
  176. }
  177. func (this *CommonRouter) BigpcPage(htmlPage string) error {
  178. types := this.GetString("type")
  179. return this.doPcBigPage(htmlPage, types)
  180. }
  181. var bigVipFreePageReg = regexp.MustCompile(`set_.*|free|unit_portrayal|analysis_(search|result)|pro_follow_detail|client_portrayal`)
  182. // 工作桌面需求 不需要判断用户权限
  183. func (this *CommonRouter) doPcBigPage(pageSign, types string) error {
  184. //page := pageSign
  185. userid, _ := this.GetSession("userId").(string)
  186. //没有登录跳转登录页面(采购单位画像除外)
  187. if !strings.Contains(pageSign, "unit_portrayal") &&
  188. !strings.Contains(pageSign, "ent_portrait") && userid == "" {
  189. return this.Redirect("/notin/page")
  190. }
  191. return this.Render(fmt.Sprintf("/frontRouter/pc/page_big_pc/sess/index.html"))
  192. }
  193. // 卡卷
  194. func (this *CommonRouter) CouponIndex() error {
  195. return this.doCouponPage()
  196. }
  197. func (this *CommonRouter) CouponPage(htmlPage string) error {
  198. return this.doCouponPage()
  199. }
  200. func (this *CommonRouter) doCouponPage() error {
  201. userid, _ := this.GetSession("userId").(string)
  202. if userid == "" {
  203. return this.Redirect("/notin/page")
  204. }
  205. return this.Render(fmt.Sprintf("/frontRouter/pc/coupon/sess/index.html"))
  206. }
  207. // 卡卷活动中转页
  208. func (this *CommonRouter) CouponActive() error {
  209. var url = "/"
  210. if this.GetString("url") != "" {
  211. url = this.GetString("url")
  212. }
  213. userid, _ := this.GetSession("userId").(string)
  214. if userid == "" {
  215. this.T["ref"] = url
  216. var shareid = this.GetString("id")
  217. if len(shareid) == 0 {
  218. shareid = "10"
  219. }
  220. this.T["logid"] = config.Seoconfig["jysskzy"].(string)
  221. this.T["shareid"] = se.EncodeString(shareid)
  222. return this.Render("/pc/notin.html", &this.T)
  223. }
  224. return this.Redirect(url)
  225. }
  226. // 活动留资
  227. func (this *CommonRouter) ActivityLeads(sign string) error {
  228. userid, _ := this.GetSession("userId").(string)
  229. if data, ok := mongodb.FindOne("saleLeads", map[string]interface{}{
  230. "userid": userid,
  231. "source": sign,
  232. }); data != nil && ok && len(*data) > 0 {
  233. return this.Redirect(config.ActiveConfig.Lottery)
  234. }
  235. return this.Redirect(fmt.Sprintf("/weixin/frontPage/bigmember/free/perfect_info?source=%v", sign))
  236. }
  237. // 组织架构
  238. func (this *CommonRouter) OrgpcIndex() error {
  239. return this.doEntpcPage()
  240. }
  241. func (this *CommonRouter) OrgpcPage(htmlPage string) error {
  242. return this.doOrgpcPage()
  243. }
  244. func (this *CommonRouter) doOrgpcPage() error {
  245. return this.Render(fmt.Sprintf("/frontRouter/pc/page_entbase_pc/sess/index.html"))
  246. }
  247. // ToSetEntPushSetPage 推送设置
  248. func (this *CommonRouter) ToSetEntPushSetPage() {
  249. this.Render("/weixin/entniche/entniche_seniorset.html")
  250. }