Browse Source

专家关注页面,ios兼容问题

xuchunyang 8 years ago
parent
commit
7f8bd4e11d
2 changed files with 68 additions and 19 deletions
  1. 30 7
      app/html/attentions.html
  2. 38 12
      app/js/attentions.js

+ 30 - 7
app/html/attentions.html

25
				<li index="1" class="mui-col-xs-6">资源</li>
25
				<li index="1" class="mui-col-xs-6">资源</li>
26
			</ul>
26
			</ul>
27
		</div>
27
		</div>
28
		<div class="alllist" id="pullrefresh">
29
	        <div  class="mui-card-content conblock childlist " style="display: block;"><!--当前x显示列表   'childlist'的显示隐藏-->
30
		      	<ul class="mui-table-view protable list ">
31
			            
32
			    </ul>
33
			</div>
34
			<div class="mui-card-content conblock childlist " >
28
		<div class="mui-content alllist mui-scroll-wrapper" id="pullrefresh" style="margin-top: 35px;">
29
			<div class="mui-scroll"> 
30
		        <div  class="mui-card-content conblock childlist " style="display: block;"><!--当前x显示列表   'childlist'的显示隐藏-->
31
			      	<ul class="mui-table-view protable list ">
32
				            
33
				    </ul>
34
				    <div class="nodatabox" style="display:none; background: #efeff4;margin: 0; " id="nodatabox1">
35
				        <div class="nodata">
36
				            <div class="picbox"><span class="defpic"></span></div>
37
				            <div class="txtbox">
38
				            	<p class="currword">抱歉!您还未关注过专家</p>
39
				                <p class="currtip">请重新修改搜索关键字、或筛选条件后再进行搜索</p>
40
				            </div>
41
				        </div>
42
				    </div>
43
				</div>
44
				
45
				<div class="mui-card-content conblock childlist ">
35
			    <ul class="mui-table-view protable list2 ">
46
			    <ul class="mui-table-view protable list2 ">
36
			           
47
			           
37
			    </ul>
48
			    </ul>
49
			    <div class="nodatabox" style="display:none; background: #efeff4; margin: 0; " id="nodatabox2">
50
			        <div class="nodata">
51
			            <div class="picbox"><span class="defpic"></span></div>
52
			            <div class="txtbox">
53
			            	<p class="currword">抱歉!您还未关注过资源</p>
54
			                <p class="currtip">请重新修改搜索关键字、或筛选条件后再进行搜索</p>
55
			            </div>
56
			        </div>
57
			    </div>
38
			</div>
58
			</div>
59
				<!-- 主界面具体展示内容 -->
60
    		</div>
39
		</div>
61
		</div>
62
		
40
		<!--<a id="scrollToTop" class="backTop hide"> <span class="mui-icon mui-icon-arrowup"></span> </a>-->
63
		<!--<a id="scrollToTop" class="backTop hide"> <span class="mui-icon mui-icon-arrowup"></span> </a>-->
41
    </div>
64
    </div>
42
    <script src="../js/public/mui.min.js"></script>
65
    <script src="../js/public/mui.min.js"></script>

+ 38 - 12
app/js/attentions.js

1
//我的关注
1
//我的关注
2
var allPages = 1, // 总页数;
2
var allPages = 1, // 总页数;
3
	pageSize = 0,
3
	pageSize = 0,
4
	pageNo = 1;
5
    checkedindex = 0
4
	pageNo = 1,
5
    checkedindex = 0;
6
var table = document.body.querySelector('.list');
6
var table = document.body.querySelector('.list');
7
var table1 = document.body.querySelector('.list2');
7
var table1 = document.body.querySelector('.list2');
8
var nodatabox1 = document.getElementById("nodatabox1");
9
var nodatabox2 = document.getElementById("nodatabox2");
8

10

9
//mui('.mui-scroll-wrapper').scroll({});
11
//mui('.mui-scroll-wrapper').scroll({});
10

12

14
		up: {
16
		up: {
15
			contentrefresh: '正在加载...',
17
			contentrefresh: '正在加载...',
16
			callback: pullupRefresh,
18
			callback: pullupRefresh,
17
			//auto:true
19
		    //auto:true
18
		}
20
		}
