浏览代码

发现 推荐改版 alpha

XMTT 7 年之前
父节点
当前提交
32a5994d33
共有 1 个文件被更改,包括 184 次插入58 次删除
  1. 184 58
      app/js/discoverNew.js

+ 184 - 58
app/js/discoverNew.js

30
		"7": 0,
30
		"7": 0,
31
		"8": 0
31
		"8": 0
32
	}
32
	}
33
	var QAtime, QAid, QArows = 2;
33
	var QAtime, QAid, QArows = 2,fTime,fId,fEx;
34
	$.ready(function() {
34
	$.ready(function() {
35
		$.plusReady(function() {
35
		$.plusReady(function() {
36
			var userid = plus.storage.getItem('userid');
36
			var userid = plus.storage.getItem('userid');
50
				userid = event.detail.id;
50
				userid = event.detail.id;
51
				document.getElementsByClassName("unlogin")[0].classList.remove("displayNone")
51
				document.getElementsByClassName("unlogin")[0].classList.remove("displayNone")
52
				document.getElementsByClassName("onlogin")[0].classList.add("displayNone")
52
				document.getElementsByClassName("onlogin")[0].classList.add("displayNone")
53
				var web4 = plus.webview.getLaunchWebview();
54
				mui.fire(web4, "newId", {
55
					rd: 2
53
				var web4 = plus.webview.getLaunchWebview();
54
				mui.fire(web4, "newId", {
55
					rd: 2
56
				});
56
				});
57
			});
57
			});
58
			if(userid && userid != null && userid != "null") {
58
			if(userid && userid != null && userid != "null") {
157
						traditional: true,
157
						traditional: true,
158
						async: true,
158
						async: true,
159
						success: function(data) {
159
						success: function(data) {
160
							console.log(JSON.stringify(data) + obj.url)
160
							if(obj.sele) {
161
							if(obj.sele) {
161
								obj.fun.call(obj.sele, data);
162
								obj.fun.call(obj.sele, data);
162
							} else {
163
							} else {
241
													},
242
													},
242
													url: "/ajax/question/answer/byTime"
243
													url: "/ajax/question/answer/byTime"
243
												});
244
												});
244
											} else {
245
                                            } else if(m == 0) {
246
                                                $D({
247
                                                    "fun": _this.createFragment,
248
                                                    data: {
249
                                                        rows:QArows,
250
                                                        ex: fEx
251
                                                    },
252
                                                    url: "/ajax/found/index"
253
                                                });
254
                                            } else {
245
												$D({
255
												$D({
246
													"fun": _this.createFragment,
256
													"fun": _this.createFragment,
247
													data: {
257
													data: {
281
												},
291
												},
282
												url: "/ajax/question/answer/byTime"
292
												url: "/ajax/question/answer/byTime"
283
											});
293
											});
294
										} else if(m == 0) {
295
                                            $D({
296
                                                "fun": _this.createFragment,
297
                                                data: {
298
                                                    time:fTime,
299
													id:fId,
300
													rows:QArows,
301
                                                    ex: fEx
302
                                                },
303
                                                url: "/ajax/found/index"
304
                                            });
284
										} else {
305
										} else {
285
											$D({
306
											$D({
286
												"fun": _this.createFragment,
307
												"fun": _this.createFragment,
365
					})
386
					})
366
				},
387
				},
367
				proName: function(data) {
388
				proName: function(data) {
389
					console.log("xmtt")
368
					if(data.success) {
390
					if(data.success) {
369
						this.innerHTML = data.data.name;
391
						this.innerHTML = data.data.name;
370
					}
392
					}
419
441
420
					}
442
					}
421
				},
443
				},
