frontRouter.go 8.6 KB

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