Browse Source

通知收尾

li 7 years ago
parent
commit
3f8f7fdb2e
6 changed files with 470 additions and 3 deletions
  1. 91 0
      inform.html
  2. 22 3
      js/common.js
  3. 1 0
      js/head-staticize.js
  4. 1 0
      js/header.js
  5. 155 0
      js/inform.js
  6. 200 0
      js/informLeaveW.js

+ 91 - 0
inform.html

@ -0,0 +1,91 @@
1
<!DOCTYPE html>
2
<html>
3

4
	<head>
5
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
6
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
7
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
8
		<title>浏览问答-科袖网</title>
9
		<link rel="shortcut icon" type="image/x-icon" href="images/favicon.png" media="screen" />
10
		<link href="css/bootstrap.min.css" rel="stylesheet">
11
		<link type="text/css" href="css/common.css" rel="stylesheet">
12
			<link type="text/css" href="css/popup.css" rel="stylesheet">
13
		<link type="text/css" href="css/genindex.css" rel="stylesheet">
14
		<link type="text/css" href="css/leaveWord.css" rel="stylesheet">
15
		<style type="text/css">
16
			.creTime {
17
				position: absolute;
18
				right: 0;
19
				font-size: 14px;
20
				color: #888888;
21
			}
22
			
23
			#curAnswers .reWidth {
24
				width: 80%;
25
				padding-right: 0px;
26
			}
27
			
28
			.coninfotit {
29
				font-size: 18px;
30
				color: #666;
31
				padding-bottom: 10px;
32
				background-color: #fff;
33
			}
34
			
35
			.owner-tit span {
36
				color: #ff9900;
37
			}
38
			
39
			.js-load-more:before {
40
				content: "查看更多通知"
41
			}
42
		</style>
43
		<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
44

45
	</head>
46

47
	<body>
48
		<header id="header">
49
			<script src="js/header.js"></script>
50
		</header>
51
		<div id="container">
52
			<div class="containerCon">
53
				<div class="contentCon clearfix">
54
					<div class="leftconBox leftconBoxbg floatL">
55
						<div class="list-main scroll-view">
56
							<section class="list-hold">
57
								<div class="list-hold-list">
58
									<div class="coninfotit">全部通知</div>
59
									<ul class="myAllneeds partLine" id="curAnswers">
60
										
61
									</ul>
62
									<!--加载更多按钮-->
63
									<div class="js-load-more displayNone"></div>
64
								</div>
65
							</section>
66
						</div>
67
					</div>
68
					<div class="rightconBox floatR">
69
						<div class="conItem advertBox advertItem">
70
							<script src="js/adverts/ad_pap.js"></script>
71
						</div>
72

73
					</div>
74

75
				</div>
76
			</div>
77
		</div>
78
		<!--反馈建议-->
79
		<script type="text/javascript" src="js/correctBack.js"></script>
80
		<footer>
81
			<script type="text/javascript" src="js/footer.js"></script>
82
		</footer>
83
		<script type="text/javascript" src="js/jquery.cookie.js"></script>
84
		<script type="text/javascript" src="js/jquery.similar.msgbox.js"></script>
85
		<script type="text/javascript" src="js/common.js"></script>
86
		<script type="text/javascript" src="js/quickLogin.js"></script>
87
		<script type="text/javascript" src="js/informLeaveW.js"></script>
88
		<script type="text/javascript" src="js/inform.js"></script>
89
	</body>
90

91
</html>

+ 22 - 3
js/common.js

@ -202,6 +202,7 @@ function loginStatus() {
202 202
					$(".portrait-p").attr("src", "/images/default-photo.jpg");
203 203
				});
204 204
			unReadedCount(userid);
205
			unInformCount(userid)
205 206
		}
206 207
		$(".portrait-p").on("click",function(){
207 208
			location.href="userInforShow.html?professorId="+userid;
@ -257,16 +258,34 @@ function unReadedCount(id){//查询指定用户的未读消息数量
257 258
			console.log(data)
258 259
			if(data.success){
259 260
				if(data.data!=0){
260
					$(".mymessage .badge").text(data.data);
261
					$(".mymessage").eq(1).find(".badge").text(data.data);
261 262
				}else{
262
					$(".mymessage .badge").text("");
263
					$(".mymessage").eq(1).find(".badge").text("");
264
				}
265
			}
266
			
267
		}
268
	});
