Browse Source

发现 问答

XMTT 7 years ago
parent
commit
4a2676681b
2 changed files with 169 additions and 86 deletions
  1. 21 7
      discover.html
  2. 148 79
      js/discover.js

+ 21 - 7
discover.html

@ -44,31 +44,45 @@
44 44
					    <div class="haveData">
45 45
					    	<div class="table-item-list">
46 46
					    		<ul class="listitemdiv listmorediv" id="table-item-0"></ul>
47
								<div class="tcdPageCode"></div>
47
								<div class="continue">
48
									<button>继续加载</button>
49
								</div>
48 50
					    	</div>
49 51
					    	<div class="table-item-list">
50 52
					    		<ul class="listitemdiv listmorediv" id="table-item-1"></ul>
51
								<div class="tcdPageCode"></div>
53
								<div class="continue">
54
									<button>继续加载</button>
55
								</div>
52 56
					    	</div>
53 57
					    	<div class="table-item-list">
54 58
					    		<ul class="listitemdiv listmorediv" id="table-item-2"></ul>
55
								<div class="tcdPageCode"></div>
59
								<div class="continue">
60
									<button>继续加载</button>
61
								</div>
56 62
					    	</div>
57 63
					    	<div class="table-item-list">
58 64
					    		<ul class="listitemdiv listmorediv" id="table-item-3"></ul>
59
								<div class="tcdPageCode"></div>
65
								<div class="continue">
66
									<button>继续加载</button>
67
								</div>
60 68
					    	</div>
61 69
					    	<div class="table-item-list">
62 70
					    		<ul class="listitemdiv listmorediv" id="table-item-4"></ul>
63
								<div class="tcdPageCode"></div>
71
								<div class="continue">
72
									<button>继续加载</button>
73
								</div>
64 74
					    	</div>
65 75
					    	<div class="table-item-list">
66 76
					    		<ul class="listitemdiv listmorediv" id="table-item-5"></ul>
67
								<div class="tcdPageCode"></div>
77
								<div class="continue">
78
									<button>继续加载</button>
79
								</div>
68 80
					    	</div>
69 81
					    	<div class="table-item-list">
70 82
					    		<ul class="listitemdiv listmorediv" id="table-item-6"></ul>
71
								<div class="tcdPageCode"></div>
83
								<div class="continue">
84
									<button>继续加载</button>
85
								</div>
72 86
					    	</div>
73 87
					    </div>
74 88
					</div>

+ 148 - 79
js/discover.js

