bidDetail.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package controller
  2. import (
  3. "app.yhyue.com/moapp/jybase/encrypt"
  4. "fmt"
  5. "github.com/gogf/gf/v2/frame/g"
  6. "github.com/gogf/gf/v2/net/ghttp"
  7. "github.com/gogf/gf/v2/util/gconv"
  8. "jyseo/internal/service"
  9. "jyseo/utility"
  10. "strings"
  11. )
  12. func DetailHandler(r *ghttp.Request) {
  13. var (
  14. bidId string
  15. stype = r.Get("stype").String()
  16. anyObj = r.Get("any").String()
  17. )
  18. index := strings.Index(anyObj, ".html")
  19. if index < 0 {
  20. r.Response.RedirectTo(fmt.Sprintf("/front/notFind?t=%d", service.DecodeErr), 302)
  21. }
  22. bidId = anyObj[:index]
  23. sids := encrypt.CommonDecodeArticle(stype, bidId)
  24. if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") {
  25. r.Response.RedirectTo(fmt.Sprintf("/front/notFind?t=%d", service.DecodeErr), 302)
  26. return
  27. }
  28. //白名单
  29. var isWhiteIp = r.Header.Get("ipWhite") == "1"
  30. bidData := service.GetBidInfo(sids[0], stype, isWhiteIp)
  31. if bidData == nil || len(bidData) <= 0 {
  32. r.Response.RedirectTo(fmt.Sprintf("/front/notFind?t=%d", service.QueryErr), 302)
  33. return
  34. }
  35. infoAttribute, _ := bidData["infoattribute"].(string)
  36. g.Log().Info(r.GetCtx(), "infoAttribute:", infoAttribute)
  37. g.Log().Info(r.GetCtx(), "r.UserAgent():", r.UserAgent(), "-----", strings.Contains(r.UserAgent(), "miniProgram"))
  38. //小程序阳光采购 未登录详情
  39. if infoAttribute == "zc_cgxx" && strings.Contains(r.UserAgent(), "miniProgram") {
  40. service.HtmlRender.Render(r, "detail-mini.html", g.Map{
  41. "bidId": bidId,
  42. "stype": stype,
  43. })
  44. return
  45. }
  46. //最新招投标
  47. newBidInfoList := service.GetNewBidInfo(sids[0], strings.Join(gconv.Strings(bidData["s_subscopeclass"]), ","), gconv.String(bidData["area"]), gconv.String(bidData["city"]))
  48. //招投标攻略
  49. industryInfoList := service.GetBiddingStrategy(10)
  50. if isLogin := utility.JySessionLoginEd(r); isLogin { //登录后渲染乾坤潜入页面
  51. service.HtmlRender.Render(r, "detail_login.html", g.Map{
  52. "isLogin": isLogin,
  53. "bidData": bidData,
  54. "newBidInfoList": newBidInfoList,
  55. "industryInfoList": industryInfoList,
  56. "tdk": service.JySeoTdk.GetBidDetailTdk(r.Context(), bidData),
  57. })
  58. return
  59. } else {
  60. // p397 未登录不能查看拟建项目
  61. canRead := true
  62. if !isWhiteIp && (bidData["subtype"] == "采购意向" || bidData["subtype"] == "拟建") { //未登录拟建 采购意向 遮罩
  63. canRead = false
  64. }
  65. service.HtmlRender.Render(r, "detail.html",
  66. g.Map{
  67. "isLogin": isLogin,
  68. "bidData": bidData,
  69. "newBidInfoList": newBidInfoList,
  70. "industryInfoList": industryInfoList,
  71. "canRead": canRead,
  72. "tdk": service.JySeoTdk.GetBidDetailTdk(r.Context(), bidData),
  73. })
  74. }
  75. }