Browse Source

发现修复

luyanan 7 years ago
parent
commit
e7e20f87c7
2 changed files with 119 additions and 114 deletions
  1. 4 4
      app/html/discoverNew.html
  2. 115 110
      app/js/discoverNew.js

+ 4 - 4
app/html/discoverNew.html

@ -59,7 +59,7 @@
59 59
				margin-left:5px;
60 60
			}
61 61
			.mui-pull-top-wrapper .mui-icon.mui-reverse {
62
				/*-webkit-transform: rotate(180deg) translateZ(0);*/
62
				-webkit-transform: rotate(180deg) translateZ(0);
63 63
			}
64 64
			.mui-pull-bottom-tips {
65 65
				text-align: center;
@ -111,7 +111,7 @@
111 111
			<div id="slider" class="mui-slider mui-fullscreen">
112 112
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
113 113
					<div class="mui-scroll">
114
						<a class="mui-control-item  mui-active" href="#item1mobile">最新文章</a>
114
						<a class="mui-control-item  mui-active" href="#item1mobile" flag="1">最新文章</a>
115 115
						<a class="mui-control-item" href="#item2mobile">前沿动态</a>
116 116
						<a class="mui-control-item" href="#item3mobile">学术经验</a>
117 117
						<a class="mui-control-item" href="#item4mobile">检测分析</a>
@ -124,9 +124,9 @@
124 124
				
125 125
			
126 126
				<div class="mui-slider-group">
127
					<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
127
					<div id="item1mobile" class="mui-slider-item mui-control-content mui-active" >
128 128
						<div id="scroll1" class="mui-scroll-wrapper">
129
							<div class="mui-scroll" id="dd">
129
							<div class="mui-scroll" id="dd" >
130 130
							<div id="slider1" class="mui-slider">
131 131
								</div>
132 132
								<ul class="mui-table-view" id="list">

+ 115 - 110
app/js/discoverNew.js

@ -1,15 +1,15 @@
1 1
(function($) {
2
//阻尼系数
3
var key1 = [];
4
var m = 0;
5
var deceleration = mui.os.ios ? 0.003 : 0.0009;
6
$('.mui-scroll-wrapper').scroll({
7
	bounce: false,
8
	indicators: true, //是否显示滚动条
9
	deceleration: deceleration
10
});
11
$.ready(function() {
12
	$.plusReady(function() {
2
	//阻尼系数
3
	var key1 = [];
4
	var m = 0;
5
	var deceleration = mui.os.ios ? 0.003 : 0.0009;
6
	$('.mui-scroll-wrapper').scroll({
7
		bounce: false,
8
		indicators: true, //是否显示滚动条
9
		deceleration: deceleration
10
	});
11
	$.ready(function() {
12
		$.plusReady(function() {
13 13
			var columnType = {
14 14
				"1": {
15 15
					fullName: "个人原创",
@ -117,22 +117,24 @@ $.ready(function() {
117 117
						key1[index] = $(pullRefreshEl).pullToRefresh({
118 118
							down: {
119 119
								callback: function() {
120
									
120 121
									var self = this;
121
									self.refresh(true);
122
									//self.refresh(true);
122 123
									setTimeout(function() {
123 124
										var ul = self.element.querySelector('.mui-table-view');
124 125
										ul.innerHTML = "";
126
										key1[m].endPullUpToRefresh(true);
125 127
										if(index == 0) {
126 128
											_this.pageNo.a = 1;
127 129
											_this.colum.a = ""
128
											$D({
129
												"fun": ob.createFragment,
130
												data: {
131
													col: 9,
132
													pageNo: 1
133
												},
134
												flag: 1,
135
												url: "/ajax/article/find"
130
											$D({
131
												"fun": ob.createFragment,
132
												data: {
133
													col: 9,
134
													pageNo: 1
135
												},
136
												flag: 1,
137
												url: "/ajax/article/find"
136 138
											});
137 139
										} else {
138 140
											_this.pageNo[index] = 1;
@ -153,6 +155,7 @@ $.ready(function() {
153 155
154 156
							},
155 157
							up: {
158
								
156 159
								callback: function() {
157 160
									var self = this;
158 161
									setTimeout(function() {
@ -216,92 +219,95 @@ $.ready(function() {
216 219
					}
217 220
				},
218 221
				createFragment: function(data) {
222
					//alert(JSON.stringify(data))
219 223
					if(data.success) {
220
					if(!arguments[1]) {
221
						document.getElementsByClassName("nodatabox")[m].classList.add("displayNone");
222
						if(data.data.data.length == 0) {
223
							document.getElementsByClassName("nodatabox")[m].classList.remove("displayNone");
224
							key1[m].endPullUpToRefresh(true);
225
							return;
226
						}
227
						if(data.data.pageNo < Math.ceil(data.data.total / data.data.pageSize)) {
228
							key1[m].endPullUpToRefresh(false);
229
						} else {
230
							key1[m].endPullUpToRefresh(true);
231
						}
232
					}
224
						
233 225
234
					var $data = data.data.data;
235
					if(arguments[1]) {
236
						if($data.length > 1) {
237
							$data.length = 1;
238
						}
239
					}
240
					for(var i = 0; i < $data.length; i++) {
241
						var of ;
242
						if($data[i].articleType == 1) { of = 1;
243
						} else { of = 2;
244
						}
245
						var arImg = "../images/default-artical.jpg";
246
						if($data[i].articleImg) {
247
							arImg = baseUrl + "/data/article/" + $data[i].articleImg
226
						var $data = data.data.data;
227
						if(arguments[1]) {
228
							if($data.length > 1) {
229
								$data.length = 1;
230
							}
248 231
						}
249
						var title = $data[i].articleTitle;
250
						var colSpan = "";
251
						if(m == 0) {
252
							if(arguments[1]) {
253
								colSpan = "<span style='border:1px solid red;border-radius:3px;padding:0px 1px;margin-right:5px;color:red;'>置顶</span>"
254
							} else {
255
								if($data[i].colNum != 0)
256
									colSpan = "<span style='border:1px solid green;border-radius:3px;padding:0px 1px;margin-right:5px;color:green;'>" + columnType[$data[i].colNum].shortName + "</span>"
232
						for(var i = 0; i < $data.length; i++) {
233
							var of ;
234
							if($data[i].articleType == 1) { of = 1;
235
							} else { of = 2;
236
							}
237
							var arImg = "../images/default-artical.jpg";
238
							if($data[i].articleImg) {
239
								arImg = baseUrl + "/data/article/" + $data[i].articleImg
257 240
							}
241
							var title = $data[i].articleTitle;
242
							var colSpan = "";
243
							if(m == 0) {
244
								if(arguments[1]) {
245
									colSpan = "<span style='border:1px solid red;border-radius:3px;padding:0px 1px;margin-right:5px;color:red;'>置顶</span>"
246
								} else {
247
									if($data[i].colNum != 0)
248
										colSpan = "<span style='border:1px solid green;border-radius:3px;padding:0px 1px;margin-right:5px;color:green;'>" + columnType[$data[i].colNum].shortName + "</span>"
249
								}
258 250
259
						}
260
						var li = document.createElement("li");
261
						li.setAttribute("data-id", $data[i].articleId);
262
						li.setAttribute("data-flag", 3);
263
						li.className = "mui-table-view-cell";
264
						li.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
265
							'<div class="madiaHead artHead" style="background-image:url(' + arImg + ')"></div>' +
266
							'<div class="madiaInfo OmadiaInfo">' +
267
							'<p class="mui-ellipsis-2 h1Font">' + title + '</p>' +
268
							'<p class="h2Font mui-ellipsis">' + colSpan +
269
							'<span class="nameSpan" style="margin-right:10px"></span>' +
270
							'<span class="time">' + commenTime($data[i].publishTime) + '</span>' +
271
							'</p>' +
272
							'</div>' +
273
							'</div>'
274
						if(arguments[1]) {
275
							if(document.getElementsByTagName("ul")[m].children[0]) {
276
								document.getElementsByTagName("ul")[m].insertBefore(li, document.getElementsByTagName("ul")[m].children[0])
251
							}
252
							var li = document.createElement("li");
253
							li.setAttribute("data-id", $data[i].articleId);
254
							li.setAttribute("data-flag", 3);
255
							li.className = "mui-table-view-cell";
256
							li.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
257
								'<div class="madiaHead artHead" style="background-image:url(' + arImg + ')"></div>' +
258
								'<div class="madiaInfo OmadiaInfo">' +
259
								'<p class="mui-ellipsis-2 h1Font">' + title + '</p>' +
260
								'<p class="h2Font mui-ellipsis">' + colSpan +
261
								'<span class="nameSpan" style="margin-right:10px"></span>' +
262
								'<span class="time">' + commenTime($data[i].publishTime) + '</span>' +
263
								'</p>' +
264
								'</div>' +
265
								'</div>'
266
							if(arguments[1]) {
267
								if(document.getElementsByTagName("ul")[m].children[0]) {
268
									document.getElementsByTagName("ul")[m].insertBefore(li, document.getElementsByTagName("ul")[m].children[0])
269
								} else {
270
									document.getElementsByTagName("ul")[m].appendChild(li);
271
								}
277 272
							} else {
278 273
								document.getElementsByTagName("ul")[m].appendChild(li);
279 274
							}
280
						} else {
281
							document.getElementsByTagName("ul")[m].appendChild(li);
275
							if( of == 1) {
276
								li.setAttribute("owner-id", $data[i].professorId);
277
								li.setAttribute("data-type", 1);
278
								$D({
279
									data: {},
280
									fun: ob.proName,
281
									url: "/ajax/professor/editBaseInfo/" + $data[i].professorId,
282
									sele: li.getElementsByClassName("nameSpan")[0]
283
								});
284
							} else {
285
								li.setAttribute("owner-id", $data[i].orgId);
286
								li.setAttribute("data-type", 2);
287
								$D({
288
									data: {},
289
									fun: ob.orgName,
290
									url: "/ajax/org/" + $data[i].orgId,
291
									sele: li.getElementsByClassName("nameSpan")[0]
292
								});
293
							}
282 294
						}
283
						if( of == 1) {
284
							li.setAttribute("owner-id", $data[i].professorId);
285
							li.setAttribute("data-type", 1);
286
							$D({
287
								data: {},
288
								fun: ob.proName,
289
								url: "/ajax/professor/editBaseInfo/" + $data[i].professorId,
290
								sele: li.getElementsByClassName("nameSpan")[0]
291
							});
292
						} else {
293
							li.setAttribute("owner-id", $data[i].orgId);
294
							li.setAttribute("data-type", 2);
295
							$D({
296
								data: {},
297
								fun: ob.orgName,
298
								url: "/ajax/org/" + $data[i].orgId,
299
								sele: li.getElementsByClassName("nameSpan")[0]
300
							});
295
						if(!arguments[1]) {
296
							document.getElementsByClassName("nodatabox")[m].classList.add("displayNone");
297
							if(data.data.data.length == 0) {
298
								document.getElementsByClassName("nodatabox")[m].classList.remove("displayNone");
299
								key1[m].endPullUpToRefresh(true);
300
								return;
301
							}
302
							if(data.data.pageNo < Math.ceil(data.data.total / data.data.pageSize)) {
303
								key1[m].refresh(true);
304
								key1[m].endPullUpToRefresh(false);
305
							} else {
306
								key1[m].endPullUpToRefresh(true);
307
							}
301 308
						}
302 309
					}
303 310
				}
304
					}
305 311
			}
306 312
			Discover.prototype.Init.prototype = Discover.prototype;
307 313
			var $D = Discover;
@ -316,14 +322,14 @@ $.ready(function() {
316 322
				},
317 323
				url: "/ajax/article/find"
318 324
			});
319
			$D({
320
				"fun": ob.createFragment,
321
				data: {
322
					col: 9,
323
					pageNo: 1
324
				},
325
				flag: 1,
326
				url: "/ajax/article/find"
325
			$D({
326
				"fun": ob.createFragment,
327
				data: {
328
					col: 9,
329
					pageNo: 1
330
				},
331
				flag: 1,
332
				url: "/ajax/article/find"
327 333
			});
328 334
			document.querySelector('#slider').addEventListener('slide', function(event) {
329 335
@ -357,7 +363,7 @@ $.ready(function() {
357 363
					});
358 364
				}
359 365
			})
360
			$.ajax(baseUrl + "/data/inc/col_bannerApp.html?ttt=" +new Date().getTime(), {
366
			$.ajax(baseUrl + "/data/inc/col_bannerApp.html?ttt=" + new Date().getTime(), {
361 367
				dataType: 'html', //服务器返回json格式数据
362 368
				type: "get", //HTTP请求类型
363 369
				timeout: 10000, //超时时间设置为10秒;
@ -372,7 +378,7 @@ $.ready(function() {
372 378
					$("#slider1").on("tap", "a", function() {
373 379
						plus.nativeUI.showWaiting();
374 380
						var id = this.parentNode.getAttribute("data-id");
375
						var col=this.parentNode.getAttribute("col-id");
381
						var col = this.parentNode.getAttribute("col-id");
376 382
						aiticl(id)
377 383
						addClick1(col);
378 384
					})
@ -393,10 +399,9 @@ $.ready(function() {
393 399
					traditional: true,
394 400
					async: true,
395 401
					success: function(data) {
396
						if(data.success) {
397
						}
402
						if(data.success) {}
398 403
					}
399
					});
404
				});
400 405
			}
401 406
402 407
			function aiticl(id) {
@ -433,7 +438,7 @@ $.ready(function() {
433 438
						plus.nativeUI.toast("服务器链接超时", toastStyle);
434 439
					}
435 440
				});
436
	}
437
})
438
})
441
			}
442
		})
443
	})
439 444
})(mui)