19
	}
21
	}
20
});
22
});
22
function pullupRefresh() {
24
function pullupRefresh() {
23
	pageNo = ++pageNo;
25
	pageNo = ++pageNo;
24
	console.log(pageNo)
26
	console.log(pageNo)
27
	console.log(checkedindex)
28
	
25
	setTimeout(function() {
29
	setTimeout(function() {
26
		expert2(pageNo, 10)
30
		expert2(pageNo, 10)
27
	}, 1000);
31
	}, 1000);
32
	mui('#pullrefresh').pullRefresh().refresh(true);
28
}
33
}
29

34

30
if(mui.os.plus) {
35
if(mui.os.plus) {
43
mui("#fixbtn").on("tap", "li", function() {
48
mui("#fixbtn").on("tap", "li", function() {
44
	window.scrollTo(0, 0);
49
	window.scrollTo(0, 0);
45
	checkedindex = this.getAttribute("index");
50
	checkedindex = this.getAttribute("index");
51
	//alert(checkedindex);
46
	var checkedcontent_arr = document.getElementsByClassName("childlist");
52
	var checkedcontent_arr = document.getElementsByClassName("childlist");
47
	var libtn_arr = document.getElementById("fixbtn").getElementsByTagName("li");
53
	var libtn_arr = document.getElementById("fixbtn").getElementsByTagName("li");
48
	if(checkedindex == 0) {
54
	if(checkedindex == 0) {
55
		getOneExpert(1, 10);
56
		pageNo = 1;
49
		libtn_arr[0].classList.add("liactive");
57
		libtn_arr[0].classList.add("liactive");
50
		libtn_arr[1].classList.remove("liactive");
58
		libtn_arr[1].classList.remove("liactive");
51
		checkedcontent_arr[1].style.display = 'none';
59
		checkedcontent_arr[1].style.display = 'none';
52
		checkedcontent_arr[0].style.display = 'block';
60
		checkedcontent_arr[0].style.display = 'block';
53
		mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
61
		mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
54
	} else {
62
	} else {
63
		getOneResources(1, 10);
64
		pageNo = 1;
55
		libtn_arr[1].classList.add("liactive");
65
		libtn_arr[1].classList.add("liactive");
56
		libtn_arr[0].classList.remove("liactive");
66
		libtn_arr[0].classList.remove("liactive");
57
		checkedcontent_arr[0].style.display = 'none';
67
		checkedcontent_arr[0].style.display = 'none';
61
})
71
})
62

72

63
getOneExpert(1, 10);
73
getOneExpert(1, 10);
64

65
getOneResources(1, 10);
74
getOneResources(1, 10);
66

75

67
mui.plusReady(function(){
76
mui.plusReady(function(){
94
			//timeout: 10000,
103
			//timeout: 10000,
95
			//async:false, 
104
			//async:false, 
96
			success: function(data) {
105
			success: function(data) {
97
				console.log("1");
106
				table.innerHTML = '';
107
				mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
98
				if(data.success && data.data.data != "") {
108
				if(data.success && data.data.data != "") {
99
					var datalist = data.data.data;
109
					var datalist = data.data.data;
100
					datalistEach(datalist);
110
					datalistEach(datalist);
111
					mui('#pullrefresh').pullRefresh().refresh(true);
112
	                if(data.data.total<data.data.pageSize){
113
	                	mui('#pullrefresh').pullRefresh().disablePullupToRefresh(); //没有数据禁止上拉刷新	
114
	                }
115
				}else {
116
					mui('#pullrefresh').pullRefresh().disablePullupToRefresh(); //没有数据禁止上拉刷新
117
					nodatabox1.style.display = 'block';
101
				}
118
				}
102
				mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
103
			},
119
			},
104
			error: function() {
120
			error: function() {
105
				plus.nativeUI.toast("服务器链接超时", toastStyle); 
121
				plus.nativeUI.toast("服务器链接超时", toastStyle); 
124
			//timeout: 10000,
140
			//timeout: 10000,
125
			//async:false,
141
			//async:false,
126
			success: function(data) {
142
			success: function(data) {
127
				console.log("2");
143
				table1.innerHTML = '';
144
				console.log(JSON.stringify(data.data.data.resource))
128
				plus.nativeUI.closeWaiting();
145
				plus.nativeUI.closeWaiting();
129
		        plus.webview.currentWebview().show("slide-in-right", 150);
146
		        plus.webview.currentWebview().show("slide-in-right", 150);
130
				if(data.success && data.data.data != "") {
147
				if(data.success && data.data.data != "") {
131
					var datalistd = data.data.data;
148
					var datalistd = data.data.data;
132
					resourcesEach2(datalistd);
149
					resourcesEach2(datalistd);
150
					mui('#pullrefresh').pullRefresh().refresh(true);
151
	                if(data.data.total<data.data.pageSize){
152
	                	mui('#pullrefresh').pullRefresh().disablePullupToRefresh(); //没有数据禁止上拉刷新	
153
	                }
154
				}else {
155
					mui('#pullrefresh').pullRefresh().disablePullupToRefresh(); //没有数据禁止上拉刷新
156
					nodatabox2.style.display = 'block';
133
				}
157
				}
134
				mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
135
			},
158
			},
136
			error: function() {
159
			error: function() {
137
				plus.nativeUI.toast("服务器链接超时", toastStyle);
160
				plus.nativeUI.toast("服务器链接超时", toastStyle);
157
				timeout: 10000,
180
				timeout: 10000,
158
				//async:false,
181
				//async:false,
159
				success: function(data) {
182
				success: function(data) {
160
					console.log(data.success)
183
					
161
					if(data.success && data.data.data != "") {
184
					if(data.success && data.data.data != "") {
162
						plus.nativeUI.closeWaiting();
185
						plus.nativeUI.closeWaiting();
163
						mui('#pullrefresh').pullRefresh().enablePullupToRefresh(); //启用上拉刷新
186
						mui('#pullrefresh').pullRefresh().enablePullupToRefresh(); //启用上拉刷新
174
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
197
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
175
						} else {
198
						} else {
176
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
199
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
200
							
177
						}
201
						}
178

202

179
					}
203
					}
205
						var dice1 = data.data.total; //总条数
229
						var dice1 = data.data.total; //总条数
206
						var dice2 = data.data.pageSize; //每页条数
230
						var dice2 = data.data.pageSize; //每页条数
207
						allPages = Math.ceil(dice1 / dice2);
231
						allPages = Math.ceil(dice1 / dice2);
232
						
208
						if(allPages == 1) { //下拉刷新需要先清空数据
233
						if(allPages == 1) { //下拉刷新需要先清空数据
209
							table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
234
							table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
210
						}
235
						}
213
						mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
238
						mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
214
						if(pageNo < allPages) {
239
						if(pageNo < allPages) {
215
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
240
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
241
							console.log("3333333");
216
						} else {
242
						} else {
217
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
243
							mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
218
						}
244
						}
231
function datalistEach(datalist) {
257
function datalistEach(datalist) {
232
	mui.each(datalist, function(index, item) {
258
	mui.each(datalist, function(index, item) {
233
		/*获取头像*/
259
		/*获取头像*/
234
		console.log(JSON.stringify(item));
260
		//console.log(JSON.stringify(item));
235
		if(item.professor.hasHeadImage == 1) {
261
		if(item.professor.hasHeadImage == 1) {
236
			var img = baseUrl + "/images/head/" + item.professor.id + "_m.jpg";
262
			var img = baseUrl + "/images/head/" + item.professor.id + "_l.jpg";
237
		} else {
263
		} else {
238
			var img = "../images/default-photo.jpg";
264
			var img = "../images/default-photo.jpg";
239
		}
265
		}
309
/*资源数据遍历*/
335
/*资源数据遍历*/
310
function resourcesEach2(datalistd) {
336
function resourcesEach2(datalistd) {
311
	mui.each(datalistd, function(index, item) {
337
	mui.each(datalistd, function(index, item) {
312

338
       
313
		/*获取头像*/
339
		/*获取头像*/
314
		if(item.resource.images.length) {
340
		if(item.resource.images.length) {
315
			var img = baseUrl + "/images/resource/" + item.resource.resourceId + ".jpg";
341
			var img = baseUrl + "/images/resource/" + item.resource.resourceId + ".jpg";