269
}
270
function unInformCount(id){//查询指定用户的未读消息数量
271
	$.ajax({
272
		type:"get",
273
		url:"/ajax/notify/idx",
274
		async:true,
275
		data:{"id":id},
276
		success:function(data){
277
			console.log(data)
278
			if(data.success){
279
				if(data.unRead!=0){
280
					$(".mymessage").eq(0).find(".badge").text(data.data);
281
				}else{
282
					$(".mymessage").eq(0).find(".badge").text("");
263 283
				}
264 284
			}
265 285
			
266 286
		}
267 287
	});
268 288
}
269

270 289
//转换格式
271 290
function changeTime(dealtime) {
272 291
	var s = dealtime;

+ 1 - 0
js/head-staticize.js

@ -40,6 +40,7 @@ var headerHtml = '';
40 40
					           ' </div>' + 
41 41
						'</div>' +
42 42
						'<ul class="headnavbtn floatR">'+
43
								'<li class="mymessage"><a href="/inform.html">通知<span class="badge"></span></a></li>'+
43 44
								'<li class="mymessage"><a href="/tidings.html">消息<span class="badge"></span></a></li>'+
44 45
								'<li class="mywork"><a href="/myDemand.html">我的工作台</a></li>'+
45 46
						'</ul>' +

+ 1 - 0
js/header.js

@ -40,6 +40,7 @@ var headerHtml = '';
40 40
					           ' </div>' + 
41 41
						'</div>' +
42 42
						'<ul class="headnavbtn floatR">'+
43
						'<li class="mymessage"><a href="inform.html">通知<span class="badge"></span></a></li>'+
43 44
								'<li class="mymessage"><a href="tidings.html">消息<span class="badge"></span></a></li>'+
44 45
								'<li class="mywork"><a href="myDemand.html">我的工作台</a></li>'+
45 46
						'</ul>' +

+ 155 - 0
js/inform.js

@ -0,0 +1,155 @@
1
$(function() {
2
	var obj = {
3
		rows: 20,
4
		uid:$.cookie("userid")
5
	};
6
	var count = 1;
7
		informList(obj);
8
		module.lWord;
9
		loginStatus();//判断个人是否登录
10
		$("#feedback").hide();
11
	function informList(objec) {
12
		$.ajax({
13
			url: '/ajax/notify',
14
			data: objec,
15
			async: true,
16
			dataType: 'json', //服务器返回json格式数据
17
			type: 'GET', //HTTP请求类型
18
			traditional: true, //传数组必须加这个
19
			success: function(data) {
20
				if(data.success) {
21
					var $info = data.data;
22
					if($info.length == 0) {
23
						return;
24
					}
25
					readed({
26
						uid: obj.uid,
27
						mid: $info[0].id,
28
						time: $info[0].createTime
29
					})
30

31
					informHtml($info);
32
					if(data.data.length == obj.rows) {
33
						obj.time = $info[$info.length - 1].createTime;
34
						obj.mid = $info[$info.length - 1].id;
35
						$(".js-load-more").removeClass("displayNone");
36
					}else{
37
						$(".js-load-more").addClass("displayNone");
38
					}
39

40
				}
41

42
			},
43
			error: function() {
44
				$.MsgBox.Alert('提示', '服务器连接超时!');
45
			}
46
		});
47
	}
48

49
	function informHtml($data) {
50
		for(var i = 0; i < $data.length; i++) {
51
			var str = '<li class="list-qa">' +
52
				'<div class="madiaInfo">' +
53
				'<div class="flexCenter qa-owner">' +
54
				'<div class="owner-head useHead" style="cursor:pointer"></div>' +
55
				'<div class="owner-info reWidth">' +
56
				'<div class="owner-tit h2Font cnt" style="cursor:pointer">' + $data[i].cnt + '</div></div>' +
57
				'<div class="creTime">' + commenTime($data[i].createTime) + '</div></div></div></li>'
58
			var $str = $(str);
59
			$str.data("obj", $data[i]);
60
			$("#curAnswers").append($str);
61
			uinfo($str, $data[i].uid)
62
		}
63
	}
64

65
	function uinfo(li, uid) {
66
		$.ajax({
67
			url:"/ajax/professor/editBaseInfo/" + uid, 
68
			async: true,
69
			dataType: 'json', //服务器返回json格式数据
70
			type: 'GET', //HTTP请求类型
71
			traditional: true, //传数组必须加这个
72
			success: function(data) {
73
				if(data.success) {
74
					var $data = data.data;
75
					if($data.hasHeadImage == 1) {
76
						li.find(".useHead").css('background-image', "url(/images/head/" + $data.id + "_l.jpg");
77
					}
78
				}
79
			},
80
			error: function(x) {
81
				plus.nativeUI.toast("服务器链接超时", toastStyle);
82
			}
83
		});
84
	}
85

86
	function readed(objec) {
87
		$.ajax({
88
			url: '/ajax/notify/readed',
89
			data: objec,
90
			async: true,
91
			dataType: 'json', //服务器返回json格式数据
92
			type: 'POST', //HTTP请求类型
93
			traditional: true, //传数组必须加这个
94
			success: function(data) {
95
				if(data.success) {
96
					console.log(JSON.stringify(data))
97
				}
98

99
			},
100
			error: function() {
101
				plus.nativeUI.toast("服务器链接超时", toastStyle);
102
			}
103
		});
104
	}
105
	$("#curAnswers").on("click", ".cnt", function() {
106
		var dobj = $(this).parents("li").data("obj");
107
		var our = "";
108
		if(dobj.opType == 0) {
109
			ourl = "userInforShow.html?professorId=" + dobj.uid;
110
		} else if(dobj.opType == 1) {
111
			ourl = 'userInforShow.html?professorId=' + dobj.pid + '&flag=1'
112
		} else if(dobj.opType == 2) {
113
			$.ajax({
114
				url: "/ajax/article/query?articleId="+dobj.pid
115
			}).done(function(data) {
116
				if(data.success) {
117
					window.openURL("shtml/a/"+data.data.createTime.substr(0,8)+"/"+data.data.shareId+".html");
118
				}
119
			});
120
		} else if(dobj.opType == 3 || dobj.opType == 4 || dobj.opType == 5) {
121
			ourl = "qa-show.html?id=" + dobj.pid;
122
		} else if(dobj.opType == 6) {
123
			$.ajax({
124
				url: "ajax/ppatent/qo?id="+dobj.pid
125
			}).done(function(data) {
126
				if(data.success) {
127
					window.openURL("shtml/pt/"+data.data.createTime.substr(0,8)+"/"+data.data.shareId+".html");
128
				}
129
			});
130
		} else if(dobj.opType == 7) {
131
			$.ajax({
132
				url: "ajax/ppaper/qo?id="+dobj.pid
133
			}).done(function(data) {
134
				if(data.success) {
135
					window.openURL("shtml/pp/"+data.data.createTime.substr(0,8)+"/"+data.data.shareId+".html");
136
				}
137
			});
138
		} else {
139
			module.lWord.init({id:dobj.pid});
140
			$(".blackcover").removeClass("displayNone");
141
			return;
142
		}
143
		if(dobj.opType == 2 || dobj.opType == 6 || dobj.opType == 7)
144
			return;
145
		window.open(ourl);
146
	})
147
	$("#curAnswers").on("click", ".useHead", function() {
148
		var dobj = $(this).parents("li").data("obj");
149
		window.open("userInforShow.html?professorId=" + dobj.uid);
150
		return false;
151
	})
152
	$(".js-load-more").click(function(){
153
		informList(obj);
154
	})
155
})

+ 200 - 0
js/informLeaveW.js

@ -0,0 +1,200 @@
1
(function(window) {
2
	function ajaxRequist(url, obj, type, fn) {
3
		$.ajax({
4
			url: url,
5
			data: obj,
6
			dataType: 'json', //服务器返回json格式数据
7
			type: type, //支持'GET'和'POST'
8
			traditional: true,
9
			success: function(data) {
10
				if(data.success) {
11
					fn(data.data)
12
				}
13
			},
14
			error: function(xhr, type, errorThrown) {
15
				$.MsgBox.Alert('提示', '服务器请求失败');
16
			}
17
		});
18
	}
19
	var LeaveWord = function() {
20
		var self = this;
21
		self.addHtml();
22
		self.bindEvent();
23
	}
24

25
	function lgin() {
26
		if($.cookie('userid')) {
27
			return true;
28
		}
29
		location.href = "login.html";
30
		return false;
31
	}
32
	LeaveWord.prototype.addHtml = function() {
33
		$("body").append('<textarea class="txtArea" id="tt" style="position:absolute;top:0;left:-999px;"></textarea>')
34
		var str='<div class="blackcover resAreaCover displayNone"><div class="resAreaBox form-item"><div class="researchArea" id="subArea" style="text-align:center;">留言详情</div><div class="form-item" style="padding:0px 30px;"><ul class="commentList"></ul></div><span class="workclose" id="workclose"></span></div></div>'
35
		$("body").prepend(str);
36
	}
37
	LeaveWord.prototype.init = function(obj) {
38
		var id = $.cookie('userid');
39
		var self = this;
40
		this.id=obj.id;
41
		console.log(self)
42
		ajaxRequist("/ajax/leavemsg/dialog", obj, "GET", function(data) {
43
			if(data.length == 0) {
44
				return;
45
			}
46
			$(".commentList").html("");
47
			for(var i = 0; i < data.length; i++) {
48
				var reply = "";
49
				if(data[i].reciver) {
50
					reply = '<span style="margin:0px 10px;">回复 </span><a href="userInforShow.html?professorId=' + data[i].reciver + '" class="userhref"><span class="h1Font messageName">张某某</span></a><em class="authiconNew" title="科袖认证专家"></em>'
51
				}
52
				if(data[i].state =="0") {
53
					data[i].cnt="该留言已被其本人删除。";
54
				}
55
				var itemlist = '<li class="flexCenter">';
56
				itemlist += '<a href class="userhref"> <div class="madiaHead useHead useHeadMsg"></div></a>';
57
				itemlist += '<div class="madiaInfo">';
58
				itemlist += '<p><a href="userInforShow.html?professorId=' + data[i].sender + '" class="userhref"><span class="h1Font messageName">张某某</span></a><em class="authiconNew" title="科袖认证专家"></em>' + reply + '<span class="commenttime" style="float:right;">' + commenTime(data[i].createTime) + '</span></p>';
59
				itemlist += '<p class="h2Font messageContent">' + data[i].cnt + '</p>';
60
				itemlist += '<div class="operateSpan"><em class="noMy"><span class="dzthumb"></span><span class="thNum">赞0</span><span class="callBack">回复</span></em><span class="messageDel displayNone">删除</span></div>';
61
				itemlist += '<div class="displayNone replyLeword"><textarea class="txtArea"></textarea><p class="pTxt"><span class="qCancel">取消</span><button class="hReply btnModel" disabled>回复</button></p></div></div></li>';
62
				$itemlist = $(itemlist);
63
				$(".commentList").append($itemlist);
64
				$itemlist.attr('data-obj', JSON.stringify(data[i]));
65
				if(id == data[i].sender) {
66
					$itemlist.find(".messageDel").removeClass("displayNone").end().find(".noMy").hide();
67
				}
68
				if(data[i].state =="0") {
69
					$itemlist.find(".operateSpan").addClass("displayNone");
70
				}
71
				if(data[i].reciver) {
72
					self.userInfo(data[i].sender, $itemlist, 0);
73
					self.userInfo(data[i].reciver, $itemlist, 1)
74
				} else {
75
					self.userInfo(data[i].sender, $itemlist, 0);
76
				}
77
				if(data[i].agreeCount)
78
					self.referThup(data[i].id, $itemlist, data[i].agreeCount);
79
			}
80
		})
81
	}
82
	LeaveWord.prototype.userInfo = function(uId, li, parNum) {
83
		ajaxRequist("/ajax/professor/editBaseInfo/" + uId, {}, "GET", function($data) {
84
			if(parNum == 0) {
85
				if($data.hasHeadImage == 1) {
86
					li.find(".useHead")[0].style.backgroundImage = "url(../images/head/" + $data.id + "_l.jpg" + ")";
87
				}
88
				li.find("textarea").attr("placeholder", "回复  " + $data.name + ":")
89
			}
90
			var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
91
			li.find(".messageName").eq(parNum).html($data.name).end().end().find(".authiconNew").eq(parNum).addClass(userType.sty).attr("title", userType.title);
92
		})
93
	}
94
	LeaveWord.prototype.size = function() {
95
		if(this.val().length > 200) {
96
			$.MsgBox.Alert('提示', '留言不得超过200个字');
97
			return false;
98
		}
99
		return true;
100
	}
101
	LeaveWord.prototype.autoGrow = function() {
102
		document.getElementById("tt").style.width = this.scrollWidth + "px";
103
		document.getElementById("tt").value = this.value;
104
		this.style.height = document.getElementById("tt").scrollHeight + "px";
105
	}
106
	LeaveWord.prototype.bindEvent = function() {
107
		var self = this;
108
		$(".commentList").on("click", "li", function(e) {
109
			if(!lgin()) {
110
				return;
111
			}
112
			var obj = JSON.parse($(this).attr("data-obj")),
113
				target = e.target;
114
			switch(target.className) {
115
				case "dzthumb":
116
					self.thub.call(target, obj.id, obj.agreeCount);
117
					break;
118
				case "callBack":
119
					$(target).parents(".operateSpan").addClass("displayNone").siblings(".replyLeword").removeClass("displayNone");
120
					break;
121
				case "messageDel":
122
					self.LwordDel(target, obj.id);
123
					break;
124
				case "hReply btnModel":
125
					self.replyLword(target, obj.id)
126
					break;
127
				case "qCancel":
128
					$(target).parent().siblings("textarea").val("").parents(".replyLeword").addClass("displayNone").siblings(".operateSpan").removeClass("displayNone")
129
					break;
130
			}
131
		});
132
		$(".msgCont").on("input", function() {
133
			if($.trim($(this).val()).length > 0) {
134
				$("#meSendtt").removeAttr("disabled");
135
			} else {
136
				$("#meSendtt").attr("disabled", "disabled");
137
			}
138
		})
139
		$(".commentList").on("input", "textarea", function(e) {
140
			if($.trim($(this).val()).length > 0) {
141
				$(this).siblings().find(".btnModel").removeAttr("disabled");
142
				self.autoGrow.call(this);
143
			} else {
144
				$(this).siblings().find(".btnModel").attr("disabled", "disabled");
145
			}
146
		})
147
		$("#workclose").click(function(){
148
			$(".blackcover").addClass("displayNone").find("ul").html("");
149
		})
150
	}
151
	LeaveWord.prototype.referThup = function(lid, li, num) {
152
		ajaxRequist("/ajax/leavemsg/agree", {
153
			id: lid,
154
			uid: $.cookie('userid')
155
		}, "GET", function(data) {
156
			if(data) {
157
				li.find(".thNum").html("已赞" + num).end().find(".dzthumb").addClass("dzthumbed").css("cursor", "auto");
158
			}
159
		})
160
	}
161
	LeaveWord.prototype.thub = function(lid, num) {
162
		var self = this;
163
		ajaxRequist("/ajax/leavemsg/agree", {
164
			id: lid,
165
			uid: $.cookie('userid'),
166
			uname: $.cookie('userName')
167
		}, "POST", function(data) {
168
			$(self).addClass('dzthumbed').siblings(".thNum").html("已赞" + (num + 1)) // + (Number(self.getAttribute("data-num")) + 1);
169
		})
170
	}
171
	LeaveWord.prototype.replyLword = function($th, lid) {
172
		var self = this;
173
		if(!self.size.call($($th).parents(".pTxt").siblings("textarea"))) {
174
			return;
175
		}
176
		ajaxRequist("/ajax/leavemsg/reply", {
177
			cnt: $($th).parents(".pTxt").siblings("textarea").val(),
178
			id: lid,
179
			uid: $.cookie('userid'),
180
			uname: $.cookie('userName')
181
		}, "POST", function(data) {
182
			$($th).parents(".pTxt").siblings("textarea").val("").parents(".replyLeword").addClass("displayNone").siblings(".operateSpan").removeClass("displayNone")
183
			self.init({
184
				id: self.id
185
			});
186
		})
187
	}
188
	LeaveWord.prototype.LwordDel = function($this, lid) {
189
		var self = this;
190
		ajaxRequist("/ajax/leavemsg/del", {
191
			id: lid
192
		}, "GET", function(data) {
193
			$($this).parents("li").remove();
194
		})
195
	}
196
	var module = {
197
		lWord: new LeaveWord()
198
	}
199
	window.module = module; 
200
})(window)