li 7 年 前
コミット
43c4f6fc93
共有2 個のファイルを変更した141 個の追加4 個の削除を含む
  1. 9 4
      app/html/inform-sub.html
  2. 132 0
      app/js/inform.js

+ 9 - 4
app/html/inform-sub.html

@ -8,14 +8,19 @@
8 8
		<link href="../css/mui.min.css" rel="stylesheet" />
9 9
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />
10 10
		<link href="../css/app.css" rel="stylesheet" />
11
		<style>
12
			.h2Font.mui-ellipsis-2>span{
13
				color:#FF9900;
14
			}
15
		</style>
11 16
	</head>
12 17

13 18
	<body>
14
		<div id="zixunpullrefresh" class="mui-content mui-scroll-wrapper">
19
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper">
15 20
			<div class="mui-scroll">
16 21
				<div class="infocon madiaBlock">
17 22
					<ul class="mui-table-view consultList" id="consultList">
18
						<li class="mui-table-view-cell" style="height:80px;">
23
						<!--<li class="mui-table-view-cell" style="height:80px;">
19 24
							<div class="madiaHead useHead" style="background-image:url(../images/default-photo.jpg)"></div>
20 25
							<div class="madiaInfo">
21 26

@ -34,11 +39,11 @@
34 39
									8月17日 18:00
35 40
								</div>
36 41
							</div>
37
						</li>
42
						</li>-->
38 43
					</ul>
39 44
				</div>
40 45
			</div>
41
			<div style="position:absolute;top:50%;width:100%;text-align:center;" class="displayNone">暂无通知</div>
46
			<div style="position:absolute;top:50%;width:100%;text-align:center;" class="displayNone" id="nodatalist">暂无通知</div>
42 47
		</div>
43 48
		<script src="../js/public/mui.min.js"></script>
44 49
		<script src="../js/public/base.js"></script>

+ 132 - 0
app/js/inform.js

@ -0,0 +1,132 @@
1
mui.init({
2
	pullRefresh: {
3
		container: '#pullrefresh',
4
		down: {
5
			callback: pulldownRefresh
6
		},
7
		up: {
8
			contentrefresh: '正在加载...',
9
			callback: pullupRefresh,
10
			auto:true
11
		}
12
	}
13
});
14
/**
15
 * 下拉刷新具体业务实现
16
 */
17
function pulldownRefresh() {
18
	mui('#pullrefresh').pullRefresh().refresh(true);
19
	count = 1;
20
	setTimeout(function() {
21
		mui.plusReady(function() {
22
			for(var i in obj) {
23
				if(obj.uid == obj[i] || obj.rows == obj[i]) {
24
					continue;
25
				}
26
				if(obj.time == obj[i] || obj.mid == obj[i])
27
					delete obj[i];
28

29
			}
30
			informList(obj);
31
		})
32
	}, 1000);
33
}
34
var count,
35
	obj = {
36
		rows: 20
37
	};
38
/**
39
 * 上拉加载具体业务实现
40
 */
41

42
function pullupRefresh() {
43
	
44
	mui.plusReady(function() {
45
		if(!obj.uid) {
46
				obj.uid = plus.storage.getItem('userid');
47
			}
48
		setTimeout(function() {
49
			informList(obj);
50
		}, 1000);
51
	})
52

53
}
54

55
function informList(objec) {
56
	console.log(JSON.stringify(objec));
57
	mui.ajax(baseUrl + '/ajax/notify', {
58
		data: objec,
59
		async: true,
60
		dataType: 'json', //服务器返回json格式数据
61
		type: 'GET', //HTTP请求类型
62
		traditional: true, //传数组必须加这个
63
		success: function(data) {
64
			if(data.success) {
65
				var $info = data.data;
66
				console.log($info.length)
67
				if($info.length == 0) {
68
					if(count) {
69
						document.getElementById("nodatalist").style.display = "block";
70
						mui('#pullrefresh').pullRefresh().disablePullupToRefresh(true);
71
						return;
72
					} else {
73
						mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); /*不能上拉*/
74
						return;
75
					}
76
				}
77
				if(count) {
78
					document.getElementById("consultList").innerHTML="";
79
					mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
80
				}
81
				count = 0;
82
				informHtml($info);
83
				if(data.data.length == obj.rows) {
84
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); /*能上拉*/
85
					obj.time = $info[$info.length-1].createTime;
86
					obj.mid = $info[$info.length-1].id;
87
				} else {
88
					mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
89
				}
90

91
			}
92

93
		},
94
		error: function(x) {
95
			plus.nativeUI.toast("服务器链接超时", toastStyle);
96
		}
97
	});
98
}
99

100
function informHtml($data) {
101
	for(var i = 0; i < $data.length; i++) {
102
		var li = document.createElement("li");
103
		li.className = "mui-table-view-cell";
104
		li.style.height = "80px";
105
		li.innerHTML = '<div class="madiaHead useHead" style="../images/default-photo.jpg"></div>' +
106
			'<div class="madiaInfo">' +
107
			'<div class="h2Font mui-ellipsis-2" style="color: #333;font-weight: 400;">' + $data[i].cnt + '</div>' +
108
			'<div class="h3Font" style="margin: 5px 0;">' + commenTime($data[i].createTime) + '</div></div>'
109
		document.getElementById("consultList").appendChild(li);
110
		uinfo(li, $data[i].uid)
111
	}
112
}
113

114
function uinfo(li, uid) {
115
	mui.ajax(baseUrl + "/ajax/professor/editBaseInfo/" + uid, {
116
		async: true,
117
		dataType: 'json', //服务器返回json格式数据
118
		type: 'GET', //HTTP请求类型
119
		traditional: true, //传数组必须加这个
120
		success: function(data) {
121
			if(data.success) {
122
				var $data = data.data;
123
				if($data.hasHeadImage == 1) {
124
					li.getElementsByClassName("useHead")[0].style.backgroundImage = "url(" + baseUrl + "/images/head/" + $data.id + "_l.jpg" + ")";
125
				}
126
			}
127
		},
128
		error: function(x) {
129
			plus.nativeUI.toast("服务器链接超时", toastStyle);
130
		}
131
	});
132
}