Browse Source

发现和文章发布留言时间展示格式规则统一

luyanan 7 years ago
parent
commit
1508365599
11 changed files with 78 additions and 108 deletions
  1. 2 2
      articalShow.html
  2. BIN
      cmp-portal/images/favicon.ico
  3. 2 2
      css/genindex.css
  4. 5 17
      js/articalList.js
  5. 4 12
      js/articalPreview.js
  6. 5 41
      js/articalShow.js
  7. 47 1
      js/common.js
  8. 3 12
      js/discover.js
  9. 2 21
      js/resourceList.js
  10. 4 0
      js/resourcePreview.js
  11. 4 0
      js/resourceShow.js

+ 2 - 2
articalShow.html

@ -24,7 +24,7 @@
24 24
				<div class="showDetail">
25 25
					<div class="offmsg">
26 26
						<div class="h1Font" id="articleTitle"></div>
27
						<div class="h2Font"><span id="publishTime">2月23日 14:38</span> <span class="readNum" id="pageViews"></span></div>
27
						<div class="h2Font"><span id="publishTime"></span> <span class="readNum" id="pageViews"></span></div>
28 28
						<div class="showBigOpen" id="articleImg"></div>
29 29
						<!--文章内容区-->
30 30
						<div class="showMain" id="articleContent"></div>
@ -142,7 +142,7 @@
142 142
					<a href=""  class="qiyego"><div class="madiaHead cmpHead" id="Qimg"></div></a>
143 143
					<div class="proInfo alignCenter">
144 144
						<div class="h3Font clearfix">
145
							<a href=""  class="h1Font qiyego" id="Qname">北京科袖科技有限公司</a>
145
							<a href=""  class="h1Font qiyego" id="Qname"></a>
146 146
							<span class="authiconNew" title="科袖认证企业" id="QauthFlag"></span>
147 147
						</div>
148 148
						<p class="h2Font ellipsisSty" id="Qindustry"></p>

BIN
cmp-portal/images/favicon.ico


+ 2 - 2
css/genindex.css

