unknown 7 年之前
父節點
當前提交
29a1bd5842
共有 2 個文件被更改,包括 10 次插入14 次删除
  1. 8 12
      src/apiservice/oamanager/content.go
  2. 2 2
      src/web/templates/pc/article.html

+ 8 - 12
src/apiservice/oamanager/content.go

@@ -2,6 +2,7 @@ package oamanager
 
 import (
 	"net"
+	"net/http"
 	"qfw/util"
 	elastic "qfw/util/elastic"
 	"regexp"
@@ -26,15 +27,13 @@ func init() {
 	xweb.AddAction(&Content{})
 }
 func (c *Content) Article(id string) {
-	bm := false
+	defer util.Catch()
 	client := c.Header("User-Agent")
-	c.Request.Proto = GetIp(c)
-	addLog(c)
+	c.Request.Proto = GetIp(c.Request) //ip
+	addLog(c.Request)
+	bm := false //访问日志
 	bm = regex.MatchString(client)
-	//解密id
-	sid_openid := util.DecodeArticleId2ByCheck(id)[0]
-	//sid_openid = "596c129d5d11e1c74547e6ff"
-	//查询数据
+	sid_openid := util.DecodeArticleId2ByCheck(id)[0] //解密id
 	data := *elastic.GetByIdField("bidding", "bidding", sid_openid, `"detail","title","projectname","publishtime"`)
 	timeF := data["publishtime"].(float64)
 	time := time.Unix(int64(timeF), 0).Format("2006-01-02 15:04")
@@ -43,7 +42,6 @@ func (c *Content) Article(id string) {
 	c.T["title"] = data["title"]
 	c.T["detail"] = detail
 	c.T["projectname"] = data["projectname"]
-	//返回页面
 	if bm { //手机访问
 		c.Render("/app/app.html", &c.T)
 	} else { //pc端访问
@@ -51,8 +49,7 @@ func (c *Content) Article(id string) {
 	}
 }
 
-func addLog(c *Content) {
-	req := c.Request
+func addLog(req *http.Request) {
 	timeNow := time.Now()
 	agent := req.Header.Get("user-agent")
 	ref := req.Referer()
@@ -127,8 +124,7 @@ func GetBrowse(userbrowser string) string {
 }
 
 //获取请求ip
-func GetIp(c *Content) string {
-	req := c.Request
+func GetIp(req *http.Request) string {
 	ip_for := req.Header.Get("x-forwarded-for")
 	ip_client := req.Header.Get("http_client_ip")
 	ip_addr := req.Header.Get("Remote_addr")

+ 2 - 2
src/web/templates/pc/article.html

@@ -24,9 +24,9 @@ $(function(){
 		data:{	appid:"jyoaACJUW1BJXwECCA1fDwUj",
 				pagenum:1,
 				keyword:"广安建新建设工程有限责任公司",
-				timestamp:1519778778,
+				timestamp:1519797630,
 				action:"getdata",
-				signature:"7njN6QvJN53z9YsLmqgjzfv533A=",
+				signature:"okaWRbhotH6xY9jhvZnLyLoz5XQ=",
 			},
 		dataType: "json",
 		success: function(r){