444
                questionModule:function(dataStr, liStr) {
445
                    var baImg = "../images/default-q&a.jpg";
446
                    var subs = new Array();
447
                    if(dataStr.img) {
448
                        if(dataStr.img.indexOf(',')) {
449
                            subs = dataStr.img.split(',');
450
                        } else {
451
                            subs[0] = dataStr.img;
452
                        }
453
                        baImg = baseUrl + "/data/question"+ subs[0];
454
                    }
455
                    var hd = "";
456
                    if (dataStr.replyCount > 0) {
457
                        hd = '<span>' + dataStr.replyCount + ' 回答</span>'
458
                    }
459
                    liStr.setAttribute("data-id", dataStr.id);
460
                    liStr.className = "mui-table-view-cell";
461
                    liStr.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
462
                        '<div class="madiaHead qa-Head" style="background-image:url(' + baImg + ')"></div>' +
463
                        '<div class="madiaInfo OmadiaInfo">' +
464
                        '<p class="mui-ellipsis-2 h1Font">' + dataStr.title + '</p>' +
465
                        '<p class="show-item mui-ellipsis h2Font">' + hd + '<span>N 关注</span></p>' +
466
                        '</div></div>'
467
                },
422
				leaveMsgCount: function(data) {
468
				leaveMsgCount: function(data) {
423
					if(data.success) {
469
					if(data.success) {
424
						if(data.data > 0) {
470
						if(data.data > 0) {
427
					}
473
					}
428
				},
474
				},
429
				createFragment: function(data) {
475
				createFragment: function(data) {
430
					console.log(JSON.stringify(data))
431
					console.log(m)
432
					if(data.success) {
476
					if(data.success) {
433
						var $data = data.data.data;
477
						var $data = data.data.data;
434
						if(arguments[1]) {
435
							if($data.length > 1) {
436
								$data.length = 1;
437
							}
478
						if(m==0){
479
                            if (arguments[1]) {
480
                                fEx = $data[0].articleId;
481
                                if ($data.length > 1) {
482
                                    $data.length = 1;
483
                                }
484
                            } else {
485
                                $data = data.data;
486
                                if ($data.length > 0) {
487
                                    fTime = $data[$data.length - 1].tm;
488
                                    fId = $data[$data.length - 1].id;
489
                                }
490
                            }
438
						}
491
						}
439
492
440
						for(var i = 0; i < $data.length; i++) {
493
						for(var i = 0; i < $data.length; i++) {
441
							var of ;
494
							var of ;
442
							if($data[i].articleType == 1) { of = 1;
495
							if($data[i].articleType == 1 || $data[i].ctype == "1") { of = 1;
443
							} else { of = 2;
496
							} else { of = 2;
444
							}
445
							var arImg = "../images/default-artical.jpg";
497
                            }
498
                            var arImg = "../images/default-artical.jpg";
446
499
447
							if($data[i].articleImg) {
448
								arImg = baseUrl + "/data/article/" + $data[i].articleImg.replace(".", "_s.")
449
							}
500
501
                            if (m == 0 && !arguments[1]) {
502
                                if ($data[i].img) {
503
                                    arImg = baseUrl + "/data/article/" + $data[i].img.replace(".", "_s.")
504
                                }
505
                            } else {
506
                                if ($data[i].articleImg) {
507
                                    arImg = baseUrl + "/data/article/" + $data[i].articleImg.replace(".", "_s.")
508
                                }
509
                            }
450
							var title = $data[i].articleTitle;
510
							var title = $data[i].articleTitle;
451
							var colSpan = "";
511
							var colSpan = "";
452
							if(m == 0) {
512
							if(m == 0) {
460
										key1[m].endPullDownToRefresh();
520
										key1[m].endPullDownToRefresh();
461
										pullObj[m] = 0;
521
										pullObj[m] = 0;
462
									}
522
									}
463
									if($data[i].colNum != 0) {
464
										colSpan = "<span class='column columnOther'>" + columnType[$data[i].colNum].shortName + "</span>"
523
									if($data[i].col != 0) {
524
										colSpan = "<span class='column columnOther'>" + columnType[$data[i].col].shortName + "</span>"
465
									}
525
									}
466
								}
526
								}
467
							} else {
527
							} else {
471
								}
531
								}
472
							}
532
							}
473
							var li = document.createElement("li");
533
							var li = document.createElement("li");
474
							li.setAttribute("data-id", $data[i].articleId);
475
							li.setAttribute("data-flag", 3);
476
							li.className = "mui-table-view-cell flexCenter OflexCenter";
477
							li.innerHTML = '<div class="madiaHead artHead" style="background-image:url(' + arImg + ')"></div>' +
478
								'<div class="madiaInfo OmadiaInfo">' +
479
								'<p class="mui-ellipsis-2 h1Font">' + title + '</p>' +
480
								'<p class="h2Font mui-ellipsis">' + colSpan +
481
								'<span class="nameSpan" style="margin-right:10px"></span>' +
482
								'<span class="time">' + commenTime($data[i].publishTime) + '</span>' +
483
								'</p>' +
484
								'</div>'
534
                            if (m == 0 && !arguments[1]) {
535
                            	if ($data[i].ctype == "3" ){
536
                                    $D({
537
                                        data: {id:$data[i].id},
538
                                        fun: ob.questionModule,
539
                                        url: "/ajax/question/qo",
540
                                        sele: li
541
                                    });
542
								}else {
543
                                    li.setAttribute("data-id", $data[i].id);
544
                                    li.setAttribute("data-flag", 3);
545
                                    li.className = "mui-table-view-cell flexCenter OflexCenter";
546
                                    li.innerHTML = '<div class="madiaHead artHead" style="background-image:url(' + arImg + ')"></div>' +
547
                                        '<div class="madiaInfo OmadiaInfo">' +
548
                                        '<p class="mui-ellipsis-2 h1Font">' + $data[i].title + '</p>' +
549
                                        '<p class="h2Font mui-ellipsis">' + colSpan +
550
                                        '<span class="nameSpan" style="margin-right:10px"></span>' +
551
                                        '<span class="time">' + commenTime($data[i].tm) + '</span>' +
552
                                        '</p>' +
553
                                        '</div>'
554
								}
555
                            } else {
556
                                li.setAttribute("data-id", $data[i].articleId);
557
                                li.setAttribute("data-flag", 3);
558
                                li.className = "mui-table-view-cell flexCenter OflexCenter";
559
                                li.innerHTML = '<div class="madiaHead artHead" style="background-image:url(' + arImg + ')"></div>' +
560
                                    '<div class="madiaInfo OmadiaInfo">' +
561
                                    '<p class="mui-ellipsis-2 h1Font">' + title + '</p>' +
562
                                    '<p class="h2Font mui-ellipsis">' + colSpan +
563
                                    '<span class="nameSpan" style="margin-right:10px"></span>' +
564
                                    '<span class="time">' + commenTime($data[i].publishTime) + '</span>' +
565
                                    '</p>' +
566
                                    '</div>'
567
                            }
485
							if(arguments[1]) {
568
							if(arguments[1]) {
486
								if(document.getElementsByTagName("ul")[m].children[0]) {
569
								if(document.getElementsByTagName("ul")[m].children[0]) {
487
									document.getElementsByTagName("ul")[m].insertBefore(li, document.getElementsByTagName("ul")[m].children[0])
570
									document.getElementsByTagName("ul")[m].insertBefore(li, document.getElementsByTagName("ul")[m].children[0])
493
							}
576
							}
494
577
495
							if( of == 1) {
578
							if( of == 1) {
496
								li.setAttribute("owner-id", $data[i].professorId);
497
								li.setAttribute("data-type", 1);
498
								$D({
499
									data: {},
500
									fun: ob.proName,
501
									url: "/ajax/professor/editBaseInfo/" + $data[i].professorId,
502
									sele: li.getElementsByClassName("nameSpan")[0]
503
								});
579
                            	if (m==0 && !arguments[1]){
580
                                    li.setAttribute("owner-id", $data[i].uid);
581
                                    li.setAttribute("data-type", 1);
582
                                    $D({
583
                                        data: {},
584
                                        fun: ob.proName,
585
                                        url: "/ajax/professor/editBaseInfo/" +$data[i].uid,
586
                                        sele: li.getElementsByClassName("nameSpan")[0]
587
                                    });
588
								}else{
589
                                    li.setAttribute("owner-id", $data[i].professorId);
590
                                    li.setAttribute("data-type", 1);
591
                                    $D({
592
                                        data: {},
593
                                        fun: ob.proName,
594
                                        url: "/ajax/professor/editBaseInfo/" + $data[i].professorId,
595
                                        sele: li.getElementsByClassName("nameSpan")[0]
596
                                    });
597
								}
504
							} else {
598
							} else {
505
								li.setAttribute("owner-id", $data[i].orgId);
506
								li.setAttribute("data-type", 2);
507
								$D({
508
									data: {},
509
									fun: ob.orgName,
510
									url: "/ajax/org/" + $data[i].orgId,
511
									sele: li.getElementsByClassName("nameSpan")[0]
512
								});
599
                            	if (m==0&& !arguments[1]){
600
                                    li.setAttribute("owner-id", $data[i].uid);
601
                                    li.setAttribute("data-type", 2);
602
                                    $D({
603
                                        data: {},
604
                                        fun: ob.orgName,
605
                                        url: "/ajax/org/" + $data[i].uid,
606
                                        sele: li.getElementsByClassName("nameSpan")[0]
607
                                    });
608
								}else{
609
                                    li.setAttribute("owner-id", $data[i].orgId);
610
                                    li.setAttribute("data-type", 2);
611
                                    $D({
612
                                        data: {},
613
                                        fun: ob.orgName,
614
                                        url: "/ajax/org/" + $data[i].orgId,
615
                                        sele: li.getElementsByClassName("nameSpan")[0]
616
                                    });
617
								}
513
							}
618
							}
514
						}
619
						}
515
620
516
						if(arguments[1]) {
621
						if(arguments[1]) {
517
							arr.push($data[0].articleId);
518
							console.log(arr + "   273");
519
							$D({
520
								"fun": ob.createFragment,
521
								data: {
522
									col: "",
523
									pageNo: 1,
524
									exclude: arr
525
								},
526
								url: "/ajax/article/find"
527
							});
622
							// arr.push($data[0].articleId);
623
							// console.log(arr + "   273");
624
							// $D({
625
							// 	"fun": ob.createFragment,
626
							// 	data: {
627
							// 		col: "",
628
							// 		pageNo: 1,
629
							// 		exclude: arr
630
							// 	},
631
							// 	url: "/ajax/article/find"
632
							// });
633
                            $D({
634
                                "fun": ob.createFragment,
635
                                data: {
636
                                    rows:QArows,
637
                                    ex: fEx
638
                                },
639
                                url: "/ajax/found/index"
640
                            });
528
641
529
						}
642
						}
530
						if(!arguments[1]) {
643
						if(!arguments[1]&&m!=0) {
531
							document.getElementsByClassName("nodatabox")[m].classList.add("displayNone");
644
							document.getElementsByClassName("nodatabox")[m].classList.add("displayNone");
532
							if(data.data.data.length == 0) {
645
							if(data.data.data.length == 0) {
533
								document.getElementsByClassName("nodatabox")[m].classList.remove("displayNone");
646
								document.getElementsByClassName("nodatabox")[m].classList.remove("displayNone");
540
							} else {
653
							} else {
541
								key1[m].endPullUpToRefresh(true);
654
								key1[m].endPullUpToRefresh(true);
542
							}
655
							}
656
						}else{
657
                            var liLen=document.getElementsByTagName("ul")[m].querySelectorAll("li").length;
658
                            if($data.length == 0&&liLen==0 ) {
659
                                document.getElementsByClassName("nodatabox")[m].classList.remove("displayNone");
660
                                key1[m].endPullUpToRefresh(true);
661
                                return;
662
                            }
663
                            if($data.length < QArows) {
664
                                key1[m].endPullUpToRefresh(true);
665
                            } else {
666
                                key1[m].refresh(true);
667
                                key1[m].endPullUpToRefresh(false);
668
                            }
543
						}
669
						}
544
					}
670
					}
545
				},
671
				},