Browse Source

Merge remote-tracking branch 'origin/dev' into dev

XMTT 7 years ago
parent
commit
c54df05b7f
6 changed files with 450 additions and 32 deletions
  1. 5 0
      app/html/inform.html
  2. 76 0
      app/html/leaveWordDialog.html
  3. 39 19
      app/index.html
  4. 14 2
      app/js/consultlistNew.js
  5. 114 11
      app/js/inform.js
  6. 202 0
      app/js/leaveWordDialog.js

+ 5 - 0
app/html/inform.html

@ -32,6 +32,11 @@
32 32
					}
33 33
				}]
34 34
			});
35
			document.getElementsByClassName("toptitbox")[0].addEventListener("tap",function(){
36
				var web3 = plus.webview.getWebviewById("consultlistNew.html");
37
				mui.fire(web3, "newId");
38
				return true;
39
			})
35 40
		</script>
36 41
	</body>
37 42


+ 76 - 0
app/html/leaveWordDialog.html

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

4
	<head>
5
		<meta charset="UTF-8">
6
		<title>论文浏览-科袖</title>
7
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
8
		<link href="../css/mui.min.css" rel="stylesheet" />
9
		<link href="../css/iconfont.css" rel="stylesheet" />
10
		<link href="../css/app.css" rel="stylesheet" />
11
		<style>
12
			html,
13
			body {
14
				height: 100%;
15
				margin: 0;
16
				padding: 0px;
17
				overflow: hidden;
18
				background: #FFFFFF;
19
			}
20
			
21
			.mui-content {
22
				height: 100%;
23
				overflow: auto;
24
				background: #FFFFFF;
25
			}
26
			
27
			.fix {
28
				position: fixed;
29
				z-index: 10;
30
				right: 0;
31
				left: 0;
32
				height: 44px;
33
				background-color: #ffffff;
34
				-webkit-backface-visibility: hidden;
35
				backface-visibility: hidden;
36
			}
37
		</style>
38
	</head>
39

40
	<body>
41
		<header class="mui-bar mui-bar-nav toptitbox">
42
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left topback"></a>
43
			<h1 class="mui-title toptit">留言对话</h1>
44
		</header>
45
		<nav class="mui-bar mui-bar-tab footbox" style="border-top:none ;">
46
			<div class="mui-row artfoot displayNone" id="textInput">
47
				<div class="mui-col-xs-12">
48
					<textarea name="" placeholder="说点什么吧…" id="textInputThis" maxlength="200"></textarea>
49
					<button class="mui-btn" disabled>发表</button>
50
				</div>
51
			</div>
52
		</nav>
53
		<div class="mui-content">
54
			<div class="showDetail">
55
				<div class="madiaBlock" style="padding-bottom:50px;">
56
					<ul class="mui-table-view commentBlock noactiveTab">
57

58
					</ul>
59
				</div>
60
			</div>
61
		</div>
62
		<script src="../js/public/mui.min.js"></script>
63
		<script src="../js/public/base.js"></script>
64
		<script type="text/javascript" src="../js/leaveWordDialog.js"></script>
65
		<script type="text/javascript">
66
			iosheader();
67
			mui.ready(function() {
68
				mui.plusReady(function() {
69
					plus.nativeUI.closeWaiting();
70
					module.lWord(plus.webview.currentWebview().lid);
71
				})
72
			})
73
		</script>
74
	</body>
75

76
</html>

+ 39 - 19
app/index.html

@ -130,30 +130,50 @@ if(mui.os.ios) {
130 130
						"context": this,
131 131
						"success": function(data) {
132 132
							if(data.success) {
133
								if(mui.os.ios) {
134
									plus.runtime.setBadgeNumber(data.data);
135
									 var GeTuiSdk = plus.ios.importClass('GeTuiSdk');
136
            								GeTuiSdk.setBadge(data.data);
137
								}
138
								
139
								if(data.data) {
140
									
141
									document.getElementById("meLInum").style.display="block"
142
									document.getElementById("meLInum").innerHTML=data.data;
143
								}else{
144
									document.getElementById("meLInum").style.display="none";
145
									document.getElementById("meLInum").innerHTML=0;
146
								}
147 133
								
134
								lewd(data.data);
148 135
							}
149 136
						},
150 137
						"error": function() {
151 138
							plus.nativeUI.toast("服务器链接超时", toastStyle);
152
						}
153
					});