@ -4,8 +4,8 @@ $(function() {
4 4
	loginStatus();//判断个人是否登录
5 5
	var userid = $.cookie("userid");
6 6
	var exculdeIds=[];
7
	var exculdeId2s=[];
8
	var rows="20"
7
	var exculdeId2s;
8
	var rows="20",fTime,fId,QTime,QId;
9 9
	var sortColumn=["3","7","10","4","5","6","8"]//发现栏目显示顺序
10 10
	//轮播加载页面
11 11
	$.ajax({
@ -17,7 +17,7 @@ $(function() {
17 17
			for(var i=0;i<5;i++){
18 18
				var dataId=$(".slide-item").eq(i).attr("data-id");
19 19
				exculdeIds.push(dataId);
20
				exculdeId2s.push(dataId);
20
				// exculdeId2s.push(dataId);
21 21
			}
22 22
			$(".slide-list").on("click",".slide-item",function(){
23 23
				var columId=$(this).attr("data-col");
@ -35,9 +35,10 @@ $(function() {
35 35
	})
36 36
	
37 37
	hotNews();
38
    importNews();
38 39
	var linkNum=0;//栏目类别导航
39 40
	if(linkNum==0){
40
		listShow(exculdeId2s,1,0,true);
41
        firstListShow(true);
41 42
	}
42 43
	navmenu();
43 44
	function navmenu(){
@ -68,8 +69,15 @@ $(function() {
68 69
		})
69 70
		$(".table-tab-item").on("click","li",function(){
70 71
			if($(this).is('.table-tab-slide')){
71
				linkNum = $(this).index(".table-tab-slide");
72
				dataColNum=$(this).attr('data-col');
72
                fTime = "", fId = "", QTime = "", QId = "";
73
                linkNum = $(this).index(".table-tab-slide");
74
                $(".haveData").find("ul").each(function () {
75
                    $(this).html("");
76
                    $(this).parent().find(".continue").unbind("click");
77
                    $(this).parent().find(".continue").show();
78
                });
79
                $("#table-item-"+linkNum).html("");
80
                dataColNum=$(this).attr('data-col');
73 81
				$(".table-tab-slide").removeClass("table-tab-slide-active");
74 82
				$(this).addClass("table-tab-slide-active");
75 83
				$(".table-drop").fadeOut(1000);
@ -81,7 +89,9 @@ $(function() {
81 89
					$(".rightbtn").removeClass("table-tab-slide-active");
82 90
				}
83 91
				if(linkNum==0){
84
					listShow(exculdeId2s,1,0,true);
92
                    firstListShow(true);
93
				}else if(linkNum == 3){
94
					getWenda(true);
85 95
				}else{
86 96
					var thisNum=dataColNum;
87 97
					listShow(exculdeIds,1,thisNum,true,linkNum);
@ -113,7 +123,8 @@ $(function() {
113 123
					if($data.length>0){
114 124
						var divObj=$("#table-item-0 li:first")
115 125
						divObj.before('<li class="flexCenter"></li>');
116
						exculdeId2s.push($data[0].articleId);
126
						// exculdeId2s.push($data[0].articleId);
127
						exculdeId2s = $data[0].articleId;
117 128
						lastestColum($data[0],$("#table-item-0 li:first"),true);
118 129
						
119 130
					}
@ -171,21 +182,16 @@ $(function() {
171 182
					if(colNum!=0){
172 183
						idItem=index;
173 184
					}
174
					$("#table-item-"+idItem).html("");
185
					// $("#table-item-"+idItem).html("");
175 186
					var strNo='<div class="nodatabox"><div class="nodata"><div class="picbox picNull"></div>'
176 187
						strNo+='<div class="txtbox"><p class="noContip">该栏目暂时没有任何动态</p></div></div></div>'
177 188
					var dataStr=data.data.data;
178 189
					if(dataStr.length>0){
179
						for(var i=0;i<dataStr.length;i++) {
180
							if(colNum>0){
181
								var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-"+idItem));
182
								otherColum(dataStr[i],listLi);
183
							}else{
184
								var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-0"));
185
								lastestColum(dataStr[i],listLi);
186
							}
187
						}
188
						if(colNum==0 && isbind==true){
190
                        for (var i = 0; i < dataStr.length; i++) {
191
                            var listLi = $('<li class="flexCenter"></li>').appendTo($("#table-item-" + idItem));
192
                            otherColum(dataStr[i], listLi);
193
                        }
194
                        if (colNum==0 && isbind==true){
189 195
							importNews(exculdeIds);
190 196
						}
191 197
					}else{
@ -194,15 +200,13 @@ $(function() {
194 200
					}
195 201
					//分页
196 202
					if(isbind==true){
197
						$("#table-item-"+idItem).parent().find(".tcdPageCode").off("click").createPage({
198
							pageCount: Math.ceil(data.data.total / 10),
199
							current: data.data.pageNo,
200
							backFn: function(p) {
201
								$("#table-item-"+idItem).html("");
202
								listShow(obj,p,colNum,false,idItem);
203
								document.body.scrollTop = document.documentElement.scrollTop = 0;
204
							}
205
						});
203
                        $("#table-item-" + idItem).parent().find(".continue").on("click", function () {
204
                            listShow(obj, ++pageNo, colNum, false, idItem);
205
                        });
206
					}
207
                    if (pageNo >= Math.ceil(data.data.total / 10)) {
208
                        $("#table-item-" + idItem).parent().find(".continue").unbind("click");
209
                        $("#table-item-" + idItem).parent().find(".continue").hide();
206 210
					}
207 211
					$(".loading").remove();
208 212
				}
@ -212,15 +216,78 @@ $(function() {
212 216
			}
213 217
		});
214 218
	}
215
	function getWenda(){
219

220
    function firstListShow(isbind){
221
        $.ajax({
222
            "url" :"/ajax/found/index",
223
            "type" :  "GET" ,
224
            "dataType" : "json",
225
            "traditional": true,
226
            "data" :{
227
            	"time":fTime,
228
				"id":fId,
229
                "rows":rows,
230
				"ex":exculdeId2s,
231
            },
232
            "beforeSend": function() {
233
                $(".table-body").append('<img src="../images/loading.gif" class="loading" />');
234
            },
235
            "success" : function(data) {
236
                if (data.success){
237
                    var dataStr=data.data;
238
                    var idItem=0;
239
                    if (dataStr.length > 0) {
240
                        fTime = dataStr[dataStr.length - 1].tm;
241
                        fId = dataStr[dataStr.length - 1].id;
242
                    }
243
                    // $("#table-item-"+idItem).html("");
244
                    var strNo='<div class="nodatabox"><div class="nodata"><div class="picbox picNull"></div>'
245
                    strNo+='<div class="txtbox"><p class="noContip">该栏目暂时没有任何动态</p></div></div></div>'
246
                    if(dataStr.length>0){
247
                        for(var i=0;i<dataStr.length;i++) {
248
                            if(dataStr[i].ctype=="3"){
249
                                var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-0"));
250
                                lastestQa(dataStr[i],listLi);
251
                            }else{
252
                                var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-0"));
253
                                fillColum(dataStr[i],listLi);
254
                            }
255
                        }
256
                        if(isbind==true){
257
                            importNews(exculdeIds);
258
                        }
259
                    }else{
260
                        $("#table-item-0").html(strNo);
261
                        $("#table-item-0").parent().find(".tcdPageCode").hide();
262
                    }
263
                    //分页
264
                    if(isbind==true){
265
                        $("#table-item-0").parent().find(".continue").on("click", function () {
266
                            firstListShow(false);
267
                        });
268
                    }
269
                    if (dataStr.length < rows) {
270
                        $("#table-item-0").parent().find(".continue").unbind("click");
271
                        $("#table-item-0").parent().find(".continue").hide();
272
                    }
273
                    $(".loading").remove();
274
                }
275
            },
276
            "error":function(){
277
                $.MsgBox.Alert('提示','链接服务器超时')
278
            }
279
        });
280
    }
281

282
	function getWenda(isbind){
216 283
		$.ajax({
217 284
			"url" :"/ajax/question/answer/byTime",
218 285
			"type" :  "GET" ,
219 286
			"dataType" : "json",
220 287
			"traditional": true,
221 288
			"data" :{
222
				"time":obj,
223
				"id":colNum,
289
				"time":QTime,
290
				"id":QId,
224 291
				"rows":rows
225 292
			},
226 293
			"beforeSend": function() {
@ -228,44 +295,34 @@ $(function() {
228 295
			},
229 296
			"success" : function(data) {
230 297
				if (data.success){
231
					var idItem=0
232
					if(colNum!=0){
233
						idItem=index;
234
					}
235
					$("#table-item-"+idItem).html("");
236
					var strNo='<div class="nodatabox"><div class="nodata"><div class="picbox picNull"></div>'
237
						strNo+='<div class="txtbox"><p class="noContip">该栏目暂时没有任何动态</p></div></div></div>'
238
					var dataStr=data.data.data;
298
                    var dataStr=data.data;
299
                    var idItem = 3;
300
                    if (dataStr.length > 0) {
301
                        QTime = dataStr[dataStr.length - 1].createTime;
302
                        QId = dataStr[dataStr.length - 1].id;
303
                    }
304
                    var strNo = '<div class="nodatabox"><div class="nodata"><div class="picbox picNull"></div>';
305
                    strNo += '<div class="txtbox"><p class="noContip">该栏目暂时没有任何动态</p></div></div></div>';
239 306
					if(dataStr.length>0){
240
						for(var i=0;i<dataStr.length;i++) {
241
							if(colNum>0){
242
								var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-"+idItem));
243
								otherColum(dataStr[i],listLi);
244
							}else{
245
								var listLi=$('<li class="flexCenter"></li>').appendTo($("#table-item-0"));
246
								lastestColum(dataStr[i],listLi);
247
							}
248
						}
249
						if(colNum==0 && isbind==true){
250
							importNews(exculdeIds);
251
						}
307
                        for (var i = 0; i < dataStr.length; i++) {
308
                            var listLi = $('<li class="flexCenter"></li>').appendTo($("#table-item-3"));
309
                            otherQa(dataStr[i], listLi);
310
                        }
252 311
					}else{
253
						$("#table-item-"+idItem).html(strNo);
254
						$("#table-item-"+idItem).parent().find(".tcdPageCode").hide();
312
						$("#table-item-3").html(strNo);
313
						$("#table-item-3").parent().find(".tcdPageCode").hide();
255 314
					}
256 315
					//分页
257
					if(isbind==true){
258
						$("#table-item-"+idItem).parent().find(".tcdPageCode").off("click").createPage({
259
							pageCount: Math.ceil(data.data.total / 10),
260
							current: data.data.pageNo,
261
							backFn: function(p) {
262
								$("#table-item-"+idItem).html("");
263
								listShow(obj,p,colNum,false,idItem);
264
								document.body.scrollTop = document.documentElement.scrollTop = 0;
265
							}
266
						});
267
					}
268
					$(".loading").remove();
316
                    if(isbind==true){
317
                        $("#table-item-" + idItem).parent().find(".continue").on("click", function () {
318
                            getWenda(false);
319
                        });
320
                    }
321
                    if (dataStr.length < rows) {
322
                        $("#table-item-3").parent().find(".continue").unbind("click");
323
                        $("#table-item-3").parent().find(".continue").hide();
324
                    }
325
                    $(".loading").remove();
269 326
				}
270 327
			},
271 328
			"error":function(){
@ -273,6 +330,7 @@ $(function() {
273 330
			}
274 331
		});
275 332
	}
333

276 334
	function lastestColum(dataStr,listLi,iftop){
277 335
		var madiaHead="../images/default-artical.jpg";
278 336
		if(dataStr.articleImg) {
@ -315,6 +373,24 @@ $(function() {
315 373
			cmpFun(dataStr.orgId, $strAdd);
316 374
		}
317 375
	}
376

377
	function fillColum(dataStr,ListLi){
378
        $.ajax({
379
            "url":"/ajax/article/query",
380
            "type": "GET",
381
            "dataType": "json",
382
            "data": {
383
                articleId:dataStr.id
384
            },
385
            "success": function(data) {
386
                if(data.success) {
387
                    lastestColum(data.data, ListLi);
388
                }
389
            },
390
            "error": function() {
391
            }
392
        });
393
	}
318 394
	
319 395
	function otherColum(dataStr,listLi){
320 396
		var madiaHead="../images/default-artical.jpg";
@ -352,7 +428,6 @@ $(function() {
352 428
	}
353 429
	
354 430
	function lastestQa(dataStr,listLi){
355
    	var dataStr = data.data;
356 431
        var baImg = "../images/default-q&a.jpg";
357 432
        var subs = new Array();
358 433
        if(dataStr.img) {
@ -361,17 +436,13 @@ $(function() {
361 436
            } else {
362 437
                subs[0] = dataStr.img;
363 438
            }
364
            baImg = baseUrl + "/data/question"+ subs[0];
439
            baImg = "/data/question"+ subs[0];
365 440
        }
366 441
        var hd = "";
367 442
        if (dataStr.replyCount > 0) {
368 443
            hd = '<span>' + dataStr.replyCount + '回答</span>'
369 444
        }
370
        listLi.setAttribute("data-id", dataStr.id);
371
        listLi.setAttribute("data-type",3);
372
        listLi.className = "mui-table-view-cell";
373
        
374
        var strAdd = '<a target="_blank" href="/'+ pageUrl('a',dataStr) +'" class="flexCenter urlgo">'+
445
        var strAdd = '<a target="_blank" href="/qa-show.html?id='+dataStr.id+'" class="flexCenter urlgo">'+
375 446
        	'<div class="flexCenter OflexCenter mui-clearfix">' +
376 447
            '<div class="madiaHead qa-Head" style="background-image:url(' + baImg + ')"></div>' +
377 448
            '<div class="madiaInfo OmadiaInfo">' +
@ -383,15 +454,12 @@ $(function() {
383 454
		listLi.append($str);
384 455
		attendCount(dataStr.id, $str);
385 456
	}
457

386 458
	function otherQa(dataStr,listLi){
387
    	var dataStr = data.data;
388 459
        var hd = "";
389 460
        if (dataStr.replyCount > 0) {
390 461
            hd = '<span>' + dataStr.replyCount + '回答</span>'
391 462
        }
392
        listLi.setAttribute("data-id", dataStr.id);
393
        listLi.setAttribute("data-type",3);
394
        listLi.className = "mui-table-view-cell";
395 463
        var strAdd = '<a target="_blank" href="qa-question-show.html?id='+dataStr.id+'" class="flexCenter urlgo">'+
396 464
        			'<div class="madiaInfo" style="padding-left:0">'+
397 465
					'<p class="h1Font ellipsisSty qa-question"></p>' +
@ -426,6 +494,7 @@ $(function() {
426 494
			}
427 495
		});
428 496
	}
497

429 498
	function attendCount(id, $str) {
430 499
		$.ajax({
431 500
			"url":"/ajax/watch/countProfessor",
@ -475,10 +544,10 @@ $(function() {
475 544
			"data": {},
476 545
			"success": function(data) {
477 546
				if(data.success) {
478
					var dataStr = res.data
547
					var dataStr = data.data
479 548
		            var baImg = "../images/default-photo.jpg";
480 549
		            if (dataStr.hasHeadImage == 1) {
481
		                baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
550
		                baImg = "/images/head/" + dataStr.id + "_l.jpg";
482 551
		            }
483 552
		            var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
484 553
		            var os = "";
@ -523,7 +592,7 @@ $(function() {
523 592
			},
524 593
			"success": function(data) {
525 594
				if(data.success) {
526
					$str.find(".qa-question").html(res.data.title);
595
					$str.find(".qa-question").html(data.data.title);
527 596
				}
528 597
			},
529 598
			"error": function() {