wangchuanjin 7 年之前
父节点
当前提交
2950e8548b

+ 195 - 131
src/jfw/front/follow.go

@@ -62,7 +62,6 @@ func (m *Follow) CheckFPStatus() error {
 //
 func (m *Follow) CheckCStatus() error {
 	defer util.Catch()
-	//s_id := util.DecodeArticleId(m.GetString("s_id"))[0]
 	pname := m.GetString("pcname")
 	pcode := m.GetString("pccode")
 	userId, _ := m.GetSession("userId").(string)
@@ -71,11 +70,6 @@ func (m *Follow) CheckCStatus() error {
 	followid := ""
 	if userId != "" {
 		flag, followid = MFollow(userId, pname, pcode, "", openId)
-		//		follows, _ := mongodb.FindOneByField("follow_project", `{"s_id":"`+s_id+`","s_openid":"`+s_openid.(string)+`"}`, `{"_id":1}`)
-		//		if follows != nil && *follows != nil && len(*follows) > 0 {
-		//			flag = "t"
-		//			followid = strings.Split(fmt.Sprintf("%s", (*follows)["_id"]), `"`)[1]
-		//		}
 	}
 	m.ServeJson(map[string]interface{}{
 		"flag":     flag,
@@ -134,11 +128,6 @@ func (m *Follow) Fwsave() {
 		data["i_source"] = 3
 		data["toptype"] = "招标"
 		fields := `"title","comeintime","bidopentime","projectcode","type","href","publishtime","area","subtype","toptype"`
-		//		res, ok := mongodb.FindById("bidding", s_id, fields)
-		//		if ok && (res == nil || *res == nil || len(*res) == 0) {
-		//			res, ok = mongodb.FindById("bidding_back", s_id, fields)
-		//		}
-
 		res := elastic.GetByIdField("bidding", "bidding", s_id, fields)
 		if res != nil {
 			projectcode, _ := (*res)["projectcode"].(string)
@@ -150,7 +139,6 @@ func (m *Follow) Fwsave() {
 			data["s_url"] = (*res)["href"]
 			data["s_province"] = (*res)["area"]
 			data["l_comeintime"] = (*res)["comeintime"]
-			//data["l_lastpushtime"] = (*res)["comeintime"]
 			if data["l_bidopentime"] == "" {
 				data["l_bidopentime"] = (*res)["bidopentime"]
 			}
@@ -201,14 +189,8 @@ func (m *Follow) ShareFW(tp string) error {
 	projectcode := ""
 	m.T["projectname"] = projectname
 	m.T["projectcode"] = projectcode
-	//userId, _ := m.GetSession("userId").(string)
 	m.T["fg"] = "F"
 	fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
-	//	data, ok := mongodb.FindById("bidding", id, fields)
-	//	if ok && (data == nil || *data == nil || len(*data) == 0) {
-	//		data, _ = mongodb.FindById("bidding_back", id, fields)
-	//	}
-
 	data := elastic.GetByIdField("bidding", "bidding", id, fields)
 	bidopentime := (*data)["bidopentime"]
 	if bidopentime != nil {
@@ -291,8 +273,6 @@ func (m *Follow) PcEntAllNotice() error {
 	entname := m.GetString("entname")
 	data := map[string]interface{}{}
 	if entname != "" {
-		//fields := `{"projectname":1,"bidamount":1,"title":1,"publishtime":1,"subtype":1,"toptype":1,"href":1}`
-		//res, ok := tools.MQFW.Find("bidding", `{"winner":"`+entname+`"}`, `{"publishtime":-1}`, fields, false, -1, -1)
 		ok := true
 		fields := `"_id","projectname","bidamount","title","publishtime","subtype","toptype","href"`
 		res := elastic.GetPage("bidding", "bidding", `{"TERM_winner":"`+entname+`"}`, `{"publishtime":-1}`, fields, 0, 100)
@@ -312,80 +292,124 @@ func (m *Follow) PcEntAllNotice() error {
 //未关注项目
 func (m *Follow) Photo(tp string) error {
 	defer util.Catch()
+	followid := ""
 	tpm := strings.Split(tp, "__")
-	id := util.DecodeArticleId2ByCheck(tpm[0])[0]
 	projectname := tpm[1]
 	projectcode := tpm[2]
-	m.T["projectname"] = projectname
-	m.T["projectcode"] = projectcode
 	userId, _ := m.GetSession("userId").(string)
 	openid := m.GetSession("s_m_openid").(string)
-	if userId != "" {
-		flag, followid := MFollow(userId, projectname, projectcode, "", openid)
-		if flag && len(followid) > 0 {
-			m.Redirect("/follow/set/list/" + followid)
-			return nil
+	if userId != "" && openid != "" {
+		_, followid = MFollow(userId, projectname, projectcode, "", openid)
+	}
+	//已关注
+	if followid != "" {
+		id := util.DecodeArticleId2ByCheck(followid)[0]
+		fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
+		data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
+			"_id":      bson.ObjectIdHex(id),
+			"s_openid": m.GetSession("s_m_openid").(string),
+		}, fields)
+		m.T["isDel"] = false
+		if ok && (data == nil || len(*data) == 0) {
+			data, ok = mongodb.FindOneByField("follow_project_back", `{"s_followid":"`+id+`"}`, fields)
+			m.T["isDel"] = true
 		}
-	}
-	m.T["fg"] = "F"
-	fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
-	//	data, ok := mongodb.FindById("bidding", id, fields)
-	//	if ok && (data == nil || *data == nil || len(*data) == 0) {
-	//		data, _ = mongodb.FindById("bidding_back", id, fields)
-	//	}
-	data := elastic.GetByIdField("bidding", "bidding", id, fields)
-	mySelf := make(bson.M)
-	if data != nil && len(*data) > 0 {
-		mySelf["s_projectname"] = projectname
-		mySelf["s_title"] = (*data)["title"]
-		mySelf["type"] = (*data)["type"]
-		mySelf["subtype"] = (*data)["subtype"]
-		mySelf["toptype"] = (*data)["toptype"]
-		mySelf["area"] = (*data)["area"]
-		mySelf["s_projectcode"] = projectcode
-		mySelf["s_url"] = (*data)["href"]
-		mySelf["s_id"] = id
-		mySelf["s_eid"] = util.EncodeArticleId2ByCheck(id)
-		mySelf["l_publishtime"] = (*data)["publishtime"]
-		////////////////////////
-		bidopentime := (*data)["bidopentime"]
-		if bidopentime != nil {
-			m.T["bidopentime"] = util.FormatDateWithObj(&bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(bidopentime), 0).Weekday().String())
-			m.T["l_bidopentime"] = bidopentime
+		if !ok || data == nil || len(*data) == 0 {
+			return m.Render("_error.html")
+		}
+		sid, _ := (*data)["s_id"].(string)
+		m.T["_id"] = followid
+		m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
+		m.T["source"] = (*data)["i_source"]
+		m.T["projectname"] = (*data)["s_projectname"]
+		m.T["projectcode"] = (*data)["s_projectcode"]
+		m.T["url"] = (*data)["s_url"]
+		m.T["remind"] = (*data)["i_remind"]
+		m.T["type"] = (*data)["s_type"]
+		if sid != "" {
+			info := elastic.GetByIdField("bidding", "bidding", sid, `"type","subtype","toptype"`)
+			info_ok := info != nil && len(*info) != 0
+			if info_ok {
+				m.T["subtype"] = (*info)["subtype"]
+				m.T["toptype"] = (*info)["toptype"]
+				m.T["type"] = (*data)["type"]
+			}
+		}
+		m.T["relationinfo"] = (*data)["a_relationinfo"]
+		m.T["a_visited"] = (*data)["a_visited"]
+		m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
+		m.T["a_lastpushids"] = (*data)["a_lastpushids"]
+		l_bidopentime := (*data)["l_bidopentime"]
+		if l_bidopentime != nil {
+			m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
+			m.T["l_bidopentime"] = l_bidopentime
 		}
-		if remindtime := (*data)["remindtime"]; remindtime != nil {
-			m.T["remindtime"] = util.FormatDateWithObj(&remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(remindtime), 0).Weekday().String())
-			m.T["l_remindtime"] = remindtime
-		} else if bidopentime != nil {
-			date := time.Unix(util.Int64All(bidopentime), 0).AddDate(0, 0, -1)
+		if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil {
+			m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
+			m.T["l_remindtime"] = l_remindtime
+		} else if l_bidopentime != nil {
+			date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
 			m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
 			m.T["l_remindtime"] = date.Unix()
 		}
-		m.T["type"] = (*data)["type"]
-		m.T["subtype"] = (*data)["subtype"]
-		m.T["toptype"] = (*data)["toptype"]
-		m.T["a_lastpushids"] = (*data)["a_lastpushids"]
-	}
-	if len(projectname) > 0 || len(projectcode) > 0 {
-		res, _ := tools.FollowPush(&rpc.FollowPush{
-			ProjectName: projectname,
-			ProjectCode: projectcode,
-			InfoId:      id,
-			FollowId:    "",
-			OpenId:      m.GetSession("s_m_openid").(string),
-			Flag:        1,
-		})
-		if len(res) > 0 || len(mySelf) > 0 {
-			m.T["fg"] = "T"
-			for _, v := range res {
-				(*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
+	} else { //未关注
+		id := util.DecodeArticleId2ByCheck(tpm[0])[0]
+		m.T["projectname"] = projectname
+		m.T["projectcode"] = projectcode
+		fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
+		data := elastic.GetByIdField("bidding", "bidding", id, fields)
+		mySelf := make(bson.M)
+		if data != nil && len(*data) > 0 {
+			mySelf["s_projectname"] = projectname
+			mySelf["s_title"] = (*data)["title"]
+			mySelf["type"] = (*data)["type"]
+			mySelf["subtype"] = (*data)["subtype"]
+			mySelf["toptype"] = (*data)["toptype"]
+			mySelf["area"] = (*data)["area"]
+			mySelf["s_projectcode"] = projectcode
+			mySelf["s_url"] = (*data)["href"]
+			mySelf["s_id"] = id
+			mySelf["s_eid"] = util.EncodeArticleId2ByCheck(id)
+			mySelf["l_publishtime"] = (*data)["publishtime"]
+			////////////////////////
+			bidopentime := (*data)["bidopentime"]
+			if bidopentime != nil {
+				m.T["bidopentime"] = util.FormatDateWithObj(&bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(bidopentime), 0).Weekday().String())
+				m.T["l_bidopentime"] = bidopentime
 			}
-			m.T["data"] = res
-			m.T["id"] = util.EncodeArticleId2ByCheck(id)
-			m.T["mySelf"] = mySelf
+			if remindtime := (*data)["remindtime"]; remindtime != nil {
+				m.T["remindtime"] = util.FormatDateWithObj(&remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(remindtime), 0).Weekday().String())
+				m.T["l_remindtime"] = remindtime
+			} else if bidopentime != nil {
+				date := time.Unix(util.Int64All(bidopentime), 0).AddDate(0, 0, -1)
+				m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
+				m.T["l_remindtime"] = date.Unix()
+			}
+			m.T["type"] = (*data)["type"]
+			m.T["subtype"] = (*data)["subtype"]
+			m.T["toptype"] = (*data)["toptype"]
+			m.T["a_lastpushids"] = (*data)["a_lastpushids"]
 		}
+		if len(projectname) > 0 || len(projectcode) > 0 {
+			res, _ := tools.FollowPush(&rpc.FollowPush{
+				ProjectName: projectname,
+				ProjectCode: projectcode,
+				InfoId:      id,
+				FollowId:    "",
+				OpenId:      m.GetSession("s_m_openid").(string),
+				Flag:        1,
+			})
+			if len(res) > 0 || len(mySelf) > 0 {
+				for _, v := range res {
+					(*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
+				}
+				m.T["data"] = res
+				m.T["id"] = util.EncodeArticleId2ByCheck(id)
+				m.T["mySelf"] = mySelf
+			}
+		}
+		m.T["source"] = 1
 	}
-	m.T["source"] = 1
 	myopenid, _ := m.Session().Get("s_m_openid").(string)
 	m.T["openid"] = se.EncodeString(myopenid)
 	mynickname, _ := m.Session().Get("s_nickname").(string)
@@ -578,14 +602,6 @@ func (m *Follow) Addsave() error {
 			}
 			//匹配
 			r := elastic.GetPage("bidding", "bidding", `{"TERM_projectname":"`+projectname+`"}`, `{"comeintime":-1}`, `"_id","title","comeintime","bidopentime","projectcode","type","href","publishtime","subtype","toptype","area"`, -1, -1)
-			//			r, ok := mongodb.Find("bidding", bson.M{
-			//				"projectname": projectname,
-			//			}, `{"comeintime":-1}`, `{"title":1,"comeintime":1,"bidopentime":1,"projectcode":1,"type":1,"href":1,"publishtime":1,"subtype":1,"toptype":1,"area":1}`, false, 0, -1)
-			//			if r == nil || *r == nil || len(*r) == 0 {
-			//				r, _ = mongodb.Find("bidding_back", bson.M{
-			//					"projectname": projectname,
-			//				}, `{"comeintime":-1}`, `{"title":1,"comeintime":1,"bidopentime":1,"projectcode":1,"type":1,"href":1,"publishtime":1,"subtype":1,"toptype":1,"area":1}`, false, 0, -1)
-			//			}
 			var matchingFlag = r != nil && len(*r) != 0
 			var projectcode, sid string
 			if matchingFlag {
@@ -645,64 +661,112 @@ func (m *Follow) Addsave() error {
 }
 func (m *Follow) Set(tp, id string) error {
 	defer util.Catch()
+	isDel := false
 	id = util.DecodeArticleId2ByCheck(id)[0]
 	fields := `{"s_id":1,"i_source":1,"s_projectname":1,"s_projectcode":1,"s_url":1,"i_remind":1,"s_type":1,"l_bidopentime":1,"l_remindtime":1,"a_relationinfo":1,"a_visited":1,"l_lastpushtime":1,"a_lastpushids":1}`
 	data, ok := mongodb.FindOneByField("follow_project", map[string]interface{}{
 		"_id":      bson.ObjectIdHex(id),
 		"s_openid": m.GetSession("s_m_openid").(string),
 	}, fields)
-	m.T["isDel"] = false
 	if ok && (data == nil || len(*data) == 0) {
 		data, ok = mongodb.FindOneByField("follow_project_back", `{"s_followid":"`+id+`"}`, fields)
-		m.T["isDel"] = true
+		isDel = true
 	}
 	if !ok || data == nil || len(*data) == 0 {
 		return m.Render("_error.html")
 	}
 	sid, _ := (*data)["s_id"].(string)
-	m.T["_id"] = util.EncodeArticleId2ByCheck(id)
-	m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
-	m.T["source"] = (*data)["i_source"]
-	m.T["projectname"] = (*data)["s_projectname"]
-	m.T["projectcode"] = (*data)["s_projectcode"]
-	m.T["url"] = (*data)["s_url"]
-	m.T["remind"] = (*data)["i_remind"]
-	m.T["type"] = (*data)["s_type"]
-	if sid != "" {
-		info := elastic.GetByIdField("bidding", "bidding", sid, `"type","subtype","toptype"`)
-		info_ok := info != nil && len(*info) != 0
-		//		info, info_ok := mongodb.FindOneByField("bidding", map[string]interface{}{
-		//			"_id": bson.ObjectIdHex(sid),
-		//		}, `{"type":1,"subtype":1,"toptype":1}`)
-		//		if info_ok && (info == nil || *info == nil || len(*info) == 0) {
-		//			info, info_ok = mongodb.FindOneByField("bidding_back", map[string]interface{}{
-		//				"_id": bson.ObjectIdHex(sid),
-		//			}, `{"type":1,"subtype":1,"toptype":1}`)
-		//		}
-		if info_ok {
-			m.T["subtype"] = (*info)["subtype"]
-			m.T["toptype"] = (*info)["toptype"]
+	projectname, _ := (*data)["s_projectname"].(string)
+	projectcode, _ := (*data)["s_projectcode"].(string)
+	if isDel {
+		fields := `"_id","title","comeintime","projectcode","projectname","bidopentime","projectcode","area","toptype","subtype","type","href","publishtime","area"`
+		data := elastic.GetByIdField("bidding", "bidding", sid, fields)
+		mySelf := make(bson.M)
+		if data != nil && len(*data) > 0 {
+			mySelf["s_projectname"] = projectname
+			mySelf["s_title"] = (*data)["title"]
+			mySelf["type"] = (*data)["type"]
+			mySelf["subtype"] = (*data)["subtype"]
+			mySelf["toptype"] = (*data)["toptype"]
+			mySelf["area"] = (*data)["area"]
+			mySelf["s_projectcode"] = projectcode
+			mySelf["s_url"] = (*data)["href"]
+			mySelf["s_id"] = sid
+			mySelf["s_eid"] = util.EncodeArticleId2ByCheck(sid)
+			mySelf["l_publishtime"] = (*data)["publishtime"]
+			////////////////////////
+			bidopentime := (*data)["bidopentime"]
+			if bidopentime != nil {
+				m.T["bidopentime"] = util.FormatDateWithObj(&bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(bidopentime), 0).Weekday().String())
+				m.T["l_bidopentime"] = bidopentime
+			}
+			if remindtime := (*data)["remindtime"]; remindtime != nil {
+				m.T["remindtime"] = util.FormatDateWithObj(&remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(remindtime), 0).Weekday().String())
+				m.T["l_remindtime"] = remindtime
+			} else if bidopentime != nil {
+				date := time.Unix(util.Int64All(bidopentime), 0).AddDate(0, 0, -1)
+				m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
+				m.T["l_remindtime"] = date.Unix()
+			}
 			m.T["type"] = (*data)["type"]
+			m.T["subtype"] = (*data)["subtype"]
+			m.T["toptype"] = (*data)["toptype"]
+			m.T["a_lastpushids"] = (*data)["a_lastpushids"]
+		}
+		if len(projectname) > 0 || len(projectcode) > 0 {
+			res, _ := tools.FollowPush(&rpc.FollowPush{
+				ProjectName: projectname,
+				ProjectCode: projectcode,
+				InfoId:      sid,
+				FollowId:    "",
+				OpenId:      m.GetSession("s_m_openid").(string),
+				Flag:        1,
+			})
+			if len(res) > 0 || len(mySelf) > 0 {
+				for _, v := range res {
+					(*v)["s_eid"] = util.EncodeArticleId2ByCheck((*v)["s_id"].(string))
+				}
+				m.T["data"] = res
+				m.T["id"] = util.EncodeArticleId2ByCheck(sid)
+				m.T["mySelf"] = mySelf
+			}
+		}
+	} else {
+		m.T["_id"] = util.EncodeArticleId2ByCheck(id)
+		m.T["sid"] = util.EncodeArticleId2ByCheck(sid)
+		m.T["source"] = (*data)["i_source"]
+		m.T["url"] = (*data)["s_url"]
+		m.T["remind"] = (*data)["i_remind"]
+		m.T["type"] = (*data)["s_type"]
+		if sid != "" {
+			info := elastic.GetByIdField("bidding", "bidding", sid, `"type","subtype","toptype"`)
+			info_ok := info != nil && len(*info) != 0
+			if info_ok {
+				m.T["subtype"] = (*info)["subtype"]
+				m.T["toptype"] = (*info)["toptype"]
+				m.T["type"] = (*data)["type"]
+			}
+		}
+		m.T["relationinfo"] = (*data)["a_relationinfo"]
+		m.T["a_visited"] = (*data)["a_visited"]
+		m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
+		m.T["a_lastpushids"] = (*data)["a_lastpushids"]
+		l_bidopentime := (*data)["l_bidopentime"]
+		if l_bidopentime != nil {
+			m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
+			m.T["l_bidopentime"] = l_bidopentime
+		}
+		if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil {
+			m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
+			m.T["l_remindtime"] = l_remindtime
+		} else if l_bidopentime != nil {
+			date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
+			m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
+			m.T["l_remindtime"] = date.Unix()
 		}
 	}
-	m.T["relationinfo"] = (*data)["a_relationinfo"]
-	m.T["a_visited"] = (*data)["a_visited"]
-	m.T["l_lastpushtime"] = (*data)["l_lastpushtime"]
-	m.T["a_lastpushids"] = (*data)["a_lastpushids"]
-	l_bidopentime := (*data)["l_bidopentime"]
-	if l_bidopentime != nil {
-		m.T["bidopentime"] = util.FormatDateWithObj(&l_bidopentime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_bidopentime), 0).Weekday().String())
-		m.T["l_bidopentime"] = l_bidopentime
-	}
-	if l_remindtime := (*data)["l_remindtime"]; l_remindtime != nil {
-		m.T["remindtime"] = util.FormatDateWithObj(&l_remindtime, "2006年01月02日 15时") + " " + convertWeekday(time.Unix(util.Int64All(l_remindtime), 0).Weekday().String())
-		m.T["l_remindtime"] = l_remindtime
-	} else if l_bidopentime != nil {
-		date := time.Unix(util.Int64All(l_bidopentime), 0).AddDate(0, 0, -1)
-		m.T["remindtime"] = util.FormatDate(&date, "2006年01月02日 15时") + " " + convertWeekday(date.Weekday().String())
-		m.T["l_remindtime"] = date.Unix()
-	}
-	m.T["flag"] = true
+	m.T["projectname"] = projectname
+	m.T["projectcode"] = projectcode
 	myopenid, _ := m.Session().Get("s_m_openid").(string)
 	m.T["openid"] = se.EncodeString(myopenid)
 	mynickname, _ := m.Session().Get("s_nickname").(string)

+ 2 - 8
src/jfw/front/swordfish.go

@@ -1109,15 +1109,9 @@ func MFollow(userId, pname, pcode, title, openid string) (bool, string) {
 	if ok && follows != nil && len(*follows) > 0 {
 		for _, v := range *follows {
 			pc, _ := v["s_projectcode"].(string)
-			if pc != "" && pc == pcode {
+			pn, _ := v["s_projectname"].(string)
+			if (pc != "" && pc == pcode) || (pn != "" && pn == pname) {
 				followFlag = true
-			} else {
-				pn, _ := v["s_projectname"].(string)
-				if pn != "" && pn == pname {
-					followFlag = true
-				}
-			}
-			if followFlag {
 				followId = util.EncodeArticleId2ByCheck(util.BsonIdToSId(v["_id"]))
 				break
 			}

+ 1 - 1
src/web/staticres/js/common.js

@@ -15,7 +15,7 @@ var EasyAlert = {
 		if(typeof(css) != "undefined"){
 			$("#easyAlert").css(css);
 		}
-		$("#easyAlert").css({"left":"50%","margin-top":-($("#easyAlert").outerHeight()/2),"margin-left":-($("#easyAlert").outerWidth()/2)});
+		$("#easyAlert").css({"left":"50%","right":"50%","margin-top":-($("#easyAlert").outerHeight()/2),"margin-left":-($("#easyAlert").outerWidth()/2),"margin-right":-($("#easyAlert").outerWidth()/2)});
 	},
 	hide: function(){
 		$("#easyalert-mask").remove();

+ 2 - 0
src/web/staticres/js/wxEntsesearch.js

@@ -401,6 +401,7 @@ var EntSearch = {
         sessionStorage.entSearch_scopeCache = EntSearch.reqParam["scope"];
 		sessionStorage.entSearch_noDataCache = EntSearch.noDataCache;
 		sessionStorage.searchpageName = "entSearch";
+		sessionStorage.cancelFollowVersion = "1";
     },
 	clearSessionStorage: function(){
 		if(!sessionStorage){
@@ -415,6 +416,7 @@ var EntSearch = {
 		sessionStorage.removeItem("entSearch_scopeCache");
 		sessionStorage.removeItem("entSearch_scrollTop");
 		sessionStorage.removeItem("searchpageName");
+		sessionStorage.removeItem("cancelFollowVersion");
 	},
 	initDropload: function (hasNextPage,pgNum){
         //上拉分页

+ 53 - 115
src/web/templates/weixin/follow/set.html

@@ -20,9 +20,7 @@
 	initShare({{.T.signature}},{{.T.openid}},"","jy_extend");
 </script>
 <script type="text/javascript">
-var _id = {{.T._id}};
-var sid = {{.T.sid}};
-var url = {{.T.url}};
+var _id = "";
 var source = {{.T.source}};
 var remind = {{.T.remind}};
 var bidopentime = {{.T.bidopentime}};
@@ -31,58 +29,21 @@ var l_bidopentime = {{.T.l_bidopentime}};
 var l_remindtime = {{.T.l_remindtime}};
 var lastpushtime = {{.T.l_lastpushtime}};
 var lastpushids = {{.T.a_lastpushids}};
-var flag = {{.T.flag}};
 var relationinfo = {{.T.relationinfo}};
-var twoid = "";
-var oneid = "";
-var myflag = "F";
 var oldData = {bidopentime:bidopentime,remindtime:remindtime,remind:remind};
 if(sessionStorage&&sessionStorage.version=="0"){
 	sessionStorage.version="1";
 }
 var storage = window.localStorage;
 var hasNoFollowPopup = null;
-var noticeid = ""
 $(function(){
 	$(window).bind("pageshow", function(event){
 		if(event.originalEvent.persisted){
 			window.location.reload(true);
 		}
     });
+	isFollow();
 	$(".setpage").css("padding-top",$(".noticehead").outerHeight());
-	if(sid !=""){
-		noticeid = sid
-	}else{
-		noticeid = {{.T.id}}
-	}
-	if (_id != ""){
-		$.post("/follow/checkFPStatus",{s_id:_id},function(fd){
-			if (fd&&fd.flag=="f"){
-				$(".followcancel").html('<div id="followcancel">已取消</div>');	 
-				var disabledMask=$(".disabledMask")
-				if(disabledMask.size()==0){
-					$(".setpage").append('<div class="disabledMask"></div>')
-				}
-			}
-		})
-	}
-	var flags = storage.getItem("notice"+noticeid)
-	if (flags) {
-		var infoid_fid=flags.split("_")
-		//storage.removeItem("notice")
-		oneid = infoid_fid[0];
-		twoid = infoid_fid[1];
-		if ({{.T.id}}==oneid){
-			$.post("/follow/mylist",{id:twoid},function(r){
-				if (r.flag == "T"){
-					//window.location.href ="/follow/set/list/"+twoid;
-					$("#followsure").addClass("hidden");
-					$("#followcancel").removeClass("hidden");
-					myflag = r.flag
-				}
-			})
-		}
-	}
 	//$("#noticeCount").html("("+(relationinfo.length)+")");
 	new FastClick(document.body);
 	var easyPopup = new EasyPopup("easypopup");
@@ -100,30 +61,25 @@ $(function(){
 				return;
 			}
 		}
-		if (_id == "" && twoid != "" && myflag=="T"){
-			_id = twoid;
-		}else if(_id == ""){
-			hasNoFollowPopup.show();
-		}
-		if(_id == ""){
-			return;
-		}
-		if($(this).parent().hasClass("turn-on")){
-			remind = 0;
-			$(".time").removeClass("tipon");
-			$(this).attr("src","/images/wx/off.png");
-		}else{
-			remind = 1;
-			$(".time").addClass("tipon");
-			$(this).attr("src","/images/wx/on.gif");
-		}
-		$(this).parent().toggleClass("turn-on");
-		checkIsUpdate();
 		if (_id != ""){
-			opation();
+			if($(this).parent().hasClass("turn-on")){
+				remind = 0;
+				$(".time").removeClass("tipon");
+				$(this).attr("src","/images/wx/off.png");
+			}else{
+				remind = 1;
+				$(".time").addClass("tipon");
+				$(this).attr("src","/images/wx/on.gif");
+			}
+			$(this).parent().toggleClass("turn-on");
 		}
+		opation();
 	});
 	var opation = function(){
+		if(_id == ""){
+			hasNoFollowPopup.show();
+			return;
+		}
 		$.post("/follow/ajaxReq",{reqType:"followset",id:_id,remind:remind,bidopentime:l_bidopentime,remindtime:l_remindtime},function(r){
 			if(r.status != "y"){
 				EasyAlert.show("操作失败!");
@@ -139,11 +95,6 @@ $(function(){
 	});
 	$("#sure").click(function(){
 		easyPopup.hide();
-		if (_id == "" && twoid != "" && myflag=="T"){
-			_id = twoid;
-		}else if(_id == ""){
-			EasyAlert.show("取消失败!");
-		}
 		$.post("/follow/ajaxReq",{reqType:"cancel",id:_id},function(r){
 			if(r.status == "y"){
 				EasyAlert.show("已取消<br>关注");
@@ -433,16 +384,7 @@ $(function(){
 			}
 			l_bidopentime = date.getTime()+"";
 			l_bidopentime = l_bidopentime.substring(0,l_bidopentime.length - 3);
-			checkIsUpdate();
-			if (_id == "" && twoid != "" && myflag=="T"){
-				_id = twoid;
-			}else if(_id == ""){
-				hasNoFollowPopup.show();
-			}
-			if (_id != ""){
-				opation();
-			}
-			
+			opation();
 		}
     });
 	var remindtimeMinDate = null;
@@ -473,15 +415,7 @@ $(function(){
 			var arrayVal = inst.getArrayVal();
 			var date = new Date(arrayVal[0],arrayVal[1],arrayVal[2],arrayVal[3]);
 			afterRemindtimeSelect(date);
-			checkIsUpdate();
-			if (_id == "" && twoid != "" && myflag=="T"){
-				_id = twoid;
-			}else if(_id == ""){
-				hasNoFollowPopup.show();
-			}
-			if (_id != ""){
-				opation();
-			}
+			opation();
 		}
     });
 	$("#bidopentime").click(function(){
@@ -523,10 +457,9 @@ function beforeRedirect(obj,sid,link,isOld){
 		}
 		return;
 	}
-	var id = {{.T._id}};
 	$(obj).addClass("visited");
-	if(typeof(sid) != "undefined" && sid != null && sid != "" && typeof(id) != "undefined" && id != null && id != ""){
-		$.post("/follow/notice/visited",{id:id,sid:sid,type:1},function(r){
+	if(typeof(sid) != "undefined" && sid != null && sid != "" && _id != ""){
+		$.post("/follow/notice/visited",{id:_id,sid:sid,type:1},function(r){
 			if(isOld){
 				myRedirect({{Msg "seo" "ZBADDRESS"}},link,sid);
 			}else{
@@ -546,17 +479,6 @@ function afterRemindtimeSelect(date){
 	l_remindtime = date.getTime()+"";
 	l_remindtime = l_remindtime.substring(0,l_remindtime.length - 3);
 }
-function checkIsUpdate(){
-	if(!flag){
-		return true;
-	}
-	if(oldData.remindtime == $('#remindtime>.time').val() && oldData.bidopentime == $('#bidopentime>.time').val() && oldData.remind == remind){
-		$("#opation").addClass("disabled");
-		return false;
-	}
-	$("#opation").removeClass("disabled");
-	return true;
-}
 function pageJump(){
 	setTimeout(function(){
 		if(sessionStorage){
@@ -566,7 +488,11 @@ function pageJump(){
 				window.location.href = "/follow/list";
 			}else{
 				try{
-					WeixinJSBridge.call('closeWindow',{},function(e){});
+					if(sessionStorage.cancelFollowVersion=="1"){
+						history.go(-1);
+					}else{
+						WeixinJSBridge.call('closeWindow',{},function(e){});
+					}
 				}catch(e){
 					window.location.href = "/follow/list";
 				}
@@ -579,9 +505,8 @@ function pageJump(){
 function followSave(flag){
 	var projectname = {{.T.projectname}};
 	var nfid = {{.T.id}}
-	$.post("/follow/fwsave",{projectname:projectname,id:nfid,remind:remind,bidopentime:l_bidopentime,remindtime:l_remindtime,relationinfo:relationinfo},function(r){	
+	$.post("/follow/fwsave",{projectname:projectname,id:nfid,remind:remind,bidopentime:l_bidopentime,remindtime:l_remindtime},function(r){	
 		if(r.status == "y"){
-			storage.setItem("notice"+noticeid,r.infoId+"_"+r.followId)
 			if(flag == 1){
 				_id = r.followId;
 				hasNoFollowPopup.hide();
@@ -602,7 +527,6 @@ function followSave(flag){
 			EasyAlert.show("已关注此项目!");
 		}else{
 			EasyAlert.show("数据提交失败!");
-			$(".opation").removeClass("disabled");
 		}
 	});
 }
@@ -613,27 +537,41 @@ function myRedirect(zbadd,link,sid){
 	}
 	window.location.href=zbadd+"/visit/redirect?id="+sid+"&url="+escape(link);
 }
+//是否关注
+function isFollow(){
+	$.ajax({
+		type: "POST",
+		url: "/follow/checkCStatus",
+		data: {pcname: {{.T.projectname}},pccode: {{.T.projectcode}}},
+		async: false,
+		cache: false,
+		dataType: "json",
+		success: function(r){
+			_id = r.followid;
+		}
+	});
+	if(_id == ""){
+		$("#followsure").removeClass("hidden");
+		$("#followcancel").addClass("hidden");
+		return false;
+	}
+	$("#followcancel").removeClass("hidden");
+	$("#followsure").addClass("hidden");
+	return true;
+}
 </script>
 </head>
 <body class="setpage">
-	{{if .T.isDel}}<div class="disabledMask"></div>{{end}}
 	<div class="noticehead">
 		{{if .T.projectname}}
 			{{.T.projectname}}
 		{{else}}
 			{{.T.projectcode}}
 		{{end}}
-		{{if .T.flag}}
-			<div class="followcancel">
-				<div id="followcancel">取消关注</div>
-			</div>
-		{{end}}
-		{{if .T.fg}}
-			<div class="followcancel">
-				<div id="followsure">关注</div>
-				<div id="followcancel" class="hidden">取消关注</div>
-			</div>
-		{{end}}
+		<div class="followcancel">
+			<div id="followsure" class="hidden">关注</div>
+			<div id="followcancel" class="hidden">取消关注</div>
+		</div>
 	</div>
 	<ul>
 		<!--<li>{{.T.projectname}}</li>-->

+ 23 - 22
src/web/templates/weixin/wxinfocontent.html

@@ -637,7 +637,9 @@ var	shareimgflag = true;
 var area = {{.T.obj.area}}
 var subtype = {{.T.obj.subtype}}
 var toptype = {{.T.obj.toptype}}
-var storage = window.localStorage;
+var jumpFlag = false;
+var followId = "";
+var followFlag = false;
 //
 var upordown = function(type){
 	var id = {{.T.obj._id}};
@@ -837,6 +839,11 @@ function getParameter(param) {
 }
 
 $(function(){
+	$(window).bind("pageshow", function(event){
+		if(event.originalEvent.persisted){
+			isFollow();
+		}
+    });
 	$(".onekey").click(function(){
 		$('#myModal').bind("touchmove",function(e){
 			e.preventDefault();
@@ -980,13 +987,6 @@ $(function(){
 			$(".jyuseful").removeClass("hidden");
 		}
 	}
-	var jumpFlag = false;
-	var followId = ""
-	{{if .T.obj.followId}}
-		jumpFlag = true;
-		followId = {{.T.obj.followId}};
-	{{end}}
-	var followFlag = {{.T.obj.followFlag}};
 	var id = {{.T.obj._id}};
 	var title = {{.T.obj.title}};
 	var s_words = {{.T.keywords}};
@@ -1045,20 +1045,7 @@ $(function(){
 	$("#h_content").html(content);
 	$("#title").html(titleCopy);
 	//
-	if (id != ""){
-		$.post("/follow/checkCStatus",{pcname:projectname,pccode:projectcode},function(fd){
-			if (fd&&fd.flag==true){
-				followFlag = true;
-				jumpFlag = true;
-				followId = fd.followid
-				$(".follow").html('<i class="glyphicon yiguanzhu"></i>已关注');
-			}else{
-				followFlag = false;
-				jumpFlag = false;
-				$(".follow").html('<i class="glyphicon weiguanzhu"></i>关注项目');
-			}
-		})
-	}
+	isFollow();
 	$(".follow").click(function(){
 		if(followFlag){
 			$.post("/follow/ajaxReq",{reqType:"cancel",id:followId},function(r){
@@ -1169,6 +1156,20 @@ $(function(){
 function reward(){
 	window.location.href = "/front/pay/redirect?id={{.T.obj._id}}&source=m";
 }
+function isFollow(){
+	$.post("/follow/checkCStatus",{pcname:{{.T.obj.projectname}},pccode:{{.T.obj.projectcode}}},function(fd){
+		if (fd&&fd.flag==true){
+			followFlag = true;
+			jumpFlag = true;
+			followId = fd.followid
+			$(".follow").html('<i class="glyphicon yiguanzhu"></i>已关注');
+		}else{
+			followFlag = false;
+			jumpFlag = false;
+			$(".follow").html('<i class="glyphicon weiguanzhu"></i>关注项目');
+		}
+	});
+}
 </script>
 {{include "/common/baiducc.html"}}
 </body>