154
		}
155
	});
156
	//当前激活选项
139
}
140
});
141
}
142
});
143

144
function lewd(num) {
145
	mui.ajax(baseUrl + '/ajax/notify/idx', {
146
		"data": {
147
			id: plus.storage.getItem('userid')
148
		},
149
		"type": "get",
150
		"async": true,
151
		"context": this,
152
		"success": function(data) {
153
			if(data.success) {
154
				data.data.unRead+=num;
155
				if(mui.os.ios) {
156
					plus.runtime.setBadgeNumber(data.data.unRead);
157
					var GeTuiSdk = plus.ios.importClass('GeTuiSdk');
158
					GeTuiSdk.setBadge(data.data.unRead);
159
				}
160

161
				if(data.data) {
162

163
					document.getElementById("meLInum").style.display = "block"
164
					document.getElementById("meLInum").innerHTML = data.data.unRead;
165
				} else {
166
					document.getElementById("meLInum").style.display = "none";
167
					document.getElementById("meLInum").innerHTML = 0;
168
				}
169

170
			}
171
		},
172
		"error": function() {
173
			plus.nativeUI.toast("服务器链接超时", toastStyle);
174
		}
175
	});
176
}//当前激活选项
157 177
	var activeTab = subpages[0];
158 178
	//选项卡点击事件
