浏览代码

留言结尾

li 7 年之前
父节点
当前提交
e85cea74c6
共有 7 个文件被更改,包括 288 次插入592 次删除
  1. 2 4
      app/html/paperShow.html
  2. 1 4
      app/html/patentShow.html
  3. 1 1
      app/html/professorArticle.html
  4. 3 20
      app/js/articleShow.js
  5. 275 260
      app/js/leaveWords.js
  6. 3 150
      app/js/paperShow.js
  7. 3 153
      app/js/patentShow.js

+ 2 - 4
app/html/paperShow.html

@ -150,6 +150,7 @@
150 150
		<script src="../js/public/mui.previewimage.js" type="text/javascript" charset="utf-8"></script>
151 151
		<script src="../js/public/base.js"></script>
152 152
		<script src="../js/public/jquery-1.11.1.js"></script>
153
		<script type="text/javascript" src="../js/leaveWords.js"></script>
153 154
		<script src="../js/paperShow.js"></script>
154 155
		<script type="text/javascript"> 
155 156
			//处理iOS下弹出软键盘后头部会随页面的滚动条消失问题
@ -158,10 +159,7 @@
158 159
			})
159 160
			//处理iOS下弹出软键盘后头部会随页面的滚动条消失问题
160 161
		    iosheader();
161
		    mui("body").on("tap",".mui-content",function(){
162
		    	document.getElementById("textInput").style.display="none";
163
		    	document.getElementById("operCol").style.display="block";
164
		    })
162
		    
165 163
		    
166 164
		    //var BtnMore=document.getElementById("BtnMore");
167 165
		    var shareOut=document.getElementById("shareOut");

+ 1 - 4
app/html/patentShow.html

@ -157,6 +157,7 @@
157 157
		<script src="../js/public/mui.previewimage.js" type="text/javascript" charset="utf-8"></script>
158 158
		<script src="../js/public/base.js"></script>
159 159
		<script src="../js/public/jquery-1.11.1.js"></script>
160
		<script type="text/javascript" src="../js/leaveWords.js"></script>
160 161
		<script src="../js/patentShow.js"></script>
161 162
		<script type="text/javascript"> 
162 163
			document.getElementById("listenClick").addEventListener("tap",function(){
@ -164,10 +165,6 @@
164 165
			})
165 166
			//处理iOS下弹出软键盘后头部会随页面的滚动条消失问题
166 167
		    iosheader();
167
		    mui("body").on("tap",".mui-content",function(){
168
		    	document.getElementById("textInput").style.display="none";
169
		    	document.getElementById("operCol").style.display="block";
170
		    })
171 168
		    
172 169
		    //var BtnMore=document.getElementById("BtnMore");
173 170
		    var shareOut=document.getElementById("shareOut");

+ 1 - 1
app/html/professorArticle.html

@ -175,8 +175,8 @@
175 175
		    	shareBlock.style.display="none";
176 176
		    })
177 177
		</script>
178
		<script type="text/javascript" src="../js/articleShow.js"></script>
179 178
		<script type="text/javascript" src="../js/leaveWords.js"></script>
179
		<script type="text/javascript" src="../js/articleShow.js"></script>
180 180
	</body>
181 181

182 182
</html>

+ 3 - 20
app/js/articleShow.js

@ -4,10 +4,11 @@ var stt;
4 4

5 5