@ -178,7 +178,7 @@ ul.choosediv{background: #E6E6E6;}
178 178
ul.choosediv>li{float: left;padding:0 20px;font-size: 14px;color:#666;line-height: 42px;border-top:4px solid transparent;cursor: pointer;}
179 179
ul.choosediv>li.liactive{border-color: #ff9900;color:#ff9900;background: #FFFFFF;}
180 180
ul.filterListNew{padding:8px 20px 0;background: #FFFFFF;}
181
ul.filterListNew>li{position: relative;line-height: 28px;font-size:12px;line-height: 24px;}
181
ul.filterListNew>li{position: relative;font-size:13px;line-height: 24px;}
182 182
ul.filterListNew>li:before,.filterListNew>li:after{display:table;content:" "}
183 183
ul.filterListNew>li:after{clear:both;content:"";position:absolute;height: 1px;width:100%;background: #E5E5E5;}
184 184
ul.filterListNew>li:last-child:after{height: 0;}
@ -392,7 +392,7 @@ ul.tagList>li .h2Font{color:#666}
392 392
.rightconBox .conItem.conItemG .madiaHead.cmpHead{background-image:url(../images/default-icon.jpg);}
393 393
.rightconBox .conItem.conItemG .h2Font{font-size:16px;color:#666;line-height:26px;}
394 394
.rightconBox .conItem.conItemG .h3Font>a{color:#333}
395
.rightconBox .conItem.conItemG .goSpan span{background: #ff9900;display:inline-block;width:90px;cursor:pointer;color:#fff;font-size:16px;margin:20px 4px 0;}
395
.rightconBox .conItem.conItemG .goSpan span{background: #ff9900;display:inline-block;width:84px;cursor:pointer;color:#fff;font-size:16px;margin:20px 4px 0;}
396 396
.rightconBox .conItem.conItemG .goSpan .attenSpan{position: relative;padding:9px 16px;padding-left:34px;}
397 397
.rightconBox .conItem.conItemG .goSpan .attenSpan:before{position:absolute;content:url(../images/g_article_icon_jia_nor.png);top:50%;left:18px;margin-top:-8px;}
398 398
.rightconBox .conItem.conItemG .goSpan .attenedSpan{background:#acbbc6;position: relative;padding:9px 16px;}

+ 5 - 17
js/articalList.js

@ -96,17 +96,17 @@ function articalList(pageSize, pageNo, isbind, num) {
96 96
						$itemlist.find("#artimg").attr("style", "background-image: url(/data/article/" + datalist.articleImg + ");");
97 97
					}
98 98
					if(datalist.status == 1) {//发布
99
						$itemlist.find(".time").text("发布于 "+Time(datalist.publishTime));
99
						$itemlist.find(".time").text("发布于 "+TimeTr(datalist.publishTime));
100 100
						$itemlist.find(".newurl").attr("href", "articalShow.html?articleId=" + datalist.articleId);
101 101
					}
102 102
					if(datalist.status == 0){//草稿
103
						$itemlist.find(".time").text("修改于 "+Time(datalist.modifyTime));
103
						$itemlist.find(".time").text("修改于 "+TimeTr(datalist.modifyTime));
104 104
						$itemlist.find(".newurl").attr("href", "articalModify.html?articleId=" + datalist.articleId);
105 105
						$itemlist.find(".editThis").attr("href", "articalModify.html?articleId=" + datalist.articleId);
106 106
					}
107 107
					if(datalist.status == 2){//定时发布
108
						$itemlist.find(".time").text("修改于 "+Time(datalist.modifyTime));
109
						$itemlist.find("#dsfbtime").text("草稿 | 将于" +Time(datalist.publishTime)+ "定时发布");
108
						$itemlist.find(".time").text("修改于 "+TimeTr(datalist.modifyTime));
109
						$itemlist.find("#dsfbtime").text("草稿 | 将于" +TimeTr(datalist.publishTime)+ "定时发布");
110 110
						$itemlist.find(".editThis,.newurl").on("click",function(){
111 111
							var newarticleId = $(this).parents(".newbox").attr("data-id");
112 112
							$.ajax({
@ -161,7 +161,7 @@ function articalList(pageSize, pageNo, isbind, num) {
161 161
			$.MsgBox.Alert('提示', '链接服务器超时')
162 162
		}
163 163
	});
164

164
}
165 165
	//查文章评论数
166 166
	function commentnum(articleId, $itemlist) {
167 167
		$.ajax({
@ -183,18 +183,6 @@ function articalList(pageSize, pageNo, isbind, num) {
183 183
		});
184 184
	}
185 185

186
	/*时间转换*/
187
	function Time(dealtime) {
188
		var s = dealtime;
189
		var m = s.substr(4, 2);
190
		var d = s.substr(6, 2);
191
		var h = s.substr(8, 2);
192
		var minute = s.substr(10, 2);
193
		var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
194
		return formatTime;
195
	}
196
}
197

198 186
/*文章删除*/
199 187
function newsDelet(_this) {
200 188
	var delarticleId = $(_this).parents(".newbox").attr("data-id");

+ 4 - 12
js/articalPreview.js

@ -16,7 +16,6 @@ $(function() {
16 16
			"success" : function(data) {
17 17
				if (data.success){
18 18
					$("#articleTitle").text(data.data.articleTitle);
19
					//$("#publishTime").text(Time(data.data.createTime));
20 19
					$("#articleContent").html(data.data.articleContent);
21 20
					$("#articleImg").attr("style", "background-image: url(/data/article/" + data.data.articleImg + ");");
22 21
					$("#tagList").text(industryShow(data.data.subject));
@ -29,6 +28,10 @@ $(function() {
29 28
						cmpFun(data.data.orgId);
30 29
					}
31 30
				}
31
				var articletitle = data.data.articleTitle + "-科袖网";
32
				window.setTimeout(function() {
33
					document.title = articletitle;
34
				}, 500);
32 35
			},
33 36
			"error":function(){
34 37
				$.MsgBox.Alert('提示','链接服务器超时')
@ -246,17 +249,6 @@ $(function() {
246 249
			}
247 250
		});
248 251
	}
249

250
	/*时间转换*/
251
	function Time(dealtime) {
252
		var s = dealtime;
253
		var m = s.substr(4, 2);
254
		var d = s.substr(6, 2);
255
		var h = s.substr(8, 2);
256
		var minute = s.substr(10, 2);
257
		var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
258
		return formatTime;
259
	}
260 252
	
261 253
	//拆解关键字
262 254
	function industryShow(data){

+ 5 - 41
js/articalShow.js

@ -52,6 +52,11 @@ $(function() {
52 52
					var weibopic ="http://"+window.location.host+"/data/article/" + data.data.articleImg;
53 53
					$("#weibo").attr("href","http://service.weibo.com/share/share.php?appkey=3677230589&title="+weibotitle+"&url="+weibourl+"&pic="+weibopic+"&ralateUid=6242830109&searchPic=false&style=simple");
54 54
				}
55
				
56
				var articletitle = data.data.articleTitle + "-科袖网";
57
				window.setTimeout(function() {
58
					document.title = articletitle;
59
				}, 500);
55 60
			},
56 61
			"error":function(){
57 62
				$.MsgBox.Alert('提示','链接服务器超时')
@ -376,17 +381,6 @@ $(function() {
376 381
			}
377 382
		});
378 383
	}
379

380
	/*时间转换*/
381
	function Time(dealtime) {
382
		var s = dealtime;
383
		var m = s.substr(4, 2);
384
		var d = s.substr(6, 2);
385
		var h = s.substr(8, 2);
386
		var minute = s.substr(10, 2);
387
		var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "") + "日 " + h + ":" + minute;
388
		return formatTime;
389
	}
390 384
	
391 385
	//拆解关键字
392 386
	function industryShow(data){
@ -839,36 +833,6 @@ function articledel(commenid) {
839 833
	});
840 834
}	
841 835

842
function commenTime(startTime){
843
	var nowTimg =  new Date();
844
	var startdate = new Date(); 
845
	startdate.setFullYear(parseInt(startTime.substring(0,4)));
846
	startdate.setMonth(parseInt(startTime.substring(4,6))-1);
847
	startdate.setDate(parseInt(startTime.substring(6,8)));
848
	startdate.setHours(parseInt(startTime.substring(8,10)));
849
	startdate.setMinutes(parseInt(startTime.substring(10,12)));
850
	startdate.setSeconds(parseInt(startTime.substring(12,14)));
851
	var date3=nowTimg.getTime()-startdate.getTime();  //时间差的毫秒数
852
    var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
853
    var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
854
    if(date3 < 60000){
855
    	return "刚刚";
856
    }else if(date3 > 60000 && date3 < 3600000){
857
    	return minutes + "分钟前";
858
    }else if(date3 > 3600000 && date3 < 86400000){
859
    	return hours + "小钟前";
860
    }else if(date3 > 86400000 && date3 < 172800000){
861
    	return "昨天 " + startTime.substring(10,12) + ":" +startTime.substring(12,14);
862
    	
863
    }else if(date3 > 172800000){
864
    	return startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
865
    }
866
    else{
867
    	return startTime.substring(0,4)  + "年" + startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
868
    }
869
  
870
}
871

872 836
window.onload=function(){
873 837
	pageViewsVal();//文章浏览量
874 838
}

+ 47 - 1
js/common.js

@ -501,4 +501,50 @@ $(".msgContbox textarea").focus(function(){
501 501
	$(this).parent().css("border-color","#ff9900");
502 502
}).blur(function(){
503 503
	$(this).parent().css("border-color","#E5E5E5");
504
})
504
})
505
506
//时间显示规则
507
function commenTime(startTime){
508
	var nowTimg =  new Date();
509
	var startdate = new Date(); 
510
	startdate.setFullYear(parseInt(startTime.substring(0,4)));
511
	startdate.setMonth(parseInt(startTime.substring(4,6))-1);
512
	startdate.setDate(parseInt(startTime.substring(6,8)));
513
	startdate.setHours(parseInt(startTime.substring(8,10)));
514
	startdate.setMinutes(parseInt(startTime.substring(10,12)));
515
	startdate.setSeconds(parseInt(startTime.substring(12,14)));
516
	var date3=nowTimg.getTime()-startdate.getTime();  //时间差的毫秒数
517
    var hours = parseInt((date3 % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
518
    var minutes = parseInt((date3 % (1000 * 60 * 60)) / (1000 * 60));
519
    if(date3 < 60000){
520
    	return "刚刚";
521
    }else if(date3 >= 60000 && date3 < 3600000){
522
    	return minutes + "分钟前";
523
    }else if(date3 >= 3600000 && date3 < 86400000){
524
    	return hours + "小时前";
525
    }else if(date3 >= 86400000 && date3 < 172800000){
526
    	return "昨天 " + startTime.substring(10,12) + ":" +startTime.substring(12,14);
527
    	
528
    }else if(date3 >= 172800000 && date3 < 31536000000){
529
    	return startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
530
    }
531
    else{
532
    	return startTime.substring(0,4)  + "年" + startTime.substring(4,6).replace(/\b(0+)/gi, "") + "月" + startTime.substring(6,8).replace(/\b(0+)/gi, "") + "日 " + startTime.substring(8,10) + ":" + startTime.substring(10,12);
533
    }
534
  
535
}
536
/*时间转换*/
537
function TimeTr(dealtime) {
538
	var myDate = new Date(); 
539
	var s = dealtime;
540
	var y = s.substr(0, 4);
541
	var m = s.substr(4, 2);
542
	var d = s.substr(6, 2);
543
	var h = s.substr(8, 2);
544
	var minute = s.substr(10, 2);
545
	var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "")+ "日 " + h + ":" + minute;
546
	if(y != myDate.getFullYear()){
547
		formatTime = y + "年" + m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "")+ "日 " + h + ":" + minute;
548
	}
549
	return formatTime;
550
}

+ 3 - 12
js/discover.js

@ -27,7 +27,7 @@ $(function() {
27 27
						itemlist += '<a href="" class="table-item-logo" id="userimg"></a>';
28 28
						itemlist += '<div class="table-item-name clearfix">';
29 29
						itemlist += '<a href="" id="userUrl"><span class="nameSpan" id="nameSpan"></span></a><em class="authiconNew " title=""></em>';
30
						itemlist += '<p><span class="timeLabel" id="time">3月22日 9:00</span></p></div></div>';
30
						itemlist += '<p><span class="timeLabel" id="time"></span></p></div></div>';
31 31
						itemlist += '<div class="table-item-cell"><a href="" id="newsurl">';
32 32
						itemlist += '<div class="table-item-img" id="newsimg"></div>';
33 33
						itemlist += '<div class="table-item-body">';
@ -39,7 +39,7 @@ $(function() {
39 39
						var datalist = data.data.data[i];
40 40
						var type = datalist.type;
41 41
						$itemlist.find("#centent").text(datalist.name);
42
						$itemlist.find("#time").text(Time(datalist.createTime));
42
						$itemlist.find("#time").text(commenTime(datalist.createTime));
43 43
						if(type == 1) { //专家文章
44 44
							$itemlist.find("#newstype").text("文章");
45 45
							$itemlist.find("#newstype").addClass("articalLabel");
@ -160,15 +160,6 @@ $(function() {
160 160
		});
161 161
	}
162 162

163
	/*时间转换*/
164
	function Time(dealtime) {
165
		var s = dealtime;
166
		var m = s.substr(4, 2);
167
		var d = s.substr(6, 2);
168
		var h = s.substr(8, 2);
169
		var minute = s.substr(10, 2);
170
		var formatTime = m.replace(/\b(0+)/gi, "") + "月" + d.replace(/\b(0+)/gi, "")+ "日 " + h + ":" + minute;
171
		return formatTime;
172
	}
163
	
173 164

174 165
})

+ 2 - 21
js/resourceList.js

@ -66,12 +66,12 @@ $(document).ready(function(){
66 66
	 		}
67 67
	 		console.log($data[i].status)
68 68
	 		if($data[i].status==0) {
69
	 			oTime="修改于 "+timeTran($data[i].modifyTime);
69
	 			oTime="修改于 "+TimeTr($data[i].modifyTime);
70 70
	 			draftLable='<span class="draftLable">草稿</span>';
71 71
	 			oHtml="resourceIssue.html";
72 72
	 			oLi="class='draftList'"
73 73
	 		}else{
74
	 			oTime="发布于 "+timeTran($data[i].publishTime);
74
	 			oTime="发布于 "+TimeTr($data[i].publishTime);
75 75
	 			pageview='<li><span>阅读量 '+$data[i].pageViews+'</span></li>';
76 76
	 			oHtml="resourceShow.html"
77 77
	 		}
@ -93,25 +93,6 @@ $(document).ready(function(){
93 93
			$("#resourceList").append(oStr);
94 94
	 	}
95 95
	 }
96
	 /*时间格式转换*/
97
	function timeTran(otm) {
98
		var month, day, hour, minu;
99
		var monFirst = otm.substring(4, 5);
100
		var dayFirst = otm.substring(6, 7);
101
		if(monFirst == "0") {
102
			month = otm.substring(5, 6)
103
		} else {
104
			month = otm.substring(4, 6)
105
		}
106
		if(dayFirst == "0") {
107
			day = otm.substring(7, 8);
108
		} else {
109
			day = otm.substring(6, 8);
110
		}
111
		hour = otm.substring(8, 10);
112
		minu = otm.substring(10, 12);
113
		return month + "月" + day + "日 " + hour + ":" + minu;
114
	}
115 96
	/*点击修改跳转修改页面*/
116 97
	$("#resourceList").on("click",".editThis",function(){
117 98
		location.href="resourceIssue.html?resourceId="+$(this).attr("data-id")

+ 4 - 0
js/resourcePreview.js

@ -22,6 +22,10 @@ $(document).ready(function() {
22 22
				console.log(data);
23 23
				if(data.success) {
24 24
					resourceHtml(data.data);
25
					var resourceName = data.data.resourceName + "-科袖网";
26
					window.setTimeout(function() {
27
						document.title = resourceName;
28
					}, 500);
25 29
				}
26 30
			},
27 31
			"data": {

+ 4 - 0
js/resourceShow.js

@ -23,6 +23,10 @@ $(document).ready(function() {
23 23
				console.log(data);
24 24
				if(data.success) {
25 25
					resourceHtml(data.data);
26
					var resourceName = data.data.resourceName + "-科袖网";
27
					window.setTimeout(function() {
28
						document.title = resourceName;
29
					}, 500);
26 30
				}
27 31
			},
28 32
			"data": {