package controller import ( "app.yhyue.com/moapp/jybase/encrypt" "fmt" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/util/gconv" "jyseo/internal/service" "jyseo/utility" "strings" ) func DetailHandler(r *ghttp.Request) { var ( bidId string stype = r.Get("stype").String() anyObj = r.Get("any").String() ) index := strings.Index(anyObj, ".html") if index < 0 { r.Response.RedirectTo(fmt.Sprintf("/front/notFind?t=%d", service.DecodeErr), 302) } bidId = anyObj[:index] sids := encrypt.CommonDecodeArticle(stype, bidId) if len(sids) == 0 || (len(sids) > 0 && sids[0] == "") { r.Response.RedirectTo(fmt.Sprintf("/front/notFind?t=%d", service.DecodeErr), 302) return } //白名单 var isWhiteIp = r.Header.Get("ipWhite") == "1" bidData := service.GetBidInfo(sids[0], stype, isWhiteIp) if bidData == nil || len(bidData) <= 0 { r.Response.RedirectTo(fmt.Sprintf("/front/notFind?t=%d", service.QueryErr), 302) return } infoAttribute, _ := bidData["infoattribute"].(string) g.Log().Info(r.GetCtx(), "infoAttribute:", infoAttribute) g.Log().Info(r.GetCtx(), "r.UserAgent():", r.UserAgent(), "-----", strings.Contains(r.UserAgent(), "miniProgram")) //小程序阳光采购 未登录详情 if infoAttribute == "zc_cgxx" && strings.Contains(r.UserAgent(), "miniProgram") { service.HtmlRender.Render(r, "detail-mini.html", g.Map{ "bidId": bidId, "stype": stype, }) return } //最新招投标 newBidInfoList := service.GetNewBidInfo(sids[0], strings.Join(gconv.Strings(bidData["s_subscopeclass"]), ","), gconv.String(bidData["area"]), gconv.String(bidData["city"])) //招投标攻略 industryInfoList := service.GetBiddingStrategy(10) if isLogin := utility.JySessionLoginEd(r); isLogin { //登录后渲染乾坤潜入页面 service.HtmlRender.Render(r, "detail_login.html", g.Map{ "isLogin": isLogin, "bidData": bidData, "newBidInfoList": newBidInfoList, "industryInfoList": industryInfoList, "tdk": service.JySeoTdk.GetBidDetailTdk(r.Context(), bidData), }) return } else { // p397 未登录不能查看拟建项目 canRead := true if !isWhiteIp && (bidData["subtype"] == "采购意向" || bidData["subtype"] == "拟建") { //未登录拟建 采购意向 遮罩 canRead = false } service.HtmlRender.Render(r, "detail.html", g.Map{ "isLogin": isLogin, "bidData": bidData, "newBidInfoList": newBidInfoList, "industryInfoList": industryInfoList, "canRead": canRead, "tdk": service.JySeoTdk.GetBidDetailTdk(r.Context(), bidData), }) } }