159 179
	mui('.mui-bar-tab').on('tap', 'a', function(e) {

+ 14 - 2
app/js/consultlistNew.js

@ -9,6 +9,8 @@ mui.ready(function() {
9 9
		} else {
10 10
			content2.style.display = 'none';
11 11
			messageList(true);
12
			inform();
13
			websocket1();
12 14
		}
13 15
		/*登陆*/
14 16
		window.addEventListener('logined', function(event) {
@ -22,8 +24,9 @@ mui.ready(function() {
22 24
			});
23 25
			if(event.detail.rd) {
24 26
				websocket1();
27
				inform();
25 28
			}
26
29
			
27 30
		});
28 31
		window.addEventListener('exited', function(event) {
29 32
			var userid = event.detail.id;
@ -70,7 +73,7 @@ mui.ready(function() {
70 73
					}
71 74
				})
72 75
		})
73
		websocket1()
76
		
74 77
75 78
		function websocket1() {
76 79
			var ws = new WebSocket("ws://192.168.3.233:8081/portal/websocket/msg?id=" + userid + "&pm=app");
@ -84,6 +87,10 @@ mui.ready(function() {
84 87
				document.getElementById("inf").innerHTML=$info.cnt;	
85 88
				document.getElementById("iconT").style.display="block";
86 89
				document.getElementById("iconNum").innerHTML=parseInt(document.getElementById("iconNum").innerHTML)+1;
90
				var web4 = plus.webview.getLaunchWebview();
91
			mui.fire(web4, "newId", {
92
				rd: 1
93
			});
87 94
				return;
88 95
				}
89 96
				var li = $("#consultList").find("li");
@ -166,7 +173,12 @@ mui.ready(function() {
166 173
			}
167 174
		}
168 175
		window.addEventListener("newId", function(event) {
176
			var web4 = plus.webview.getLaunchWebview();
177
			mui.fire(web4, "newId", {
178
				rd: 3
179
			});
169 180
			messageList(false);
181
			inform();
170 182
		})
171 183
172 184
		function messageList(bole) {

+ 114 - 11
app/js/inform.js

@ -7,7 +7,7 @@ mui.init({
7 7
		up: {
8 8
			contentrefresh: '正在加载...',
9 9
			callback: pullupRefresh,
10
			auto:true
10
			auto: true
11 11
		}
12 12
	}
13 13
});
@ -40,11 +40,11 @@ var count,
40 40
 */
41 41

42 42
function pullupRefresh() {
43
	
43

44 44
	mui.plusReady(function() {
45 45
		if(!obj.uid) {
46
				obj.uid = plus.storage.getItem('userid');
47
			}
46
			obj.uid = plus.storage.getItem('userid');
47
		}
48 48
		setTimeout(function() {
49 49
			informList(obj);
50 50
		}, 1000);
@ -53,7 +53,6 @@ function pullupRefresh() {
53 53
}
54 54

55 55
function informList(objec) {
56
	console.log(JSON.stringify(objec));
57 56
	mui.ajax(baseUrl + '/ajax/notify', {
58 57
		data: objec,
59 58
		async: true,
@ -63,7 +62,7 @@ function informList(objec) {
63 62
		success: function(data) {
64 63
			if(data.success) {
65 64
				var $info = data.data;
66
				console.log($info.length)
65

67 66
				if($info.length == 0) {
68 67
					if(count) {
69 68
						document.getElementById("nodatalist").style.display = "block";
@ -75,15 +74,21 @@ function informList(objec) {
75 74
					}
76 75
				}
77 76
				if(count) {
78
					document.getElementById("consultList").innerHTML="";
77
					document.getElementById("consultList").innerHTML = "";
79 78
					mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
79

80 80
				}
81
				readed({
82
					uid: obj.uid,
83
					mid: $info[0].id,
84
					time: $info[0].createTime
85
				})
81 86
				count = 0;
82 87
				informHtml($info);
83 88
				if(data.data.length == obj.rows) {
84 89
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); /*能上拉*/
85
					obj.time = $info[$info.length-1].createTime;
86
					obj.mid = $info[$info.length-1].id;
90
					obj.time = $info[$info.length - 1].createTime;
91
					obj.mid = $info[$info.length - 1].id;
87 92
				} else {
88 93
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
89 94
				}
@ -99,13 +104,16 @@ function informList(objec) {
99 104

100 105
function informHtml($data) {
101 106
	for(var i = 0; i < $data.length; i++) {
107
		var par = JSON.stringify($data[i]);
108
		console.log($data[i].readed);
102 109
		var li = document.createElement("li");
103 110
		li.className = "mui-table-view-cell";
104 111
		li.style.height = "80px";
105
		li.innerHTML = '<div class="madiaHead useHead" style="../images/default-photo.jpg"></div>' +
112
		li.innerHTML = '<div class="madiaHead useHead" style="../images/default-photo.jpg" data-id="' + $data[i].uid + '"></div>' +
106 113
			'<div class="madiaInfo">' +
107 114
			'<div class="h2Font mui-ellipsis-2" style="color: #333;font-weight: 400;">' + $data[i].cnt + '</div>' +
108 115
			'<div class="h3Font" style="margin: 5px 0;">' + commenTime($data[i].createTime) + '</div></div>'
116
		li.getElementsByClassName("madiaInfo")[0].setAttribute("data-obj", par);
109 117
		document.getElementById("consultList").appendChild(li);
110 118
		uinfo(li, $data[i].uid)
111 119
	}
@ -129,4 +137,99 @@ function uinfo(li, uid) {
129 137
			plus.nativeUI.toast("服务器链接超时", toastStyle);
130 138
		}
131 139
	});
132
}
140
}
141

142
function readed(objec) {
143
	mui.ajax(baseUrl + '/ajax/notify/readed', {
144
		data: objec,
145
		async: true,
146
		dataType: 'json', //服务器返回json格式数据
147
		type: 'POST', //HTTP请求类型
148
		traditional: true, //传数组必须加这个
149
		success: function(data) {
150
			if(data.success) {
151
				console.log(JSON.stringify(data))
152
			}
153

154
		},
155
		error: function(x) {
156
			plus.nativeUI.toast("服务器链接超时", toastStyle);
157
		}
158
	});
159
}
160
mui("#consultList").on("tap", ".madiaInfo", function() {
161
	var dobj = JSON.parse(this.getAttribute("data-obj"));
162
	var our = "",
163
		data;
164
	if(dobj.opType == 0) {
165
		ourl = "userInforShow.html";
166
		data = {
167
			proid: dobj.pid
168
		}
169
	} else if(dobj.opType == 1) {
170
		ourl = "researchAreaHead.html";
171
		data = {
172
			dataCaption: dobj.cnt.substring(dobj.cnt.indexOf(">") + 1, dobj.cnt.lastIndexOf("<")),
173
			professorId: dobj.pid
174
		}
175
	} else if(dobj.opType == 2) {
176
		ourl = "professorArticle.html";
177
		data = {
178
			articleId: dobj.pid,
179
			ownerid: obj.uid
180
		};
181
	} else if(dobj.opType == 3) {
182
		ourl = "qa-answer-show.html";
183
		data = {
184
			anid: dobj.pid
185
		};
186
	} else if(dobj.opType == 4) {
187
		ourl = "qa-answer-show.html";
188
		data = {
189
			anid: dobj.pid
190
		};
191
	} else if(dobj.opType == 5) {
192
		ourl = "qa-question-show.html"
193
		data = {
194
			quid: dobj.pid
195
		};
196
	} else if(dobj.opType == 6) {
197
		ourl = "patentShow.html"
198
		data = {
199
			patentId: dobj.pid
200
		}
201
	} else if(dobj.opType == 7) {
202
		ourl = "paperShow.html";
203
		data = {
204
			paperId: dobj.pid
205
		}
206
	} else {
207
		ourl = "leaveWordDialog.html";
208
		data = {
209
			lid: dobj.pid
210
		}
211
	}
212
	mui.openWindow({
213
		url: '../html/' + ourl,
214
		id: ourl,
215
		show: {
216
			autoShow: false,
217
			aniShow: "slide-in-right",
218
		},
219
		extras: data
220
	})
221
})
222
mui("#consultList").on("tap", ".useHead", function() {
223
	var dobj = this.getAttribute("data-id");
224
	mui.openWindow({
225
		url: '../html/userInforShow.html',
226
		id: "userInforShow.html",
227
		show: {
228
			autoShow: false,
229
			aniShow: "slide-in-right",
230
		},
231
		extras: {
232
			proid: dobj
233
		}
234
	})
235
})

+ 202 - 0
app/js/leaveWordDialog.js

@ -0,0 +1,202 @@
1
(function(window) {
2
	function ajaxRequist(url, obj, type, fn) {
3
		mui.ajax(url, {
4
			data: obj,
5
			dataType: 'json', //服务器返回json格式数据
6
			type: type, //支持'GET'和'POST'
7
			traditional: true,
8
			success: function(data) {
9
				console.log(JSON.stringify(data))
10
				if(data.success) {
11
					fn(data.data)
12
				}
13
			},
14
			error: function(xhr, type, errorThrown) {
15
				plus.nativeUI.toast("服务器链接超时", toastStyle);
16
			}
17
		});
18
	}
19

20
	function trim(str) { //删除左右两端的空格
21
		  
22
		return str.replace(/(^\s*)|(\s*$)/g, "");  
23
	}
24
	var LeaveWord = function() {
25
		var self = this;
26
		self.sid = module.sid;
27
		self.init();
28
		self.bindEvent();
29
	}
30
	LeaveWord.prototype.init = function() {
31
		var self = this;
32
		ajaxRequist(baseUrl + "/ajax/leavemsg/dialog", {
33
			id: self.sid
34
		}, "GET", function(data) {
35
			plus.webview.currentWebview().show();
36
			console.log(JSON.stringify(data))
37
			document.getElementsByClassName('commentBlock')[0].innerHTML = ""
38
			if(data.length == 0) {
39
				return;
40
			}
41
			var id = plus.storage.getItem('userid');
42
			for(var i = 0; i < data.length; i++) {
43
				var oText = "",
44
					reply = "",re="";
45
					if(data[i].state=="1") 
46
					re = '<span class="replyLew" style="margin-right:10px;" data-id="' + data[i].id + '">回复</span>' + '<span class="mui-icon iconfont plusbtn icon-appreciate"style="padding-left:10px;margin-right:10px;font-size:14px;" data-id="' + data[i].id + '" data-num="' + data[i].agreeCount + '"></span><span  class="zan"style="display:' + (data[i].agreeCount ? "inline-block" : "none") + '">' + data[i].agreeCount + ' 赞 </span>';
47
					
48
				if(id == data[i].sender) {
49
					oText = "删除";
50
					re = "";
51
				}
52
				if(data[i].state=="0") {
53
					oText = ""
54
				}
55
				if(data[i].reciver) {
56
					reply = " 回复 " + "<span class='reply2'></span>"
57
				}
58
				var baImg = "../images/default-photo.jpg";
59
				var li = document.createElement("li");
60
				li.className = "mui-table-view-cell";
61
				li.innerHTML = '<div class="flexCenter mui-clearfix">' +
62
					'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')" data-id="' + data[i].sender + '"></div>' +
63
					'<div class="madiaInfo">' +
64
					'<p><span class="replay1"></span>' + reply + '</p>' +
65
					'</div>' +
66
					'</div>' +
67
					'<div class="madiaInfo">' +
68
					'<p class="h2Font">' + ((data[i].state=="1")?data[i].cnt:"该留言已被其本人删除。") + '</p>' +
69
					'<p class="operateSpan">' +
70
					'<span class="commenttime">' + commenTime(data[i].createTime) + '</span>' + re +
71
					'<span data-id="' + data[i].id + '" class="dele">' + oText + '</span>' +
72
					'</p>' +
73
					'</div>'
74
				document.getElementsByClassName("commentBlock")[0].appendChild(li);
75
				if(data[i].reciver) {
76
					self.userInfo(data[i].sender, li, 1);
77
					self.userInfo(data[i].reciver, li, 2)
78
				} else {
79
					self.userInfo(data[i].sender, li, 1);
80
				}
81
				if(data[i].agreeCount)
82
					self.referThup(data[i].id, li, data[i].agreeCount);
83
			}
84
		})
85
	}
86
	LeaveWord.prototype.userInfo = function(uId, li, parNum) {
87
		ajaxRequist(baseUrl + "/ajax/professor/editBaseInfo/" + uId, {}, "GET", function($data) {
88
			if(parNum == 1) {
89
				if($data.hasHeadImage == 1) {
90
					li.getElementsByClassName("useHead")[0].style.backgroundImage = "url(" + baseUrl + "/images/head/" + $data.id + "_l.jpg" + ")";
91
				}
92
			}
93
			var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
94
			var str = '<span class="h1Font" >' + $data.name + '</span><em class="authicon ' + userType.sty + '" title="科袖认证专家"></em>'
95
			if(parNum == 1) {
96
				li.getElementsByClassName("replay1")[0].innerHTML = str;
97
			} else {
98
				li.getElementsByClassName("reply2")[0].innerHTML = str;
99
			}
100
			if(li.getElementsByClassName("replyLew")[0])
101
				li.getElementsByClassName("replyLew")[0].setAttribute("name", "回复 " + $data.name + ":");
102
		})
103
	}
104
	LeaveWord.prototype.size = function() {
105
		if(document.getElementById("textInputThis").value.length > 200) {
106
			plus.nativeUI.toast("留言不得超过200个字", toastStyle);
107
			return false;
108
		}
109
		return true;
110
	}
111
	LeaveWord.prototype.bindEvent = function() {
112
		var self = this;
113
		document.getElementsByClassName("mui-btn")[0].addEventListener("tap", function() {
114
				self.replyLword(document.getElementById("textInputThis").getAttribute("oid"));
115
		});
116
		mui(".commentBlock").on("tap", ".plusbtn", function() {
117
			if(this.classList.contains('icon-appreciatefill') == true) {
118
				return;
119
			}
120
			self.thub.call(this, this.getAttribute("data-id"));
121
		})
122
		mui(".commentBlock").on("tap", ".replyLew", function() {
123
			var oid = this.getAttribute("data-id")
124
			document.getElementById("textInput").style.display = "block";
125
			document.getElementById("textInputThis").focus();
126
			document.getElementById("textInputThis").placeholder = this.getAttribute("name");
127
			document.getElementById("textInputThis").setAttribute("oid", oid);
128
			return false;
129
		})
130
		mui("body").on("tap", ".mui-content", function() {
131
			document.getElementById("textInput").style.display = "none";
132
		})
133
		mui(".commentBlock").on("tap", ".dele", function() {
134
			self.LwordDel(this, this.getAttribute("data-id"));
135
		});
136
		document.getElementById("textInputThis").addEventListener("input", function() {
137
			var length = trim(this.value);
138
			if(length) {
139
				document.getElementsByClassName("mui-btn")[0].removeAttribute("disabled");
140
			} else {
141
				document.getElementsByClassName("mui-btn")[0].setAttribute("disabled", "true")
142
			}
143
		})
144
	}
145
	LeaveWord.prototype.referThup = function(lid, li, num) {
146
		ajaxRequist(baseUrl + "/ajax/leavemsg/agree", {
147
			id: lid,
148
			uid: plus.storage.getItem('userid')
149
		}, "GET", function(data) {
150
			if(data) {
151
				li.getElementsByClassName("plusbtn")[0].classList.add("icon-appreciatefill");
152
				li.getElementsByClassName("zan")[0].innerHTML = "已赞" + num;
153
			}
154
		})
155
	}
156
	LeaveWord.prototype.thub = function(lid) {
157
		var self = this;
158
		ajaxRequist(baseUrl + "/ajax/leavemsg/agree", {
159
			id: lid,
160
			uid: plus.storage.getItem('userid'),
161
			uname: plus.storage.getItem('name')
162
		}, "POST", function(data) {
163
			self.classList.add("icon-appreciatefill");
164
			self.nextElementSibling.innerHTML = "已赞" + (Number(self.getAttribute("data-num")) + 1);
165
			self.nextElementSibling.style.display = "inline-block";
166
		})
167
	}
168
	LeaveWord.prototype.replyLword = function(lid) {
169
		var self = this;
170
		if(!self.size) {
171
			return;
172
		}
173
		ajaxRequist(baseUrl + "/ajax/leavemsg/reply", {
174
			cnt: document.getElementById("textInputThis").value,
175
			id: lid,
176
			uid: plus.storage.getItem('userid'),
177
			uname: plus.storage.getItem('name')
178
		}, "POST", function(data) {
179
			document.getElementById("textInputThis").value = "";
180
			document.getElementById('textInput').style.display = "none";
181
			self.init({
182
				id: self.sid
183
			});
184
		})
185
	}
186
	LeaveWord.prototype.LwordDel = function($this, lid) {
187
		var self = this;
188
		ajaxRequist(baseUrl + "/ajax/leavemsg/del", {
189
			id: lid
190
		}, "GET", function(data) {
191
			document.getElementsByClassName("commentBlock")[0].removeChild($this.parentNode.parentNode.parentNode);
192
		})
193
	}
194

195
	var module = {
196
		lWord: function(sid) {
197
			this.sid = sid;
198
			var lw = new LeaveWord();
199
		}
200
	}
201
	window.module = module;
202
})(window)