jack 8 年 前
コミット
35c386708b
共有2 個のファイルを変更した175 個の追加119 個の削除を含む
  1. 2 2
      app/html/professorArticle.html
  2. 173 117
      app/js/articleShow.js

+ 2 - 2
app/html/professorArticle.html

@ -48,7 +48,7 @@
48 48
		    		<div class="h1Font hWeight" id="articleName"></div>
49 49
		    		<div class="madiaBlock">
50 50
		    			<ul class="mui-table-view noactiveTab" style="margin:0 -15px;">
51
					        <li class="mui-table-view-cell">
51
					        <li class="mui-table-view-cell" id="personAL">
52 52
					            <div class="flexCenter mui-clearfix">
53 53
					                <div class="madiaHead useHead" id="messImg"></div>
54 54
									<div class="madiaInfo">
@ -91,7 +91,7 @@
91 91
					</div>
92 92
					<!--留言-->
93 93
					<div class="madiaBlock mui-scroll">
94
						<div class="madiaTit">留言</div>
94
						<div class="madiaTit" id="title">留言</div>
95 95
						<ul class="mui-table-view mui-table-view-chevron commentBlock noactiveTab">
96 96
					       
97 97
					   </ul>

+ 173 - 117
app/js/articleShow.js

@ -12,14 +12,15 @@ mui.init({
12 12

13 13
function pullupRefresh() {
14 14
	setTimeout(function() {
15
		leword(1,0);
15
		leword(1, 0);
16 16
	}, 1000);
17 17
}
18 18
leword(1, 1);
19 19

20
function leword(row,aa) {
20
function leword(row, aa) {
21 21
	mui.plusReady(function() {
22
		var af=aa;
22
		var af = aa,
23
			stt;
23 24
		var obj = {};
24 25
		obj.articleId = plus.webview.currentWebview().articleId;
25 26
		obj.createTime = createTime;
@ -34,18 +35,18 @@ function leword(row,aa) {
34 35
			success: function(data) {
35 36
				if(data.success) {
36 37
					if(af == 1) {
37
						document.getElementsByClassName('commentBlock')[0].innerHTML=""
38
						document.getElementsByClassName('commentBlock')[0].innerHTML = ""
38 39
						if(data.data.length == 0) {
39 40
							mui('#pullrefresh').pullRefresh().disablePullupToRefresh(true);
40 41
							return;
41 42
						}
42
					}else{
43
					} else {
43 44
						if(data.data.length == 0) {
44 45
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
45 46
							return;
46 47
						}
47 48
					}
48
					var id=plus.storage.getItem('userid');
49
					var id = plus.storage.getItem('userid');
49 50
					createTime = data.data[data.data.length - 1].createTime;
50 51
					orderKey = data.data[data.data.length - 1].orderKey;
51 52
					if(data.data.length == row) {
@ -54,9 +55,9 @@ function leword(row,aa) {
54 55
						mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
55 56
					}
56 57
					for(var i = 0; i < data.data.length; i++) {
57
						var oText=""
58
						if(id==data.data[i].professor.id) {
59
							oText="删除"
58
						var oText = ""
59
						if(id == data.data[i].professor.id) {
60
							oText = "删除"
60 61
						}
61 62
						var userType = autho(data.data[i].professor.authType, data.data[i].professor.orgAuth, data.data[i].professor.authStatus);
62 63
						var baImg = "../images/default-photo.jpg";
@ -64,7 +65,8 @@ function leword(row,aa) {
64 65
							baImg = baseUrl + "/images/head/" + data.data[i].professor.id + "_l.jpg";
65 66
						}
66 67
						var li = document.createElement("li");
67
						li.className = "mui-table-view-cell"
68
						li.className = "mui-table-view-cell";
69
						li.setAttribute("data-id", data.data[i].professor.id)
68 70
						li.innerHTML = '<div class="flexCenter mui-clearfix">' +
69 71
							'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')"></div>' +
70 72
							'<div class="madiaInfo">' +
@ -75,7 +77,7 @@ function leword(row,aa) {
75 77
							'<p class="h2Font">' + data.data[i].content + '</p>' +
76 78
							'<p class="operateSpan">' +
77 79
							'<span class="commenttime">' + oTime.publish(data.data[i].createTime) + '</span>' +
78
							'<span data-id="'+data.data[i].id+'" class="dele">'+oText+'</span>' +
80
							'<span data-id="' + data.data[i].id + '" class="dele">' + oText + '</span>' +
79 81
							'</p>' +
80 82
							'</div>'
81 83
						document.getElementsByClassName("commentBlock")[0].appendChild(li);
@ -164,8 +166,8 @@ mui.plusReady(function() {
164 166
				success: function(data) {
165 167
					if(data.success) {
166 168
						oFun(data.data);
167
					}else{
168
						
169
					} else {
170

169 171
					}
170 172
				},
171 173
				error: function(xhr, type, errorThrown) {
@ -179,6 +181,8 @@ mui.plusReady(function() {
179 181
			plus.webview.currentWebview().show("slide-in-right", 150);
180 182
			//console.log(JSON.stringify($data));
181 183
			document.getElementById("articleName").innerHTML = $data.articleTitle;
184
			stt = $data.articleImg.substring(0, 9);
185
			console.log(stt)
182 186
			if($data.articleContent) {
183 187
				//document.getElementById("articleContent").style.display="block";
184 188
				document.getElementById("articleContent").innerHTML = $data.articleContent;
@ -228,6 +232,34 @@ mui.plusReady(function() {
228 232
			}
229 233
			if($data.authStatus == 3) {
230 234
				document.getElementById("auth").classList.add("authicon-com-ok");
235
				mui('#personAL').on('tap', '#messImg,#name', function() {
236
					mui.openWindow({
237
						url: '../html/cmpinfor-index.html',
238
						id: 'cmpinfor-index.html',
239
						show: {
240
							autoShow: false,
241
							aniShow: "slide-in-right",
242
						},
243
						extras: {
244
							orgId: oArticleModule.oWner,
245
						}
246
					});
247
				})
248
			} else {
249
				mui('#personAL').on('tap', '#messImg,#name', function() {
250
					mui.openWindow({
251
						url: '../html/cmpinfor-Unindex.html',
252
						id: 'cmpinfor-Unindex.html',
253
						show: {
254
							autoShow: false,
255
							aniShow: "slide-in-right",
256
						},
257
						extras: {
258
							orgId: oArticleModule.oWner,
259
							flag: 0,
260
						}
261
					});
262
				})
231 263
			}
232 264
		},
233 265
		correlationExpert: function($data) {
@ -271,6 +303,7 @@ mui.plusReady(function() {
271 303
			var userType = autho($data.authType, $data.orgAuth, $data.authStatus);
272 304
			var li = document.createElement("li");
273 305
			li.className = "mui-table-view-cell";
306
			li.setAttribute("data-id", $data.id);
274 307
			li.innerHTML = '<div class="flexCenter mui-clearfix">' +
275 308
				'<div class="madiaHead useHead" style="background-image:url(' + baImg + ')"></div>' +
276 309
				'<div class="madiaInfo">' +
@ -294,7 +327,6 @@ mui.plusReady(function() {
294 327

295 328
		},
296 329
		rsourceList: function($data) {
297
			//console.log(JSON.stringify($data));
298 330
			var namepo, userType;
299 331
			if($data.resourceType == 1) {
300 332
				namepo = $data.editProfessor.name;
@ -310,6 +342,7 @@ mui.plusReady(function() {
310 342
			}
311 343
			var rImg = baseUrl + "/data/resource/" + $data.images[0].imageSrc;
312 344
			var li = document.createElement("li");
345
			li.setAttribute("data-id", $data.resourceId);
313 346
			li.className = "mui-table-view-cell";
314 347
			li.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
315 348
				' <div class="madiaHead resouseHead" style="background-image:url(' + rImg + ')"></div>' +
@ -322,6 +355,7 @@ mui.plusReady(function() {
322 355
			document.getElementById("resourceList").appendChild(li);
323 356
		},
324 357
		correlationArticle: function($data) {
358

325 359
			if($data.length == 0) {
326 360
				return;
327 361
			}
@ -349,7 +383,8 @@ mui.plusReady(function() {
349 383
							var li = document.createElement("li");
350 384
							if( of == 1) {
351 385
								var userType = autho(data.data.authType, data.data.orgAuth, data.data.authStatus);
352

386
								li.setAttribute("owner-id", data.data.id);
387
								li.setAttribute("data-type", 1);
353 388
							} else {
354 389
								var userType = {};
355 390
								if(data.data.authStatus == 3) {
@ -357,7 +392,10 @@ mui.plusReady(function() {
357 392
								} else {
358 393
									userType.sty = "e"
359 394
								}
395
								li.setAttribute("owner-id", data.data.id);
396
								li.setAttribute("data-type", 2);
360 397
							}
398
							li.setAttribute("data-id", $data[i].articleId);
361 399
							li.className = "mui-table-view-cell";
362 400
							li.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
363 401
								'<div class="madiaHead artHead" style="background-image:url(' + arImg + ')"></div>' +
@ -417,12 +455,20 @@ mui.plusReady(function() {
417 455
	if(oArticleModule.oFlag == 1) {
418 456
		/*企业发布文章信息*/
419 457
		oArticleModule.oAjaxGet(baseUrl + "/ajax/org/" + oArticleModule.oWner, "", "get", oArticleModule.business);
420
		document.getElementById('attBtn').style.display="none";
421
		
458
		document.getElementById('attBtn').style.display = "none";
422 459

423 460
	} else {
461
		if(plus.storage.getItem('userid') == oArticleModule.oWner) {
462
			document.getElementById('attBtn').style.display = "none";
463
		}
464
		mui('#personAL').on('tap', '#messImg,#name', function() {
465
			var id = oArticleModule.oWner;
466
			plus.nativeUI.showWaiting(); //显示原生等待框
467
			plus.webview.create("../html/proinforbrow.html", 'proinforbrow.html', {}, {
468
				proid: id
469
			}); //后台创建webview并打开show.html
470
		})
424 471
		/*查询是否关注专家*/
425
		
426 472
		oArticleModule.oAjaxGet(baseUrl + "/ajax/watch/hasWatch", {
427 473
			"watchObject": oArticleModule.oWner,
428 474
			'professorId': oCurren.userid
@ -436,8 +482,55 @@ mui.plusReady(function() {
436 482
	oArticleModule.oAjaxGet(baseUrl + "/ajax/article/ralateRes", {
437 483
		"articleId": oArticleModule.articleId
438 484
	}, "get", oArticleModule.correlationResource);
485
	mui('#expertList,.commentBlock').on('tap', 'li', function() {
486
		var id = this.getAttribute("data-id");
487
		plus.nativeUI.showWaiting(); //显示原生等待框
488
		plus.webview.create("../html/proinforbrow.html", 'proinforbrow.html', {}, {
489
			proid: id
490
		});
491
	})
492
	/*资源浏览*/
493
	mui('#resourceList').on('tap', 'li', function() {
494
		var resouId = this.getAttribute("data-id");
495
		plus.nativeUI.showWaiting();
496
		plus.webview.create("../html/resinforbrow.html", 'resinforbrow.html', {}, {
497
			resourceId: resouId
498
		});
499
	})
439 500
	/*点赞*/
440

501
	mui('#articleList').on('tap', 'li', function() {
502
		var id = this.getAttribute("data-id");
503
		var datatype = this.getAttribute("data-type");
504
		var ownerid = this.getAttribute("owner-id");
505
		if(datatype == 1) {
506
			mui.openWindow({
507
				url: '../html/professorArticle.html',
508
				id: 'html/professorArticle.html',
509
				show: {
510
					autoShow: false,
511
					aniShow: "slide-in-right",
512
				},
513
				extras: {
514
					articleId: id,
515
					ownerid: ownerid,
516
				}
517
			});
518
		} else if(datatype == 2) {
519
			mui.openWindow({
520
				url: '../html/professorArticle.html',
521
				id: 'html/professorArticle.html',
522
				show: {
523
					autoShow: false,
524
					aniShow: "slide-in-right",
525
				},
526
				extras: {
527
					articleId: id,
528
					ownerid: ownerid,
529
					oFlag: 1
530
				}
531
			});
532
		}
533
	});
441 534
	document.getElementsByClassName("thumbBtn")[0].addEventListener("tap", function() {
442 535
		var oClsNm = document.getElementById("snum").parentNode.className;
443 536
		if(oClsNm == 'thumbBtn thumbedBtn')
@ -468,6 +561,9 @@ mui.plusReady(function() {
468 561
	/*自定义事件*/
469 562
	window.addEventListener("newId", function(event) {
470 563
		oCurren.userid = plus.storage.getItem('userid');
564
		if(oCurren.userid == oArticleModule.oWner) {
565
			document.getElementById('attBtn').style.display = "none";
566
		}
471 567
		oArticleModule.oAjaxGet(baseUrl + "/ajax/article/isAgree", {
472 568
			"articleId": oArticleModule.articleId,
473 569
			'operateId': oCurren.userid
@ -537,15 +633,15 @@ mui.plusReady(function() {
537 633
	oArticleModule.oAjaxGet(baseUrl + "/ajax/leaveWord/lwCount", {
538 634
		"articleId": oArticleModule.articleId
539 635
	}, "get", leaveWord.leaveWordTotal);
540
	document.getElementById("textInputThis").addEventListener("keyup",function(){
636
	document.getElementById("textInputThis").addEventListener("keyup", function() {
541 637
		var length = trim(this.value);
542 638
		if(length) {
543 639
			document.getElementsByClassName("mui-btn")[0].removeAttribute("disabled")
544
		}else{
545
			document.getElementsByClassName("mui-btn")[0].setAttribute("disabled","true")
640
		} else {
641
			document.getElementsByClassName("mui-btn")[0].setAttribute("disabled", "true")
546 642
		}
547 643
	})
548
	document.getElementsByClassName("mui-btn")[0].addEventListener("tap",function(){
644
	document.getElementsByClassName("mui-btn")[0].addEventListener("tap", function() {
549 645
		mui.ajax(baseUrl + "/ajax/leaveWord", {
550 646
			data: {
551 647
				"articleId": plus.webview.currentWebview().articleId,
@ -557,11 +653,14 @@ mui.plusReady(function() {
557 653
			timeout: 10000, //超时时间设置为10秒;
558 654
			success: function(data) {
559 655
				if(data.success) {
560
					document.getElementById("textInputThis").value="";
561
					createTime="";
562
					orderKey="";
656
					document.getElementById("textInputThis").value = "";
657
					createTime = "";
658
					orderKey = "";
563 659
					mui('#pullrefresh').pullRefresh().enablePullupToRefresh();
564 660
					leword(1, 1);
661
					oArticleModule.oAjaxGet(baseUrl + "/ajax/leaveWord/lwCount", {
662
						"articleId": oArticleModule.articleId
663
					}, "get", leaveWord.leaveWordTotal)
565 664
				}
566 665
			},
567 666
			error: function(xhr, type, errorThrown) {
@ -570,8 +669,8 @@ mui.plusReady(function() {
570 669
			}
571 670
		});
572 671
	})
573
	mui(".commentBlock").on("tap",".dele",function(){
574
		var $this=this;
672
	mui(".commentBlock").on("tap", ".dele", function() {
673
		var $this = this;
575 674
		mui.ajax(baseUrl + "/ajax/leaveWord/delete", {
576 675
			data: {
577 676
				"id": this.getAttribute("data-id"),
@ -582,10 +681,13 @@ mui.plusReady(function() {
582 681
			success: function(data) {
583 682
				if(data.success) {
584 683
					document.getElementsByClassName("commentBlock")[0].removeChild($this.parentNode.parentNode.parentNode);
585
					createTime="";
586
					orderKey="";
684
					createTime = "";
685
					orderKey = "";
587 686
					mui('#pullrefresh').pullRefresh().enablePullupToRefresh();
588 687
					leword(1, 1);
688
					oArticleModule.oAjaxGet(baseUrl + "/ajax/leaveWord/lwCount", {
689
						"articleId": oArticleModule.articleId
690
					}, "get", leaveWord.leaveWordTotal)
589 691
				}
590 692
			},
591 693
			error: function(xhr, type, errorThrown) {
@ -594,48 +696,9 @@ mui.plusReady(function() {
594 696
			}
595 697
		});
596 698
	})
597
	
598
	
599
	
699

600 700
	/*微信及微信朋友圈分享专家*/
601 701
	var auths, shares;
602
	mui("#shareBlock").on("tap","li",function(){
603
		var oFen=this.getElementsByTagName("span")[0].innerHTML;
604
		console.log(oFen);
605
		if(oFen=="微信好友") {
606
			var share = buildShareService("weixin");
607
				if(share) {
608
					shareMessage(share, "WXSceneSession", {
609
						content: "dddddd",
610
						title: "【科袖文章】" + proticleName,
611
						href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=" + proId,
612
						thumbs: [baseUrl + "/images/logo180.png"]
613
					});
614
				}
615
		}else if(oFen=="微信朋友圈") {
616
			var share = buildShareService("weixin");
617
				if(share) {
618
					shareMessage(share, "WXSceneTimeline", {
619
						content: "DDD",
620
						title: "【科袖文章】" ,
621
						href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=",
622
						thumbs: [baseUrl + "/images/logo180.png"]
623
					});
624
				}
625
		}else if(oFen=="新浪微博") {
626
			var share = buildShareService("sinaweibo");
627
				if(share) {
628
					shareMessage(share, "sinaweibo", {
629
						content: "iiiiiiiiiiiiisssss",
630
						
631
					});
632
				}
633
		}
634
		
635
	})
636
	/*document.getElementById("shareBtn").addEventListener("tap", function() {
637
		shareShow()
638
	})*/
639 702
	plus.oauth.getServices(function(services) {
640 703
		auths = {};
641 704
		for(var i in services) {
@ -658,55 +721,44 @@ mui.plusReady(function() {
658 721
		}
659 722
	}, function(e) {
660 723
		alert("获取分享服务列表失败:" + e.message + " - " + e.code);
661
	})
662

663
	/*function shareShow() {
664
		var shareBts = [];
665
		// 更新分享列表
666
		var ss = shares['weixin'];
667
		if(navigator.userAgent.indexOf('StreamApp') < 0 && navigator.userAgent.indexOf('qihoo') < 0) { //在360流应用中微信不支持分享图片
668
			ss && ss.nativeClient && (shareBts.push({
669
					title: '微信好友',
670
					s: ss,
671
					x: 'WXSceneSession'
672
				}),
673
				shareBts.push({
674
					title: '微信朋友圈',
675
					s: ss,
676
					x: 'WXSceneTimeline'
677
				}));
678
		}
679
		//				// 弹出分享列表
680
		shareBts.length > 0 ? plus.nativeUI.actionSheet({
681
			title: '分享',
682
			cancel: '取消',
683
			buttons: shareBts
684
		}, function(e) {
685
			if(e.index == 1) {
686
				var share = buildShareService();
687
				if(share) {
688
					shareMessage(share, "WXSceneSession", {
689
						content: oImgShare.substring(0,70),
690
						title: "【科袖文章】" + proticleName,
691
						href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=" + proId,
692
						thumbs: [baseUrl + "/images/logo180.png"]
693
					});
694
				}
695
			} else if(e.index == 2) {
696
				var share = buildShareService();
697
				if(share) {
698
					shareMessage(share, "WXSceneTimeline", {
699
						content: oImgShare.substring(0,70),
700
						title: "【科袖文章】" + proticleName,
701
						href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=" + proId,
702
						thumbs: [baseUrl + "/images/logo180.png"]
703
					});
704
				}
724
	});
725
	mui("#shareBlock").on("tap", "li", function() {
726
		document.getElementById("shareBlock").style.display = "none";
727
		document.getElementById("maskBlack").style.display = "none";
728
		var oFen = this.getElementsByTagName("span")[0].innerHTML;
729
		if(oFen == "微信好友") {
730
			var share = buildShareService("weixin");
731
			if(share) {
732
				shareMessage(share, "WXSceneSession", {
733
					content: document.getElementById("articleContent").innerText.substring(0, 70),
734
					title: document.getElementById("articleName").innerHTML,
735
					href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=" + oArticleModule.articleId,
736
					thumbs: [baseUrl + "/data/article/" + stt + oArticleModule.articleId + "_s.jpg"]
737
				});
705 738
			}
739
		} else if(oFen == "微信朋友圈") {
740
			var share = buildShareService("weixin");
741
			if(share) {
742
				shareMessage(share, "WXSceneTimeline", {
743
					content: document.getElementById("articleContent").innerText.substring(0, 70),
744
					title: document.getElementById("articleName").innerHTML,
745
					href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=" + oArticleModule.articleId,
746
					thumbs: [baseUrl + "/data/article/" + stt + oArticleModule.articleId + "_s.jpg"]
747
				});
748
			}
749
		} else if(oFen == "新浪微博") {
750
			var share = buildShareService("sinaweibo");
751
			if(share) {
752
				shareMessage(share, "sinaweibo", {
753
					content: document.getElementById("articleContent").innerText.substring(0, 70),
754
					title: document.getElementById("articleName").innerHTML,
755
					href: baseUrl + "/ekexiu/shareArticalinfor.html?articleId=" + oArticleModule.articleId,
756
					thumbs: [baseUrl + "/data/article/" + stt + oArticleModule.articleId + "_s.jpg"]
757
				});
758
			}
759
		}
706 760

707
		}) : plus.nativeUI.alert('当前环境无法支持分享操作!');
708

709
	}*/
761
	})
710 762

711 763
	function buildShareService(ttt) {
712 764
		var share = shares[ttt];
@ -746,4 +798,8 @@ mui.plusReady(function() {
746 798
			}
747 799
		});
748 800
	}
801
	/*定位*/
802
	document.querySelector(".icon-liuyan").onclick = function() {
803
		window.location.href = "#title";
804
	}
749 805
});