6 6
mui.plusReady(function() {
7
	console.log(JSON.stringify(module))
7 8
	mui('#articleContent').on('tap','a',function(){
8 9
		plus.runtime.openURL( this.href);
9 10
	});
10
	
11
	module.lWord(plus.webview.currentWebview().articleId, 1);
11 12
	var ffl=false;
12 13
	var oCurren = {
13 14
		self: plus.webview.currentWebview(),
@ -577,14 +578,12 @@ mui.plusReady(function() {
577 578
			"articleId": oArticleModule.articleId,
578 579
			'operateId': oCurren.userid
579 580
		}, "get", oArticleModule.thumbs);
580

581
		
582

583 581
		/*查询是否收藏文章*/
584 582
		oArticleModule.oAjaxGet(baseUrl + "/ajax/watch/hasWatch", {
585 583
			"watchObject": oArticleModule.articleId,
586 584
			'professorId': oCurren.userid
587 585
		}, "get", oArticleModule.storeGetUp);
586
		module.init.init();
588 587
	})
589 588

590 589
	document.getElementsByClassName("attenSpan")[0].addEventListener("tap", function() {
@ -642,23 +641,7 @@ mui.plusReady(function() {
642 641
		}
643 642
	})
644 643
	/*留言总数*/
645
	function trim(str) { //删除左右两端的空格
646
		  
647
		return str.replace(/(^\s*)|(\s*$)/g, "");  
648
	}
649
	
650
	document.getElementById("textInputThis").addEventListener("input", function() {
651
		var length = trim(this.value);
652
		if(length) {
653
			document.getElementsByClassName("mui-btn")[0].removeAttribute("disabled");
654
			
655
		} else {
656
			document.getElementsByClassName("mui-btn")[0].setAttribute("disabled", "true")
657
		}
658
		
659
	})
660 644
	
661

662 645
	/*微信及微信朋友圈分享专家*/
663 646
	var auths, shares;
664 647
	plus.oauth.getServices(function(services) {

+ 275 - 260
app/js/leaveWords.js

@ -1,279 +1,294 @@
1
mui.ready(function() {
2
	mui.plusReady(function() {
3
		function ajaxRequist(url, obj, type, fn) {
4
			mui.ajax(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
					plus.nativeUI.toast("服务器链接超时", toastStyle);
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
				if(data.success) {
10
					fn(data.data)
16 11
				}
17
			});
18
		}
19
		var LeaveWord = function() {
20
			var self = this;
21
			self.sid = module.sid;
22
			self.stype = module.stype;
12
			},
13
			error: function(xhr, type, errorThrown) {
14
				plus.nativeUI.toast("服务器链接超时", toastStyle);
15
			}
16
		});
17
	}
23 18

24
			self.init({
25
				sid: self.sid,
26
				stype: self.stype,
27
				time: 0,
28
				id: 0,
29
				rows: 500
30
			});
31
			self.bindEvent();
32
			self.LwordTotal();
33
		}
19
	function trim(str) { //删除左右两端的空格
20
		  
21
		return str.replace(/(^\s*)|(\s*$)/g, "");  
22
	}
23
	var LeaveWord = function() {
24
		var self = this;
25
		self.sid = module.sid;
26
		self.stype = module.stype;
27
		self.init();
28
		self.bindEvent();
29
		self.LwordTotal();
30
	}
34 31

35
		function lgin() {
36
			if(plus.storage.getItem('userid')) {
37
				return true;
38
			}
39
			mui.openWindow({
40
				url: '../html/login.html',
41
				id: '../html/login.html',
42
				show: {
43
					aniShow: "slide-in-bottom"
44
				},
45
				extras: {
46
					ourl: plus.webview.currentWebview().id
47
				}
48
			});
49
			return false;
50
		}
51
		LeaveWord.prototype.init = function(obj) {
52
			var self = this;
53
			ajaxRequist(baseUrl + "/ajax/leavemsg/subject", obj, "GET", function(data) {
54
				document.getElementsByClassName('commentBlock')[0].innerHTML = ""
55
				if(data.length == 0) {
56
					return;
57
				}
58
				var id = plus.storage.getItem('userid');
59
				for(var i = 0; i < data.length; i++) {
60
					var oText = "",
61
						reply = "",
62
						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>';
63
					if(id == data[i].sender) {
64
						oText = "删除";
65
						re = "";
66
					}
67
					if(data[i].reciver) {
68
						reply = " 回复 " + "<span class='reply2'></span>"
69
					}
70
					var baImg = "../images/default-photo.jpg";
71
					var li = document.createElement("li");
72
					li.className = "mui-table-view-cell";
73
					li.innerHTML = '<div class="flexCenter mui-clearfix">' +
74
						'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')" data-id="' + data[i].sender + '"></div>' +
75
						'<div class="madiaInfo">' +
76
						'<p><span class="replay1"></span>' + reply + '</p>' +
77
						'</div>' +
78
						'</div>' +
79
						'<div class="madiaInfo">' +
80
						'<p class="h2Font">' + data[i].cnt + '</p>' +
81
						'<p class="operateSpan">' +
82
						'<span class="commenttime">' + commenTime(data[i].createTime) + '</span>' + re +
83
						'<span data-id="' + data[i].id + '" class="dele">' + oText + '</span>' +
84
						'</p>' +
85
						'</div>'
86
					document.getElementsByClassName("commentBlock")[0].appendChild(li);
87
					if(data[i].reciver) {
88
						self.userInfo(data[i].sender, li, 1);
89
						self.userInfo(data[i].reciver, li, 2)
90
					} else {
91
						self.userInfo(data[i].sender, li, 1);
92
					}
93
					if(data[i].agreeCount)
94
					self.referThup(data[i].id, li,data[i].agreeCount);
95
				}
96
			})
97
		}
98
		LeaveWord.prototype.userInfo = function(uId, li, parNum) {
99
			ajaxRequist(baseUrl + "/ajax/professor/editBaseInfo/" + uId, {}, "GET", function($data) {
100
				if(parNum == 1) {
101
					if($data.hasHeadImage == 1) {
102
						li.getElementsByClassName("useHead")[0].style.backgroundImage = "url(" + baseUrl + "/images/head/" + $data.id + "_l.jpg" + ")";
103
					}
104
				}
105
				var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
106
				var str = '<span class="h1Font" >' + $data.name + '</span><em class="authicon ' + userType.sty + '" title="科袖认证专家"></em>'
107
				if(parNum == 1) {
108
					li.getElementsByClassName("replay1")[0].innerHTML = str;
109
				} else {
110
					li.getElementsByClassName("reply2")[0].innerHTML = str;
111
				}
112
				if(li.getElementsByClassName("replyLew")[0])
113
				li.getElementsByClassName("replyLew")[0].setAttribute("name", "回复 " + $data.name + ":");
114
			})
115
		}
116
		LeaveWord.prototype.size = function() {
117
			if(document.getElementById("textInputThis").value.length > 200) {
118
				plus.nativeUI.toast("留言不得超过200个字", toastStyle);
119
				return false;
120
			}
32
	function lgin() {
33
		if(plus.storage.getItem('userid')) {
121 34
			return true;
122 35
		}
123
		LeaveWord.prototype.topLw = function() {
124
			var self = this;
125
			if(!self.size) {
36
		mui.openWindow({
37
			url: '../html/login.html',
38
			id: '../html/login.html',
39
			show: {
40
				aniShow: "slide-in-bottom"
41
			},
42
			extras: {
43
				ourl: plus.webview.currentWebview().id
44
			}
45
		});
46
		return false;
47
	}
48
	LeaveWord.prototype.init = function() {
49
		console.log(JSON.stringify(this))
50
		var self = this;
51
		ajaxRequist(baseUrl + "/ajax/leavemsg/subject", {
52
			sid: self.sid,
53
			stype: self.stype,
54
			time: 0,
55
			id: 0,
56
			rows: 500
57
		}, "GET", function(data) {
58
			document.getElementsByClassName('commentBlock')[0].innerHTML = ""
59
			if(data.length == 0) {
126 60
				return;
127 61
			}
128
			ajaxRequist(baseUrl + "/ajax/leavemsg", {
129
				cnt: document.getElementById("textInputThis").value,
130
				refId: self.sid,
131
				refType: self.stype,
132
				sender: plus.storage.getItem('userid'),
133
				uname: plus.storage.getItem('name')
134
			}, "POST", function() {
135
				document.getElementById("textInputThis").value = "";
136
				document.getElementById('textInput').style.display = "none";
137
				document.getElementById('operCol').style.display = "block";
138
				self.init({
139
					sid: self.sid,
140
					stype: self.stype,
141
					time: 0,
142
					id: 0,
143
					rows: 500
144
				});
145
			})
146
		}
147
		LeaveWord.prototype.bindEvent = function() {
148
			var self = this;
149
			document.getElementsByClassName("mui-btn")[0].addEventListener("tap", function() {
150
				if(!lgin()) {
151
					return;
62
			var id = plus.storage.getItem('userid');
63
			for(var i = 0; i < data.length; i++) {
64
				var oText = "",
65
					reply = "",
66
					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>';
67
				if(id == data[i].sender) {
68
					oText = "删除";
69
					re = "";
152 70
				}
153
				if(document.getElementById("textInputThis").getAttribute("oid")) {
154
					self.replyLword(document.getElementById("textInputThis").getAttribute("oid"));
155
					return;
71
				if(data[i].reciver) {
72
					reply = " 回复 " + "<span class='reply2'></span>"
156 73
				}
157
				self.topLw();
158
			});
159
			mui(".commentBlock").on("tap", ".plusbtn", function() {
160
				if(!lgin()) {
161
					return;
162
				}
163
				if(this.classList.contains('icon-appreciatefill')==true) {
164
					return;
165
				}
166
				self.thub.call(this, this.getAttribute("data-id"));
167
			})
168
			mui(".commentBlock").on("tap", ".replyLew", function() {
169
				if(!lgin()) {
170
					return;
171
				}
172
				var oid = this.getAttribute("data-id")
173
				document.getElementById("operCol").style.display = "none";
174
				document.getElementById("textInput").style.display = "block";
175
				document.getElementById("textInputThis").focus();
176
				document.getElementById("textInputThis").placeholder = this.getAttribute("name");
177
				document.getElementById("textInputThis").setAttribute("oid", oid);
178
				return false;
179
			})
180
			mui("body").on("tap", ".mui-content", function() {
181
				document.getElementById("textInput").style.display = "none";
182
				document.getElementById("operCol").style.display = "block";
183
				document.getElementById("textInputThis").placeholder = "说点什么吧...";
184
				if(document.getElementById("textInputThis").getAttribute("oid")) {
185
					document.getElementById("textInputThis").removeAttribute("oid")
186
				}
187
			})
188
			mui(".commentBlock").on("tap", ".dele", function() {
189
				self.LwordDel(this, this.getAttribute("data-id"));
190
			});
191
			mui(".artfoot").on("tap", ".inputShow", function() {
192
				if(!lgin()) {
193
					return;
74
				var baImg = "../images/default-photo.jpg";
75
				var li = document.createElement("li");
76
				li.className = "mui-table-view-cell";
77
				li.innerHTML = '<div class="flexCenter mui-clearfix">' +
78
					'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')" data-id="' + data[i].sender + '"></div>' +
79
					'<div class="madiaInfo">' +
80
					'<p><span class="replay1"></span>' + reply + '</p>' +
81
					'</div>' +
82
					'</div>' +
83
					'<div class="madiaInfo">' +
84
					'<p class="h2Font">' + data[i].cnt + '</p>' +
85
					'<p class="operateSpan">' +
86
					'<span class="commenttime">' + commenTime(data[i].createTime) + '</span>' + re +
87
					'<span data-id="' + data[i].id + '" class="dele">' + oText + '</span>' +
88
					'</p>' +
89
					'</div>'
90
				document.getElementsByClassName("commentBlock")[0].appendChild(li);
91
				if(data[i].reciver) {
92
					self.userInfo(data[i].sender, li, 1);
93
					self.userInfo(data[i].reciver, li, 2)
94
				} else {
95
					self.userInfo(data[i].sender, li, 1);
194 96
				}
195
				document.getElementById("textInput").style.display = "block";
196
				document.getElementById("operCol").style.display = "none";
197
				document.getElementById("textInputThis").focus();
198
			})
199
		}
200
		LeaveWord.prototype.referThup = function(lid, li,num) {
201
			ajaxRequist(baseUrl + "/ajax/leavemsg/agree", {
202
				id: lid,
203
				uid: plus.storage.getItem('userid')
204
			}, "GET", function(data) {
205
				if(data) {
206
					li.getElementsByClassName("plusbtn")[0].classList.add("icon-appreciatefill");
207
					li.getElementsByClassName("zan")[0].innerHTML="已赞" +num;
97
				if(data[i].agreeCount)
98
					self.referThup(data[i].id, li, data[i].agreeCount);
99
			}
100
		})
101
	}
102
	LeaveWord.prototype.userInfo = function(uId, li, parNum) {
103
		ajaxRequist(baseUrl + "/ajax/professor/editBaseInfo/" + uId, {}, "GET", function($data) {
104
			if(parNum == 1) {
105
				if($data.hasHeadImage == 1) {
106
					li.getElementsByClassName("useHead")[0].style.backgroundImage = "url(" + baseUrl + "/images/head/" + $data.id + "_l.jpg" + ")";
208 107
				}
209
			})
108
			}
109
			var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
110
			var str = '<span class="h1Font" >' + $data.name + '</span><em class="authicon ' + userType.sty + '" title="科袖认证专家"></em>'
111
			if(parNum == 1) {
112
				li.getElementsByClassName("replay1")[0].innerHTML = str;
113
			} else {
114
				li.getElementsByClassName("reply2")[0].innerHTML = str;
115
			}
116
			if(li.getElementsByClassName("replyLew")[0])
117
				li.getElementsByClassName("replyLew")[0].setAttribute("name", "回复 " + $data.name + ":");
118
		})
119
	}
120
	LeaveWord.prototype.size = function() {
121
		if(document.getElementById("textInputThis").value.length > 200) {
122
			plus.nativeUI.toast("留言不得超过200个字", toastStyle);
123
			return false;
210 124
		}
211
		LeaveWord.prototype.thub = function(lid) {
212
			var self = this;
213
			ajaxRequist(baseUrl + "/ajax/leavemsg/agree", {
214
				id: lid,
215
				uid: plus.storage.getItem('userid'),
216
				uname: plus.storage.getItem('name')
217
			}, "POST", function(data) {
218
				self.classList.add("icon-appreciatefill");
219
				self.nextElementSibling.innerHTML="已赞" +(Number(self.getAttribute("data-num"))+1);
220
				self.nextElementSibling.style.display="inline-block";
221
			})
125
		return true;
126
	}
127
	LeaveWord.prototype.topLw = function() {
128
		var self = this;
129
		if(!self.size) {
130
			return;
222 131
		}
223
		LeaveWord.prototype.replyLword = function(lid) {
224
			var self = this;
225
			if(!self.size) {
132
		ajaxRequist(baseUrl + "/ajax/leavemsg", {
133
			cnt: document.getElementById("textInputThis").value,
134
			refId: self.sid,
135
			refType: self.stype,
136
			sender: plus.storage.getItem('userid'),
137
			uname: plus.storage.getItem('name')
138
		}, "POST", function() {
139
			document.getElementById("textInputThis").value = "";
140
			document.getElementById('textInput').style.display = "none";
141
			document.getElementById('operCol').style.display = "block";
142
			self.init({
143
				sid: self.sid,
144
				stype: self.stype,
145
				time: 0,
146
				id: 0,
147
				rows: 500
148
			});
149
		})
150
	}
151
	LeaveWord.prototype.bindEvent = function() {
152
		var self = this;
153
		document.getElementsByClassName("mui-btn")[0].addEventListener("tap", function() {
154
			if(!lgin()) {
226 155
				return;
227 156
			}
228
			ajaxRequist(baseUrl + "/ajax/leavemsg/reply", {
229
				cnt: document.getElementById("textInputThis").value,
230
				id: lid,
231
				uid: plus.storage.getItem('userid'),
232
				uname: plus.storage.getItem('name')
233
			}, "POST", function(data) {
234
				document.getElementById("textInputThis").value = "";
235
				document.getElementById('textInput').style.display = "none";
236
				document.getElementById('operCol').style.display = "block";
237
				document.getElementById("textInputThis").removeAttribute("replyLword");
238
				document.getElementById("textInputThis").placeholder = "说点什么吧...";
239
				self.init({
240
					sid: self.sid,
241
					stype: self.stype,
242
					time: 0,
243
					id: 0,
244
					rows: 500
245
				});
246
				self.LwordTotal();
247
			})
248
		}
249
		LeaveWord.prototype.LwordDel = function($this, lid) {
250
			var self = this;
251
			ajaxRequist(baseUrl + "/ajax/leavemsg/del", {
252
				id: lid
253
			}, "GET", function(data) {
254
				document.getElementsByClassName("commentBlock")[0].removeChild($this.parentNode.parentNode.parentNode);
255
				self.LwordTotal();
256
			})
157
			if(document.getElementById("textInputThis").getAttribute("oid")) {
158
				self.replyLword(document.getElementById("textInputThis").getAttribute("oid"));
159
				return;
160
			}
161
			self.topLw();
162
		});
163
		mui(".commentBlock").on("tap", ".plusbtn", function() {
164
			if(!lgin()) {
165
				return;
166
			}
167
			if(this.classList.contains('icon-appreciatefill') == true) {
168
				return;
169
			}
170
			self.thub.call(this, this.getAttribute("data-id"));
171
		})
172
		mui(".commentBlock").on("tap", ".replyLew", function() {
173
			if(!lgin()) {
174
				return;
175
			}
176
			var oid = this.getAttribute("data-id")
177
			document.getElementById("operCol").style.display = "none";
178
			document.getElementById("textInput").style.display = "block";
179
			document.getElementById("textInputThis").focus();
180
			document.getElementById("textInputThis").placeholder = this.getAttribute("name");
181
			document.getElementById("textInputThis").setAttribute("oid", oid);
182
			return false;
183
		})
184
		mui("body").on("tap", ".mui-content", function() {
185
			document.getElementById("textInput").style.display = "none";
186
			document.getElementById("operCol").style.display = "block";
187
			document.getElementById("textInputThis").placeholder = "说点什么吧...";
188
			if(document.getElementById("textInputThis").getAttribute("oid")) {
189
				document.getElementById("textInputThis").removeAttribute("oid")
190
			}
191
		})
192
		mui(".commentBlock").on("tap", ".dele", function() {
193
			self.LwordDel(this, this.getAttribute("data-id"));
194
		});
195
		mui(".artfoot").on("tap", ".inputShow", function() {
196
			if(!lgin()) {
197
				return;
198
			}
199
			if(document.getElementById("textInputThis").getAttribute("oid")) {
200
				document.getElementById("textInputThis").removeAttribute("oid")
201
			}
202
			document.getElementById("textInput").style.display = "block";
203
			document.getElementById("operCol").style.display = "none";
204
			document.getElementById("textInputThis").focus();
205
		})
206
		document.getElementById("textInputThis").addEventListener("input", function() {
207
			var length = trim(this.value);
208
			if(length) {
209
				document.getElementsByClassName("mui-btn")[0].removeAttribute("disabled");
210
			} else {
211
				document.getElementsByClassName("mui-btn")[0].setAttribute("disabled", "true")
212
			}
213
		})
214
	}
215
	LeaveWord.prototype.referThup = function(lid, li, num) {
216
		ajaxRequist(baseUrl + "/ajax/leavemsg/agree", {
217
			id: lid,
218
			uid: plus.storage.getItem('userid')
219
		}, "GET", function(data) {
220
			if(data) {
221
				li.getElementsByClassName("plusbtn")[0].classList.add("icon-appreciatefill");
222
				li.getElementsByClassName("zan")[0].innerHTML = "已赞" + num;
223
			}
224
		})
225
	}
226
	LeaveWord.prototype.thub = function(lid) {
227
		var self = this;
228
		ajaxRequist(baseUrl + "/ajax/leavemsg/agree", {
229
			id: lid,
230
			uid: plus.storage.getItem('userid'),
231
			uname: plus.storage.getItem('name')
232
		}, "POST", function(data) {
233
			self.classList.add("icon-appreciatefill");
234
			self.nextElementSibling.innerHTML = "已赞" + (Number(self.getAttribute("data-num")) + 1);
235
			self.nextElementSibling.style.display = "inline-block";
236
		})
237
	}
238
	LeaveWord.prototype.replyLword = function(lid) {
239
		var self = this;
240
		if(!self.size) {
241
			return;
257 242
		}
258
		LeaveWord.prototype.LwordTotal = function() {
259
			var self = this;
260
			ajaxRequist(baseUrl + "/ajax/leavemsg/count", {
243
		ajaxRequist(baseUrl + "/ajax/leavemsg/reply", {
244
			cnt: document.getElementById("textInputThis").value,
245
			id: lid,
246
			uid: plus.storage.getItem('userid'),
247
			uname: plus.storage.getItem('name')
248
		}, "POST", function(data) {
249
			document.getElementById("textInputThis").value = "";
250
			document.getElementById('textInput').style.display = "none";
251
			document.getElementById('operCol').style.display = "block";
252
			document.getElementById("textInputThis").removeAttribute("oid");
253
			document.getElementById("textInputThis").placeholder = "说点什么吧...";
254
			self.init({
261 255
				sid: self.sid,
262
				stype: self.stype
263
			}, "get", function($data) {
264
				if($data > 0) {
265
					document.getElementsByClassName('mui-badge')[0].innerHTML = $data;
266
				}
267
			})
268
		}
269

270
		var module = {
271
			lWord: function(sid, stype) {
272
				this.sid = sid;
273
				this.stype = stype;
274
				var lw = new LeaveWord();
256
				stype: self.stype,
257
				time: 0,
258
				id: 0,
259
				rows: 500
260
			});
261
			self.LwordTotal();
262
		})
263
	}
264
	LeaveWord.prototype.LwordDel = function($this, lid) {
265
		var self = this;
266
		ajaxRequist(baseUrl + "/ajax/leavemsg/del", {
267
			id: lid
268
		}, "GET", function(data) {
269
			document.getElementsByClassName("commentBlock")[0].removeChild($this.parentNode.parentNode.parentNode);
270
			self.LwordTotal();
271
		})
272
	}
273
	LeaveWord.prototype.LwordTotal = function() {
274
		var self = this;
275
		ajaxRequist(baseUrl + "/ajax/leavemsg/count", {
276
			sid: self.sid,
277
			stype: self.stype
278
		}, "get", function($data) {
279
			if($data > 0) {
280
				document.getElementsByClassName('mui-badge')[0].innerHTML = $data;
275 281
			}
282
		})
283
	}
284

285
	var module = {
286
		lWord: function(sid, stype) {
287
			this.sid = sid;
288
			this.stype = stype;
289
			var lw = new LeaveWord();
290
			this.init = lw.init;
276 291
		}
277
		module.lWord(plus.webview.currentWebview().articleId, 1);
278
	})
279
})
292
	}
293
	window.module = module;
294
})(window)

+ 3 - 150
app/js/paperShow.js

@ -9,6 +9,7 @@ mui.plusReady(function() {
9 9
	//paperId="FF6EFFA4D7474CC7B808D9BC08E88E79";
10 10
	getRecourceMe(); /*获取资源信息*/
11 11
	//关键词标签点击进去搜索
12
	module.lWord(paperId, 2);
12 13
	mui(".tagList").on("tap", "li", function() {
13 14
		var tagText = this.getElementsByTagName("span")[0].innerText;
14 15
		plus.nativeUI.showWaiting();
@ -255,6 +256,7 @@ mui.plusReady(function() {
255 256
		userid = plus.storage.getItem('userid');
256 257
		getRecourceMe();
257 258
		ifcollectionAbout(paperId,oifCollect, 5);
259
		module.init.init();
258 260
	});
259 261
260 262
	function leadIn(sel) {
@ -687,157 +689,8 @@ function addAgree() {
687 689
		}
688 690
	});
689 691
}
690
mui(".artfoot").on("tap", ".inputShow", function() {
691
	
692
		if(!isLogin()) {
693
			document.getElementById("textInput").style.display = "block";
694
			document.getElementById("operCol").style.display = "none";
695
			document.getElementById("textInputThis").focus();
696
		}
697
		
698
	})
699
leword();
700 692
701
mmentBlock').on('tap', '.useHead', function leword() {
702
		var data = {"paperId": paperId,"rows": 500}	
703
		mui.ajax(baseUrl + "/ajax/leaveWord/ql/paper", {
704
			data: data,
705
			dataType: 'json', //服务器返回json格式数据
706
			type: 'get', //HTTP请求类型
707
			timeout: 10000, //超时时间设置为10秒;
708
			traditional: true,
709
			success: function(data) {
710
				if(data.success) {
711
					document.getElementsByClassName('commentBlock')[0].innerHTML = ""
712
					if(data.data.length == 0) {
713
						return;
714
					}
715
					var id = plus.storage.getItem('userid');
716
					for(var i = 0; i < data.data.length; i++) {
717
						var oText = ""
718
						if(id == data.data[i].professor.id) {
719
							oText = "删除"
720
						}
721
						var userType = autho(data.data[i].professor.authType, data.data[i].professor.orgAuth, data.data[i].professor.authStatus);
722
						var baImg = "../images/default-photo.jpg";
723
						if(data.data[i].professor.hasHeadImage == 1) {
724
							baImg = baseUrl + "/images/head/" + data.data[i].professor.id + "_l.jpg";
725
						}
726
						var li = document.createElement("li");
727
						li.className = "mui-table-view-cell";
728
						li.innerHTML = '<div class="flexCenter mui-clearfix">' +
729
							'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')" data-id="' + data.data[i].professor.id + '"></div>' +
730
							'<div class="madiaInfo">' +
731
							'<p><span class="h1Font" data-id="' + data.data[i].professor.id + '">' + data.data[i].professor.name + '</span><em class="authicon ' + userType.sty + '" title="科袖认证专家"></em></p>' +
732
							'</div>' +
733
							'</div>' +
734
							'<div class="madiaInfo">' +
735
							'<p class="h2Font">' + data.data[i].content + '</p>' +
736
							'<p class="operateSpan">' +
737
							'<span class="commenttime">' + commenTime(data.data[i].createTime) + '</span>' +
738
							'<span data-id="' + data.data[i].id + '" class="dele">' + oText + '</span>' +
739
							'</p>' +
740
							'</div>'
741
						document.getElementsByClassName("commentBlock")[0].appendChild(li);
742
					}
743
744
				} else {
745
				}
746
			},
747
			error: function(xhr, type, errorThrown) {
748
				//异常处理;
749
				plus.nativeUI.toast("服务器链接超时", toastStyle);
750
			}
751
		});
752
}
753
lewordNum();
754
function lewordNum() {
755
		var data = {"paperId": paperId}	
756
		mui.ajax(baseUrl + "/ajax/leaveWord/lwCount/paper", {
757
			data: data,
758
			dataType: 'json', //服务器返回json格式数据
759
			type: 'get', //HTTP请求类型
760
			timeout: 10000, //超时时间设置为10秒;
761
			traditional: true,
762
			success: function(data) {
763
				if(data.success) {
764
					if(data.data > 0) {
765
						document.getElementsByClassName("mui-badge")[0].innerHTML = data.data;
766
					}
767
				}
768
769
				
770
			},
771
			error: function(xhr, type, errorThrown) {
772
				//异常处理;
773
				plus.nativeUI.toast("服务器链接超时", toastStyle);
774
			}
775
		});
776
}
777
function trim(str) { //删除左右两端的空格
778
		  
779
		return str.replace(/(^\s*)|(\s*$)/g, "");  
780
	}
781
document.getElementById("textInputThis").addEventListener("input", function() {
782
		var length = trim(this.value);
783
		if(length) {
784
			document.getElementsByClassName("mui-btn")[0].removeAttribute("disabled");
785
		} else {
786
			document.getElementsByClassName("mui-btn")[0].setAttribute("disabled", "true")
787
		}
788
	})
789
document.getElementsByClassName("mui-btn")[0].addEventListener("tap", function() {
790
	if(document.getElementById("textInputThis").value.length>200) {
791
				plus.nativeUI.toast("留言不得超过200个字", toastStyle);
792
				return;
793
			}
794
		mui.ajax(baseUrl + "/ajax/leaveWord/paper", {
795
			data: {
796
				"paperId": paperId,
797
				"sender": plus.storage.getItem('userid'),
798
				"content": document.getElementById("textInputThis").value
799
			},
800
			dataType: 'json', //服务器返回json格式数据
801
			type: 'post', //HTTP请求类型
802
			timeout: 10000, //超时时间设置为10秒;
803
			success: function(data) {
804
				if(data.success) {
805
					document.getElementById("textInputThis").value = "";
806
					document.getElementById('textInput').style.display = "none";
807
					document.getElementById('operCol').style.display = "block";
808
					leword();
809
					lewordNum();
810
				}
811
			},
812
			error: function() {
813
				//异常处理;
814
				plus.nativeUI.toast("服务器链接超时", toastStyle);
815
			}
816
		});
817
	})
818
mui(".commentBlock").on("tap", ".dele", function() {
819
		var $this = this;
820
		mui.ajax(baseUrl + "/ajax/leaveWord/delete", {
821
			data: {
822
				"id": this.getAttribute("data-id"),
823
			},
824
			dataType: 'json', //服务器返回json格式数据
825
			type: 'post', //HTTP请求类型
826
			timeout: 10000, //超时时间设置为10秒;
827
			success: function(data) {
828
				if(data.success) {
829
					document.getElementsByClassName("commentBlock")[0].removeChild($this.parentNode.parentNode.parentNode);
830
					leword();
831
					lewordNum();
832
				}
833
			},
834
			error: function(xhr, type, errorThrown) {
835
				//异常处理;
836
				plus.nativeUI.toast("服务器链接超时", toastStyle);
837
			}
838
		});
839
	})
840
mui('.commentBlock').on('tap', '.useHead,.h1Font', function() {
693
mui('.commentBlock').on('tap', '.useHead', function() {
841 694
		var id = this.getAttribute("data-id");
842 695
		plus.nativeUI.showWaiting(); //显示原生等待框
843 696
		plus.webview.create("../html/userInforShow.html", 'userInforShow.html', {}, {

+ 3 - 153
app/js/patentShow.js

@ -7,6 +7,7 @@ mui.plusReady(function() {
7 7
	var userName = plus.storage.getItem('name');
8 8
	patentId = self.patentId;
9 9
	getRecourceMe();/*获取资源信息*/
10
	module.lWord(patentId, 3);
10 11
	//关键词标签点击进去搜索
11 12
	mui(".tagList").on("tap","li",function(){
12 13
		var tagText = this.getElementsByTagName("span")[0].innerText;
@ -253,6 +254,7 @@ mui.plusReady(function() {
253 254
		getRecourceMe();
254 255
		ifcollectionAbout(patentId,oifCollect,4);
255 256
		isAgree();
257
		module.init.init();
256 258
	});
257 259
	function leadIn(sel) {
258 260
		mui.ajax(baseUrl + "/ajax/ppatent/ass", {
@ -662,159 +664,7 @@ function addAgree() {
662 664
		}
663 665
	});
664 666
}
665
mui(".artfoot").on("tap", ".inputShow", function() {
666
	
667
		if(!isLogin()) {
668
			document.getElementById("textInput").style.display = "block";
669
			document.getElementById("operCol").style.display = "none";
670
			document.getElementById("textInputThis").focus();
671
		}
672
		
673
	})
674
leword();
675
676
function leword() {
677
		var data = {"patentId": patentId,"rows": 500}	
678
		mui.ajax(baseUrl + "/ajax/leaveWord/ql/patent", {
679
			data: data,
680
			dataType: 'json', //服务器返回json格式数据
681
			type: 'get', //HTTP请求类型
682
			timeout: 10000, //超时时间设置为10秒;
683
			traditional: true,
684
			success: function(data) {
685
				console.log(JSON.stringify(data))
686
				if(data.success) {
687
					document.getElementsByClassName('commentBlock')[0].innerHTML = ""
688
					if(data.data.length == 0) {
689
						return;
690
					}
691
					var id = plus.storage.getItem('userid');
692
					for(var i = 0; i < data.data.length; i++) {
693
						var oText = ""
694
						if(id == data.data[i].professor.id) {
695
							oText = "删除"
696
						}
697
						var userType = autho(data.data[i].professor.authType, data.data[i].professor.orgAuth, data.data[i].professor.authStatus);
698
						var baImg = "../images/default-photo.jpg";
699
						if(data.data[i].professor.hasHeadImage == 1) {
700
							baImg = baseUrl + "/images/head/" + data.data[i].professor.id + "_l.jpg";
701
						}
702
						var li = document.createElement("li");
703
						li.className = "mui-table-view-cell";
704
						li.innerHTML = '<div class="flexCenter mui-clearfix">' +
705
							'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')" data-id="' + data.data[i].professor.id + '"></div>' +
706
							'<div class="madiaInfo">' +
707
							'<p><span class="h1Font" data-id="' + data.data[i].professor.id + '">' + data.data[i].professor.name + '</span><em class="authicon ' + userType.sty + '" title="科袖认证专家"></em></p>' +
708
							'</div>' +
709
							'</div>' +
710
							'<div class="madiaInfo">' +
711
							'<p class="h2Font">' + data.data[i].content + '</p>' +
712
							'<p class="operateSpan">' +
713
							'<span class="commenttime">' + commenTime(data.data[i].createTime) + '</span>' +
714
							'<span data-id="' + data.data[i].id + '" class="dele">' + oText + '</span>' +
715
							'</p>' +
716
							'</div>'
717
						document.getElementsByClassName("commentBlock")[0].appendChild(li);
718
					}
719
720
				} else {
721
				}
722
			},
723
			error: function(xhr, type, errorThrown) {
724
				//异常处理;
725
				plus.nativeUI.toast("服务器链接超时", toastStyle);
726
			}
727
		});
728
}
729
lewordNum();
730
function lewordNum() {
731
		var data = {"patentId": patentId}	
732
		mui.ajax(baseUrl + "/ajax/leaveWord/lwCount/patent", {
733
			data: data,
734
			dataType: 'json', //服务器返回json格式数据
735
			type: 'get', //HTTP请求类型
736
			timeout: 10000, //超时时间设置为10秒;
737
			traditional: true,
738
			success: function(data) {
739
				if(data.success) {
740
					if(data.data > 0) {
741
						document.getElementsByClassName("mui-badge")[0].innerHTML = data.data;
742
					}
743
				
744
				}
745
746
				
747
			},
748
			error: function(xhr, type, errorThrown) {
749
				//异常处理;
750
				plus.nativeUI.toast("服务器链接超时", toastStyle);
751
			}
752
		});
753
}
754
function trim(str) { //删除左右两端的空格
755
		  
756
		return str.replace(/(^\s*)|(\s*$)/g, "");  
757
	}
758
document.getElementById("textInputThis").addEventListener("input", function() {
759
		var length = trim(this.value);
760
		if(length) {
761
			document.getElementsByClassName("mui-btn")[0].removeAttribute("disabled");
762
		} else {
763
			document.getElementsByClassName("mui-btn")[0].setAttribute("disabled", "true")
764
		}
765
	})
766
document.getElementsByClassName("mui-btn")[0].addEventListener("tap", function() {
767
	if(document.getElementById("textInputThis").value.length>200) {
768
				plus.nativeUI.toast("留言不得超过200个字", toastStyle);
769
				return;
770
			}
771
		mui.ajax(baseUrl + "/ajax/leaveWord/patent", {
772
			data: {
773
				"patentId": patentId,
774
				"sender": plus.storage.getItem('userid'),
775
				"content": document.getElementById("textInputThis").value
776
			},
777
			dataType: 'json', //服务器返回json格式数据
778
			type: 'post', //HTTP请求类型
779
			timeout: 10000, //超时时间设置为10秒;
780
			success: function(data) {
781
				if(data.success) {
782
					document.getElementById("textInputThis").value = "";
783
					document.getElementById('textInput').style.display = "none";
784
					document.getElementById('operCol').style.display = "block";
785
					leword();
786
					lewordNum();
787
				}
788
			},
789
			error: function() {
790
				//异常处理;
791
				plus.nativeUI.toast("服务器链接超时", toastStyle);
792
			}
793
		});
794
	})
795
mui(".commentBlock").on("tap", ".dele", function() {
796
		var $this = this;
797
		mui.ajax(baseUrl + "/ajax/leaveWord/delete", {
798
			data: {
799
				"id": this.getAttribute("data-id"),
800
			},
801
			dataType: 'json', //服务器返回json格式数据
802
			type: 'post', //HTTP请求类型
803
			timeout: 10000, //超时时间设置为10秒;
804
			success: function(data) {
805
				if(data.success) {
806
					document.getElementsByClassName("commentBlock")[0].removeChild($this.parentNode.parentNode.parentNode);
807
					leword();
808
					lewordNum();
809
				}
810
			},
811
			error: function(xhr, type, errorThrown) {
812
				//异常处理;
813
				plus.nativeUI.toast("服务器链接超时", toastStyle);
814
			}
815
		});
816
	})
817
mui('.commentBlock').on('tap', '.useHead,.h1Font', function() {
667
mui('.commentBlock').on('tap', '.useHead', function() {
818 668
		var id = this.getAttribute("data-id");
819 669
		plus.nativeUI.showWaiting(); //显示原生等待框
820 670
		plus.webview.create("../html/userInforShow.html", 'userInforShow.html', {}, {