luyanan 7 jaren geleden
bovenliggende
commit
1b50ef822e
4 gewijzigde bestanden met toevoegingen van 459 en 899 verwijderingen
  1. 1 1
      app/html/qa-my-wenda.html
  2. 458 438
      app/js/qa-my-wenda.js
  3. 0 459
      app/js/qa-my-wendaTT.js
  4. 0 1
      app/js/qa-question-show.js

+ 1 - 1
app/html/qa-my-wenda.html

@ -125,7 +125,7 @@
125 125
		<script src="../js/public/mui.pullToRefresh.js"></script>
126 126
		<script src="../js/public/mui.pullToRefresh.material.js"></script>
127 127
		<script src="../js/public/base.js"></script>
128
		<script src="../js/qa-my-wendaTT.js"></script>
128
		<script src="../js/qa-my-wenda.js"></script>
129 129
	</body>
130 130

131 131
</html>

+ 458 - 438
app/js/qa-my-wenda.js

@ -1,439 +1,459 @@
1
//阻尼系数
2
var deceleration = mui.os.ios ? 0.003 : 0.0009;
3
mui('.mui-scroll-wrapper').scroll({
4
	bounce: false,
5
	indicators: true, //是否显示滚动条
6
	deceleration: deceleration
7
});
8
var key1 = [],
9
	key2 = [1, 1, 1, 1, 1],
10
	ifkong=[1, 1, 1, 1, 1],
11
	pageNo=1,
12
	rows=2,
13
	pageSize=2;
14
mui.ready(function() {
15
	mui.plusReady(function() {
16
		var userid = plus.storage.getItem('userid');
17
		var search = {
18
			oAjaxGet: function(url, obj, oType, oFun) {
19
				var urlStr = baseUrl + url;
20
				mui.plusReady(function() {
21
					mui.ajax(urlStr, {
22
						data: obj,
23
						dataType: 'json',
24
						type: oType, 
25
						traditional: true,
26
						async: false,
27
						success: function(res) {
28
							if(res.success) {
29
								//console.log(JSON.stringify(res))
30
								oFun(res);
31
							}
32
						}
33
					});
34
				})
35
			},
36
			dataO:{time:"",id:"",type:"",url:""},
37
			listData: [{
38
					type:1,
39
					aimid:"myQ",
40
					url:"/ajax/question/my",
41
					notip:"您还没有提过问题",
42
				},
43
				{
44
					type:2,
45
					aimid:"myA",
46
					url:"/ajax/question/answer/bySelf",
47
					notip:"您还没有回答问题",
48
				},
49
				{
50
					type:3,
51
					aimid:"watchPro",
52
					url:"/ajax/watch/qaPro",
53
					notip:"您还没有关注的人",
54
				},
55
				{
56
					type:4,
57
					aimid:"watchQ",
58
					url:"/ajax/question/watch",
59
					notip:"您还没有关注的问题",
60
				},
61
				{
62
					type:5,
63
					aimid:"watchA",
64
					url:"/ajax/question/answer/byWatch",
65
					notip:"您还没有收藏的回答",
66
				},
67
			],
68
			comPull:function(dataStr,$_index,reStr){
69
				var that=search,
70
					aimId=that.listData[$_index].aimid,
71
					newStr=that.listData[$_index].notip;
72
					
73
				that.dataO.type=that.listData[$_index].type;
74
				that.dataO.url=that.listData[$_index].url;
75
				
76
				if(!ifkong[$_index]){that.removeAfter(aimId)}
77
				if(dataStr.length==0&&ifkong[$_index] && key2[$_index] ){
78
					that.insertAfter(newStr,aimId);
79
					ifkong[$_index]=0
80
				}
81
				
82
				if(key2[$_index]) {
83
					plus.nativeUI.closeWaiting();
84
					plus.webview.currentWebview().show("slide-in-right", 150);
85
					mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function($_index, pullRefreshEl) {
86
						key1[$_index] =mui(pullRefreshEl).pullToRefresh({
87
							up: {
88
								callback: function() {
89
									if(that.dataO.type==3){
90
										var self=this;
91
										setTimeout(function() {
92
											var rs={
93
												"professorId": userid,
94
												"watchType":1,
95
												"pageSize":pageSize,
96
												"pageNo":++pageNo
97
											};
98
											search.oAjaxGet(that.dataO.url, rs, "get",that.oWatchPro);
99
											self.endPullUpToRefresh()
100
										}, 1000);
101
									}else{
102
										var self=this;
103
										setTimeout(function() {
104
											var rs={
105
												"uid": userid,
106
												"rows":rows,
107
												"time":that.dataO.time,
108
												"id":that.dataO.id
109
											};
110
											if(that.dataO.type==1){
111
												search.oAjaxGet(that.dataO.url, rs, "get",that.oMyQ);
112
											}else if(that.dataO.type==2){
113
												search.oAjaxGet(that.dataO.url, rs, "get",that.oMyA);
114
											}else if(that.dataO.type==4){
115
												search.oAjaxGet(that.dataO.url, rs, "get",that.oWatchQ);
116
											}else if(that.dataO.type==5){
117
												search.oAjaxGet(that.dataO.url, rs, "get",that.oWatchA);
118
											}
119
											self.endPullUpToRefresh()
120
										}, 1000);
121
									}
122
								}
123
							}
124
						});
125
					});
126
					key1[$_index].endPullUpToRefresh(false);
127
					key2[$_index] = 0;
128
				}
129
				if(dataStr.length>0){
130
					that.dataO.time = dataStr[dataStr.length-1].createTime;
131
					that.dataO.id = dataStr[dataStr.length-1].id;
132
					
133
					for(var i = 0; i < dataStr.length; i++) {
134
						var liStr = document.createElement("li");
135
						document.getElementById(aimId).appendChild(liStr);
136
						if(that.dataO.type==1 || that.dataO.type==4){
137
							that.questionModule(dataStr[i], liStr);
138
						}else if(that.dataO.type==2 || that.dataO.type==5){
139
							that.answerModule(dataStr[i], liStr);
140
						}else if(that.dataO.type==3){
141
							that.proModule(dataStr[i], liStr);
142
						}
143
					}
144
					if(that.dataO.type==3){
145
						if(pageNo < Math.ceil(reStr.total / reStr.pageSize)) {
146
							key1[$_index].endPullUpToRefresh(false);
147
						} else {
148
							key1[$_index].endPullUpToRefresh(true);
149
						}
150
					}else{
151
						if(dataStr.length>rows){
152
							key1[$_index].endPullUpToRefresh(false);
153
						}
154
					}
155
				}else{
156
					key1[$_index].endPullUpToRefresh(true);
157
					return;
158
				}
159
				if(dataStr.length==0){
160
					key1[$_index].endPullUpToRefresh(true);
161
					return;
162
				}
163
				
164
			},
165
			oMyQ: function(res) {
166
				search.comPull(res.data,0);
167
			},
168
			oMyA: function(res) {
169
				search.comPull(res.data,1);
170
			},
171
			oWatchPro: function(res) {
172
				search.comPull(res.data.data,2,res.data);
173
			},
174
			oWatchQ: function(res) {
175
				search.comPull(res.data,3);
176
			},
177
			oWatchA: function(res) {
178
				search.comPull(res.data,4);
179
			},
180
			proModule:function(dataStr, liStr){
181
				var dataStr=dataStr.professor
182
				var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
183
					var os = "";
184
					if(dataStr.title) {
185
						if(dataStr.orgName) {
186
							os = dataStr.title + "," + dataStr.orgName;
187
						} else {
188
							os = dataStr.title;
189
						}
190
					} else {
191
						if(dataStr.office) {
192
							if(dataStr.orgName) {
193
								os = dataStr.office + "," + dataStr.orgName;
194
							} else {
195
								os = dataStr.office;
196
							}
197
						} else {
198
							if(dataStr.orgName) {
199
								os = dataStr.orgName;
200
							}
201
						}
202
					}
203
					var baImg = "../images/default-photo.jpg";
204
					if(dataStr.hasHeadImage == 1) {
205
						baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
206
					}
207
					var oSub = "";
208
					if(dataStr.researchAreas.length) {
209
						var arr = [];
210
						for(var n = 0; n < dataStr.researchAreas.length; n++) {
211
							arr[n] = dataStr.researchAreas[n].caption;
212
						}
213
						oSub = "研究方向:" + arr.join(";");
214
					}
215
					liStr.setAttribute("data-id", dataStr.id);
216
					liStr.setAttribute("data-flag", 1);
217
					liStr.className = "mui-table-view-cell flexCenter";
218
					liStr.innerHTML = ' <div class="madiaHead useHead" style="background-image:url(' + baImg + ')"></div>' +
219
						'<div class="madiaInfo">' +
220
						'<p><span class="h1Font">' + dataStr.name + '</span><em class="authicon ' + userType.sty + '" title="' + userType.title + '"></em></p>' +
221
						'<p class="mui-ellipsis h2Font">' + os + '</p>' +
222
						'<p class="mui-ellipsis h2Font">' + oSub + '</p>' +
223
						'</div>'
224
			},
225
			questionModule: function(dataStr, liStr) {
226
				var baImg = "../images/default-q&a.jpg";
227
				var subs = new Array();
228
				if(dataStr.img) {
229
					if(dataStr.img.indexOf(',')) {
230
						subs = dataStr.img.split(',');
231
					} else {
232
						subs[0] = dataStr.img;
233
					}
234
					baImg = baseUrl + "/data/question"+ subs[0];
235
				}
236
				var hd = "";
237
				if(dataStr.replyCount > 0) {
238
					hd = '<span>' + dataStr.replyCount + ' 回答</span>'
239
				}
240
				liStr.setAttribute("data-id", dataStr.id);
241
				liStr.className = "mui-table-view-cell";
242
				liStr.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
243
					'<div class="madiaHead qa-Head" style="background-image:url(' + baImg + ')"></div>' +
244
					'<div class="madiaInfo OmadiaInfo">' +
245
					'<p class="mui-ellipsis-2 h1Font">' + dataStr.title + '</p>' +
246
					'<p class="show-item mui-ellipsis h2Font">' + hd + '<span>N 关注</span></p>' +
247
					'</div></div>'
248
			},
249
			answerModule: function(dataStr, liStr) {
250
				var hd = "",hl="";
251
				if(dataStr.agree > 0) {
252
					hd = '<span>'+dataStr.agree+'赞</span>'
253
				}
254
				if(dataStr.ballot > 0){
255
					hl='<span>'+dataStr.ballot+'留言</span>'
256
				}
257
				liStr.setAttribute("data-id", dataStr.id);
258
				liStr.className = "mui-table-view-cell";
259
				var str = '<div class="madiaInfo">'+
260
								'<p class="h1Font mui-ellipsis-2 qa-question"></p>'+
261
								'<div class="flexCenter qa-owner"></div>'+
262
								'<p class="qa-con mui-ellipsis-5">'+dataStr.cnt+'</p>'+
263
								'<div class="showli mui-ellipsis">'+
264
									'<span>'+commenTime(dataStr.createTime)+'</span>'+ hd + hl+
265
								'</div>'+
266
							'</div>'
267
				var $str=$(str)
268
				$str.appendTo(liStr);
269
				search.questioninfo(dataStr.qid,$str);
270
				search.proinfo(dataStr.uid,$str);
271
				
272
			},
273
			insertAfter:function(newStr, targetE){
274
			    var parent = document.getElementById(targetE).parentNode;
275
			    var kong = document.createElement("div");
276
			   		kong.className="con-kong";
277
			   		kong.innerHTML=newStr;
278
			   	if(parent.lastChild.className == "con-kong"){
279
			        return
280
			   	}else{
281
			        parent.insertBefore( kong, document.getElementById(targetE).nextSibling );
282
			   	}
283
			    
284
			},
285
			removeAfter:function(targetE){
286
				var parent = document.getElementById(targetE).parentNode;
287
				if(parent.lastChild.className == "con-kong"){
288
			   		parent.removeChild(parent.querySelector(".con-kong"));
289
			   	}else{
290
			        return
291
			   	}
292
			},
293
			slideFun:function($type){
294
				search.dataO={time:"",id:"",type:"",url:""},
295
				pageNo=1,
296
//				key1=[],
297
				key2 = [1, 1, 1, 1, 1];
298
//				if(key1[$type-1] instanceof Object){
299
//					key1[$type-1].endPullUpToRefresh(false);
300
//				}
301
				if($type == "1") {
302
					document.getElementById("myQ").innerHTML="";
303
					search.oAjaxGet("/ajax/question/my", {
304
						"uid": userid,
305
						"rows":rows,
306
					}, "get", search.oMyQ);
307
				} else if($type == "2") {
308
					document.getElementById("myA").innerHTML="";
309
					search.oAjaxGet("/ajax/question/answer/bySelf", {
310
						"uid": userid,
311
						"rows":rows,
312
					}, "get", search.oMyA);
313
				} else if($type == "3") {
314
					document.getElementById("watchPro").innerHTML="";
315
					search.oAjaxGet("/ajax/watch/qaPro", {
316
						"professorId": userid,
317
						"watchType":1,
318
						"pageSize":pageSize,
319
						"pageNo":pageNo
320
					}, "get", search.oWatchPro);
321
				} else if($type == "4") {
322
					document.getElementById("watchQ").innerHTML="";
323
					search.oAjaxGet("/ajax/question/watch", {
324
						"uid": userid,
325
						"rows":rows,
326
					}, "get", search.oWatchQ);
327
				} else if($type == "5") {
328
					document.getElementById("watchA").innerHTML="";
329
					search.oAjaxGet("/ajax/question/answer/byWatch", {
330
						"uid": userid,
331
						"rows":rows,
332
					}, "get", search.oWatchA);
333
				}
334
			},
335
			allAgreeNum:function(){
336
				mui.ajax(baseUrl+"/ajax/question/answer/my/agree/count",{
337
					data: {"id":userid },
338
					dataType: 'json',
339
					type: "get",
340
					success: function(res) {
341
						if(res.success) {
342
							document.getElementById("allAgreeNum").innerHTML=res.data
343
						}
344
					}
345
				})
346
				
347
			},
348
			proinfo:function(pid,$str){
349
				search.oAjaxGet("/ajax/professor/baseInfo/"+pid, {}, "get", function(res){
350
					var dataStr=res.data
351
					var baImg = "../images/default-photo.jpg";
352
					if(dataStr.hasHeadImage == 1) {
353
						baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
354
					}
355
					var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
356
					var os = "";
357
					if(dataStr.title) {
358
						if(dataStr.orgName) {
359
							os = dataStr.title + "," + dataStr.orgName;
360
						} else {
361
							os = dataStr.title;
362
						}
363
					} else {
364
						if(dataStr.office) {
365
							if(dataStr.orgName) {
366
								os = dataStr.office + "," + dataStr.orgName;
367
							} else {
368
								os = dataStr.office;
369
							}
370
						} else {
371
							if(dataStr.orgName) {
372
								os = dataStr.orgName;
373
							}
374
						}
375
					}
376
					var str='<div class="owner-head useHead" style="background-image:url('+baImg+')"></div>'+
377
							'<div class="owner-info">'+
378
								'<div class="owner-name"><span class="h1Font">'+dataStr.name+'</span><em class="authicon '+userType.sty+'" title="'+userType.title+'"></em></div>'+
379
								'<div class="owner-tit mui-ellipsis h2Font">'+os+'</div>'+
380
							'</div>'
381
					$str.find(".qa-owner").html(str)
382
				});
383
			},
384
			questioninfo:function(qid,$str){
385
				search.oAjaxGet("/ajax/question/qo", {
386
					"id": qid,
387
				}, "get", function(res){
388
					$str.find(".qa-question").html(res.data.title);
389
				});
390
				
391
			}
392
		}
393
		
394
		search.allAgreeNum();//总赞同数
395
		search.oAjaxGet("/ajax/question/my", {
396
			"uid": userid,
397
			"rows":rows,
398
		}, "get", search.oMyQ);
399
		
400
		
401
		//左滑及右滑
402
		document.querySelector('#slider').addEventListener('slide', function(event) {
403
			var $this = document.querySelector(".mui-scroll .mui-active");
404
			var $type = $this.getAttribute("data-type")
405
			search.slideFun($type);
406
		});
407
		//点击
408
		document.querySelector('#slider').addEventListener('tap', function(event) {
409
			var $this = document.querySelector(".mui-scroll .mui-active");
410
			var $type = $this.getAttribute("data-type")
411
			search.slideFun($type);
412
		});
413
		
414
		
415
		mui("#myQ,#watchQ").on("tap", "li", function() {
416
			var id = this.getAttribute("data-id");
417
			console.log(JSON.stringify(id))
418
			plus.nativeUI.showWaiting();
419
			plus.webview.create("../html/qa-question-show.html", 'qa-question-show.html', {}, {
420
				"quid": id
421
			});
422
		})
423
		mui("#myA,#watchA").on("tap", "li", function() {
424
			var id = this.getAttribute("data-id");
425
			plus.nativeUI.showWaiting();
426
			plus.webview.create("../html/qa-answer-show.html", 'qa-answer-show.html', {}, {
427
				"anid": id
428
			});
429
		})
430
		mui("#watchPro").on("tap", "li", function() {
431
			var id = this.getAttribute("data-id");
432
			plus.nativeUI.showWaiting();
433
			plus.webview.create("../html/userInforShow.html", 'userInforShow.html', {}, {
434
				"proid": id
435
			});
436
		})
437
		
438
	})
1
/**
2
 * Created by TT on 2018/1/9.
3
 */
4
var deceleration = mui.os.ios ? 0.003 : 0.0009;
5
mui('.mui-scroll-wrapper').scroll({
6
    bounce: false,
7
    indicators: true, //是否显示滚动条
8
    deceleration: deceleration
9
});
10
mui.ready(function () {
11
    mui.plusReady(function () {
12
    	var self = plus.webview.currentWebview()
13
    	plus.nativeUI.closeWaiting();
14
		self.show("slide-in-right", 150);
15
        var currentIndex,
16
            currentSelf,
17
            pageNo = 1,
18
            rows = 20,
19
            pageSize = 20;
20
        var listData = [{
21
                type: 0,
22
                aimid: "myQ",
23
                url: "/ajax/question/my",
24
                notip: "您还没有提过问题"
25
            },
26
                {
27
                    type: 1,
28
                    aimid: "myA",
29
                    url: "/ajax/question/answer/bySelf",
30
                    notip: "您还没有回答问题"
31
                },
32
                {
33
                    type: 2,
34
                    aimid: "watchPro",
35
                    url: "/ajax/watch/qaPro",
36
                    notip: "您还没有关注的人"
37
                },
38
                {
39
                    type: 3,
40
                    aimid: "watchQ",
41
                    url: "/ajax/question/watch",
42
                    notip: "您还没有关注的问题"
43
                },
44
                {
45
                    type: 4,
46
                    aimid: "watchA",
47
                    url: "/ajax/question/answer/byWatch",
48
                    notip: "您还没有收藏的回答"
49
                }
50
            ],
51
            dataO = {time: "", id: ""};
52
        var userid = plus.storage.getItem('userid');
53
54
        function allAgreeNum() {
55
            mui.ajax(baseUrl + "/ajax/question/answer/my/agree/count", {
56
                data: {"id": userid},
57
                dataType: 'json',
58
                type: "get",
59
                success: function (res) {
60
                    if (res.success) {
61
                        document.getElementById("allAgreeNum").innerHTML = res.data
62
                    }
63
                }
64
            })
65
        };
66
        var oAjaxGet = function (url, obj, oType, oFun) {
67
            var urlStr = baseUrl + url;
68
            mui.plusReady(function () {
69
                mui.ajax(urlStr, {
70
                    data: obj,
71
                    dataType: 'json',
72
                    type: oType,
73
                    traditional: true,
74
                    async: false,
75
                    success: function (res) {
76
                        if (res.success) {
77
                            oFun(res);
78
                        }
79
                    }
80
                });
81
            })
82
        };
83
        var comPull = function (dataStr, index, reStr) {
84
            var url = listData[index].url,
85
                aimId = listData[index].aimid,
86
                newStr = listData[index].notip;
87
            if (currentIndex != index) {
88
                currentIndex = index;
89
                mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function ($_index, pullRefreshEl) {
90
                    if ($_index == index) {
91
                        currentSelf = mui(pullRefreshEl).pullToRefresh({
92
                            up: {
93
                                callback: function () {
94
                                	if(currentSelf.loading){
95
	                                    setTimeout(function () {
96
	                                        if (index == 2) {
97
	                                            var rs = {
98
	                                                "professorId": userid,
99
	                                                "watchType": 1,
100
	                                                "pageSize": pageSize,
101
	                                                "pageNo": ++pageNo
102
	                                            };
103
	                                            oAjaxGet(url, rs, "get", oWatchPro);
104
	                                        } else {
105
	                                            var rs = {
106
	                                                "uid": userid,
107
	                                                "rows": rows,
108
	                                                "time": dataO.time,
109
	                                                "id": dataO.id
110
	                                            };
111
	                                            if (index == 0) {
112
	                                                oAjaxGet(url, rs, "get", oMyQ);
113
	                                            } else if (index == 1) {
114
	                                                oAjaxGet(url, rs, "get", oMyA);
115
	                                            } else if (index == 3) {
116
	                                                oAjaxGet(url, rs, "get", oWatchQ);
117
	                                            } else if (index == 4) {
118
	                                                oAjaxGet(url, rs, "get", oWatchA);
119
	                                            }
120
	                                        }
121
	                                        // currentSelf.endPullUpToRefresh()
122
	                                    }, 1000);
123
                                    }
124
                                }
125
                            }
126
                        });
127
                    }
128
                })
129
            }
130
            if (dataStr.length > 0) {
131
                dataO.time = dataStr[dataStr.length - 1].createTime;
132
                dataO.id = dataStr[dataStr.length - 1].id;
133
134
                for (var i = 0; i < dataStr.length; i++) {
135
                    var liStr = document.createElement("li");
136
                    document.getElementById(aimId).appendChild(liStr);
137
                    if (index == 0 || index == 3) {
138
                        questionModule(dataStr[i], liStr);
139
                    } else if (index == 1 || index == 4) {
140
                        answerModule(dataStr[i], liStr);
141
                    } else if (index == 2) {
142
                        proModule(dataStr[i], liStr);
143
                    }
144
                }
145
                if (index == 2) {
146
                    if (pageNo < Math.ceil(reStr.total / reStr.pageSize)) {
147
                        currentSelf.endPullUpToRefresh(false);
148
                    } else {
149
                        currentSelf.endPullUpToRefresh(true);
150
                    }
151
                    if(reStr.total<=reStr.pageSize){
152
                        currentSelf.endPullUpToRefresh(true);
153
                    }
154
                } else {
155
                    if (dataStr.length < rows) {
156
                        currentSelf.endPullUpToRefresh(true);
157
                    }else {
158
                        currentSelf.endPullUpToRefresh(false);
159
                    }
160
                }
161
            } else {
162
                currentSelf.endPullUpToRefresh(true);
163
                var liLen=document.getElementById(aimId).querySelectorAll("li").length;
164
                removeAfter(aimId);
165
                if(dataStr.length == 0 && liLen == 0 ){
166
                    insertAfter(newStr,aimId);
167
                }
168
                return;
169
            }
170
        };
171
        var oMyQ = function (res) {
172
                comPull(res.data, 0);
173
            },
174
            oMyA = function (res) {
175
                comPull(res.data, 1);
176
            },
177
            oWatchPro = function (res) {
178
                comPull(res.data.data, 2, res.data);
179
            },
180
            oWatchQ = function (res) {
181
                comPull(res.data, 3);
182
            },
183
            oWatchA = function (res) {
184
                comPull(res.data, 4);
185
            },
186
            proModule = function (dataStr, liStr) {
187
                var dataStr = dataStr.professor;
188
                var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
189
                var os = "";
190
                if (dataStr.title) {
191
                    if (dataStr.orgName) {
192
                        os = dataStr.title + "," + dataStr.orgName;
193
                    } else {
194
                        os = dataStr.title;
195
                    }
196
                } else {
197
                    if (dataStr.office) {
198
                        if (dataStr.orgName) {
199
                            os = dataStr.office + "," + dataStr.orgName;
200
                        } else {
201
                            os = dataStr.office;
202
                        }
203
                    } else {
204
                        if (dataStr.orgName) {
205
                            os = dataStr.orgName;
206
                        }
207
                    }
208
                }
209
                var baImg = "../images/default-photo.jpg";
210
                if (dataStr.hasHeadImage == 1) {
211
                    baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
212
                }
213
                var oSub = "";
214
                if (dataStr.researchAreas.length) {
215
                    var arr = [];
216
                    for (var n = 0; n < dataStr.researchAreas.length; n++) {
217
                        arr[n] = dataStr.researchAreas[n].caption;
218
                    }
219
                    oSub = "研究方向:" + arr.join(";");
220
                }
221
                liStr.setAttribute("data-id", dataStr.id);
222
                liStr.setAttribute("data-flag", 1);
223
                liStr.className = "mui-table-view-cell flexCenter";
224
                liStr.innerHTML = ' <div class="madiaHead useHead" style="background-image:url(' + baImg + ')"></div>' +
225
                    '<div class="madiaInfo">' +
226
                    '<p><span class="h1Font">' + dataStr.name + '</span><em class="authicon ' + userType.sty + '" title="' + userType.title + '"></em></p>' +
227
                    '<p class="mui-ellipsis h2Font">' + os + '</p>' +
228
                    '<p class="mui-ellipsis h2Font">' + oSub + '</p>' +
229
                    '</div>'
230
            },
231
            questionModule = function (dataStr, liStr) {
232
                var baImg = "../images/default-q&a.jpg";
233
				var subs = new Array();
234
				if(dataStr.img) {
235
					if(dataStr.img.indexOf(',')) {
236
						subs = dataStr.img.split(',');
237
					} else {
238
						subs[0] = dataStr.img;
239
					}
240
					baImg = baseUrl + "/data/question"+ subs[0];
241
				}
242
                var hd = "";
243
                if (dataStr.replyCount > 0) {
244
                    hd = '<span>' + dataStr.replyCount + ' 回答</span>'
245
                }
246
                liStr.setAttribute("data-id", dataStr.id);
247
                liStr.className = "mui-table-view-cell";
248
                liStr.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
249
                    '<div class="madiaHead qa-Head" style="background-image:url(' + baImg + ')"></div>' +
250
                    '<div class="madiaInfo OmadiaInfo">' +
251
                    '<p class="mui-ellipsis-2 h1Font">' + dataStr.title + '</p>' +
252
                    '<p class="show-item mui-ellipsis h2Font">' + hd + '<span class="attendCount"></span></p>' +
253
				'</div></div>'
254
				var $str = $(liStr);
255
				attendCount(dataStr.id, $str);
256
	        },
257
			attendCount=function(id, $str) {
258
				oAjaxGet("/ajax/watch/countProfessor", {
259
					id:id,
260
					type: 8
261
				}, "get", function(data) {
262
					if(data.success) {
263
						if(data.data > 0) {
264
							$str.find(".attendCount").html(data.data + "关注");
265
						}
266
					}
267
				})
268
			},
269
            answerModule = function (dataStr, liStr) {
270
                var hd = "";
271
                if (dataStr.agree > 0) {
272
                    hd = '<span>' + dataStr.agree + '赞</span>'
273
                }
274
                liStr.setAttribute("data-id", dataStr.id);
275
                liStr.className = "mui-table-view-cell";
276
                liStr.innerHTML = '<div class="madiaInfo">' +
277
                    '<p class="h1Font mui-ellipsis-2 qa-question"></p>' +
278
                    '<div class="flexCenter qa-owner"></div>' +
279
                    '<p class="qa-con mui-ellipsis-5">' + (dataStr.cnt).replace(/\n/g,"<br />") + '</p>' +
280
                    '<div class="showli mui-ellipsis">' +
281
                    '<span>' + commenTime(dataStr.createTime) + '</span>' + hd +'<span class="leaveMsgCount"></span>'+
282
                    '</div>' +
283
                    '</div>'
284
              	var $str = $(liStr);
285
                questioninfo(dataStr.qid, $str);
286
                proinfo(dataStr.uid, $str);
287
				leaveMsgCount(dataStr.id, $str);
288
            },
289
			leaveMsgCount=function(id, $str) {
290
				oAjaxGet("/ajax/leavemsg/count", {
291
					sid:id,
292
					stype: "4"
293
				}, "get", function(data) {
294
					if(data.success) {
295
						if(data.data > 0) {
296
							$str.find(".leaveMsgCount").html(data.data + "留言");
297
						}
298
					}
299
				})
300
			},
301
            insertAfter = function (newStr, targetE) {
302
                var parent = document.getElementById(targetE).parentNode;
303
                var kong = document.createElement("div");
304
                kong.className = "con-kong";
305
                kong.innerHTML = newStr;
306
                if (parent.firstChild.className == "con-kong") {
307
                    return
308
                } else {
309
                    parent.insertBefore(kong,parent.firstChild);
310
                }
311
312
            },
313
            removeAfter = function (targetE) {
314
                var parent = document.getElementById(targetE).parentNode;
315
                if (parent.firstChild.className == "con-kong") {
316
                    parent.removeChild(parent.firstChild);
317
                } else {
318
                    return
319
                }
320
            },
321
            proinfo = function (pid, $str) {
322
                oAjaxGet("/ajax/professor/baseInfo/" + pid, {}, "get", function (res) {
323
                    var dataStr = res.data
324
                    var baImg = "../images/default-photo.jpg";
325
                    if (dataStr.hasHeadImage == 1) {
326
                        baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
327
                    }
328
                    var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
329
                    var os = "";
330
                    if (dataStr.title) {
331
                        if (dataStr.orgName) {
332
                            os = dataStr.title + "," + dataStr.orgName;
333
                        } else {
334
                            os = dataStr.title;
335
                        }
336
                    } else {
337
                        if (dataStr.office) {
338
                            if (dataStr.orgName) {
339
                                os = dataStr.office + "," + dataStr.orgName;
340
                            } else {
341
                                os = dataStr.office;
342
                            }
343
                        } else {
344
                            if (dataStr.orgName) {
345
                                os = dataStr.orgName;
346
                            }
347
                        }
348
                    }
349
                    var str = '<div class="owner-head useHead" style="background-image:url(' + baImg + ')"></div>' +
350
                        '<div class="owner-info">' +
351
                        '<div class="owner-name"><span class="h1Font">' + dataStr.name + '</span><em class="authicon ' + userType.sty + '" title="' + userType.title + '"></em></div>' +
352
                        '<div class="owner-tit mui-ellipsis h2Font">' + os + '</div>' +
353
                        '</div>'
354
                    $str.find(".qa-owner").html(str)
355
                });
356
            },
357
            questioninfo = function (qid, $str) {
358
                oAjaxGet("/ajax/question/qo", {
359
                    "id": qid,
360
                }, "get", function (res) {
361
                    $str.find(".qa-question").html(res.data.title);
362
                });
363
364
            }
365
366
        var slideFun = function (index) {
367
            if (index == "0") {
368
                document.getElementById("myQ").innerHTML = "";
369
                oAjaxGet("/ajax/question/my", {
370
                    "uid": userid,
371
                    "rows": rows
372
                }, "get", oMyQ);
373
            } else if (index == "1") {
374
                document.getElementById("myA").innerHTML = "";
375
                oAjaxGet("/ajax/question/answer/bySelf", {
376
                    "uid": userid,
377
                    "rows": rows
378
                }, "get", oMyA);
379
            } else if (index == "2") {
380
                document.getElementById("watchPro").innerHTML = "";
381
                oAjaxGet("/ajax/watch/qaPro", {
382
                    "professorId": userid,
383
                    "watchType": 1,
384
                    "pageSize": pageSize,
385
                    "pageNo": pageNo
386
                }, "get", oWatchPro);
387
            } else if (index == "3") {
388
                document.getElementById("watchQ").innerHTML = "";
389
                oAjaxGet("/ajax/question/watch", {
390
                    "uid": userid,
391
                    "rows": rows
392
                }, "get", oWatchQ);
393
            } else if (index == "4") {
394
                document.getElementById("watchA").innerHTML = "";
395
                oAjaxGet("/ajax/question/answer/byWatch", {
396
                    "uid": userid,
397
                    "rows": rows
398
                }, "get", oWatchA);
399
            }
400
        }
401
402
		allAgreeNum() 
403
        oAjaxGet("/ajax/question/my", {
404
            "uid": userid,
405
            "rows":rows
406
        }, "get", oMyQ);
407
        //左滑及右滑
408
        document.querySelector('#slider').addEventListener('slide', function (event) {
409
            // currentSelf.endPullUpToRefresh(false);
410
            mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function ($_index, pullRefreshEl) {
411
                var id = pullRefreshEl.getAttribute("data-pullToRefresh");
412
                if(id) {
413
                    pullRefreshEl.removeAttribute("data-pullToRefresh");
414
                }
415
            });
416
            dataO = {time: "", id: ""};pageNo = 1;
417
            var $this = document.querySelector(".mui-scroll .mui-active");
418
            var $type = $this.getAttribute("data-type");
419
            slideFun($type);
420
        });
421
        //点击
422
        document.querySelector('#slider').addEventListener('tap', function (event) {
423
            // currentSelf.endPullUpToRefresh(false);
424
            mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function ($_index, pullRefreshEl) {
425
                var id = pullRefreshEl.getAttribute("data-pullToRefresh");
426
                if(id) {
427
                    pullRefreshEl.removeAttribute("data-pullToRefresh");
428
                }
429
            });
430
            dataO = {time: "", id: ""};pageNo = 1;
431
            var $this = document.querySelector(".mui-scroll .mui-active");
432
            var $type = $this.getAttribute("data-type");
433
            slideFun($type);
434
        });
435
        
436
        mui("#myQ,#watchQ").on("tap", "li", function() {
437
			var id = this.getAttribute("data-id");
438
			console.log(JSON.stringify(id))
439
			plus.nativeUI.showWaiting();
440
			plus.webview.create("../html/qa-question-show.html", 'qa-question-show.html', {}, {
441
				"quid": id
442
			});
443
		})
444
		mui("#myA,#watchA").on("tap", "li", function() {
445
			var id = this.getAttribute("data-id");
446
			plus.nativeUI.showWaiting();
447
			plus.webview.create("../html/qa-answer-show.html", 'qa-answer-show.html', {}, {
448
				"anid": id
449
			});
450
		})
451
		mui("#watchPro").on("tap", "li", function() {
452
			var id = this.getAttribute("data-id");
453
			plus.nativeUI.showWaiting();
454
			plus.webview.create("../html/userInforShow.html", 'userInforShow.html', {}, {
455
				"proid": id
456
			});
457
		})
458
    })
439 459
});

+ 0 - 459
app/js/qa-my-wendaTT.js

@ -1,459 +0,0 @@
1
/**
2
 * Created by TT on 2018/1/9.
3
 */
4
var deceleration = mui.os.ios ? 0.003 : 0.0009;
5
mui('.mui-scroll-wrapper').scroll({
6
    bounce: false,
7
    indicators: true, //是否显示滚动条
8
    deceleration: deceleration
9
});
10
mui.ready(function () {
11
    mui.plusReady(function () {
12
    	var self = plus.webview.currentWebview()
13
    	plus.nativeUI.closeWaiting();
14
		self.show("slide-in-right", 150);
15
        var currentIndex,
16
            currentSelf,
17
            pageNo = 1,
18
            rows = 2,
19
            pageSize = 2;
20
        var listData = [{
21
                type: 0,
22
                aimid: "myQ",
23
                url: "/ajax/question/my",
24
                notip: "您还没有提过问题"
25
            },
26
                {
27
                    type: 1,
28
                    aimid: "myA",
29
                    url: "/ajax/question/answer/bySelf",
30
                    notip: "您还没有回答问题"
31
                },
32
                {
33
                    type: 2,
34
                    aimid: "watchPro",
35
                    url: "/ajax/watch/qaPro",
36
                    notip: "您还没有关注的人"
37
                },
38
                {
39
                    type: 3,
40
                    aimid: "watchQ",
41
                    url: "/ajax/question/watch",
42
                    notip: "您还没有关注的问题"
43
                },
44
                {
45
                    type: 4,
46
                    aimid: "watchA",
47
                    url: "/ajax/question/answer/byWatch",
48
                    notip: "您还没有收藏的回答"
49
                }
50
            ],
51
            dataO = {time: "", id: ""};
52
        var userid = plus.storage.getItem('userid');
53
54
        function allAgreeNum() {
55
            mui.ajax(baseUrl + "/ajax/question/answer/my/agree/count", {
56
                data: {"id": userid},
57
                dataType: 'json',
58
                type: "get",
59
                success: function (res) {
60
                    if (res.success) {
61
                        document.getElementById("allAgreeNum").innerHTML = res.data
62
                    }
63
                }
64
            })
65
        };
66
        var oAjaxGet = function (url, obj, oType, oFun) {
67
            var urlStr = baseUrl + url;
68
            mui.plusReady(function () {
69
                mui.ajax(urlStr, {
70
                    data: obj,
71
                    dataType: 'json',
72
                    type: oType,
73
                    traditional: true,
74
                    async: false,
75
                    success: function (res) {
76
                        if (res.success) {
77
                            oFun(res);
78
                        }
79
                    }
80
                });
81
            })
82
        };
83
        var comPull = function (dataStr, index, reStr) {
84
            var url = listData[index].url,
85
                aimId = listData[index].aimid,
86
                newStr = listData[index].notip;
87
            if (currentIndex != index) {
88
                currentIndex = index;
89
                mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function ($_index, pullRefreshEl) {
90
                    if ($_index == index) {
91
                        currentSelf = mui(pullRefreshEl).pullToRefresh({
92
                            up: {
93
                                callback: function () {
94
                                	if(currentSelf.loading){
95
	                                    setTimeout(function () {
96
	                                        if (index == 2) {
97
	                                            var rs = {
98
	                                                "professorId": userid,
99
	                                                "watchType": 1,
100
	                                                "pageSize": pageSize,
101
	                                                "pageNo": ++pageNo
102
	                                            };
103
	                                            oAjaxGet(url, rs, "get", oWatchPro);
104
	                                        } else {
105
	                                            var rs = {
106
	                                                "uid": userid,
107
	                                                "rows": rows,
108
	                                                "time": dataO.time,
109
	                                                "id": dataO.id
110
	                                            };
111
	                                            if (index == 0) {
112
	                                                oAjaxGet(url, rs, "get", oMyQ);
113
	                                            } else if (index == 1) {
114
	                                                oAjaxGet(url, rs, "get", oMyA);
115
	                                            } else if (index == 3) {
116
	                                                oAjaxGet(url, rs, "get", oWatchQ);
117
	                                            } else if (index == 4) {
118
	                                                oAjaxGet(url, rs, "get", oWatchA);
119
	                                            }
120
	                                        }
121
	                                        // currentSelf.endPullUpToRefresh()
122
	                                    }, 1000);
123
                                    }
124
                                }
125
                            }
126
                        });
127
                    }
128
                })
129
            }
130
            if (dataStr.length > 0) {
131
                dataO.time = dataStr[dataStr.length - 1].createTime;
132
                dataO.id = dataStr[dataStr.length - 1].id;
133
134
                for (var i = 0; i < dataStr.length; i++) {
135
                    var liStr = document.createElement("li");
136
                    document.getElementById(aimId).appendChild(liStr);
137
                    if (index == 0 || index == 3) {
138
                        questionModule(dataStr[i], liStr);
139
                    } else if (index == 1 || index == 4) {
140
                        answerModule(dataStr[i], liStr);
141
                    } else if (index == 2) {
142
                        proModule(dataStr[i], liStr);
143
                    }
144
                }
145
                if (index == 2) {
146
                    if (pageNo < Math.ceil(reStr.total / reStr.pageSize)) {
147
                        currentSelf.endPullUpToRefresh(false);
148
                    } else {
149
                        currentSelf.endPullUpToRefresh(true);
150
                    }
151
                    if(reStr.total<=reStr.pageSize){
152
                        currentSelf.endPullUpToRefresh(true);
153
                    }
154
                } else {
155
                    if (dataStr.length < rows) {
156
                        currentSelf.endPullUpToRefresh(true);
157
                    }else {
158
                        currentSelf.endPullUpToRefresh(false);
159
                    }
160
                }
161
            } else {
162
                currentSelf.endPullUpToRefresh(true);
163
                var liLen=document.getElementById(aimId).querySelectorAll("li").length;
164
                removeAfter(aimId);
165
                if(dataStr.length == 0 && liLen == 0 ){
166
                    insertAfter(newStr,aimId);
167
                }
168
                return;
169
            }
170
        };
171
        var oMyQ = function (res) {
172
                comPull(res.data, 0);
173
            },
174
            oMyA = function (res) {
175
                comPull(res.data, 1);
176
            },
177
            oWatchPro = function (res) {
178
                comPull(res.data.data, 2, res.data);
179
            },
180
            oWatchQ = function (res) {
181
                comPull(res.data, 3);
182
            },
183
            oWatchA = function (res) {
184
                comPull(res.data, 4);
185
            },
186
            proModule = function (dataStr, liStr) {
187
                var dataStr = dataStr.professor;
188
                var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
189
                var os = "";
190
                if (dataStr.title) {
191
                    if (dataStr.orgName) {
192
                        os = dataStr.title + "," + dataStr.orgName;
193
                    } else {
194
                        os = dataStr.title;
195
                    }
196
                } else {
197
                    if (dataStr.office) {
198
                        if (dataStr.orgName) {
199
                            os = dataStr.office + "," + dataStr.orgName;
200
                        } else {
201
                            os = dataStr.office;
202
                        }
203
                    } else {
204
                        if (dataStr.orgName) {
205
                            os = dataStr.orgName;
206
                        }
207
                    }
208
                }
209
                var baImg = "../images/default-photo.jpg";
210
                if (dataStr.hasHeadImage == 1) {
211
                    baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
212
                }
213
                var oSub = "";
214
                if (dataStr.researchAreas.length) {
215
                    var arr = [];
216
                    for (var n = 0; n < dataStr.researchAreas.length; n++) {
217
                        arr[n] = dataStr.researchAreas[n].caption;
218
                    }
219
                    oSub = "研究方向:" + arr.join(";");
220
                }
221
                liStr.setAttribute("data-id", dataStr.id);
222
                liStr.setAttribute("data-flag", 1);
223
                liStr.className = "mui-table-view-cell flexCenter";
224
                liStr.innerHTML = ' <div class="madiaHead useHead" style="background-image:url(' + baImg + ')"></div>' +
225
                    '<div class="madiaInfo">' +
226
                    '<p><span class="h1Font">' + dataStr.name + '</span><em class="authicon ' + userType.sty + '" title="' + userType.title + '"></em></p>' +
227
                    '<p class="mui-ellipsis h2Font">' + os + '</p>' +
228
                    '<p class="mui-ellipsis h2Font">' + oSub + '</p>' +
229
                    '</div>'
230
            },
231
            questionModule = function (dataStr, liStr) {
232
                var baImg = "../images/default-q&a.jpg";
233
				var subs = new Array();
234
				if(dataStr.img) {
235
					if(dataStr.img.indexOf(',')) {
236
						subs = dataStr.img.split(',');
237
					} else {
238
						subs[0] = dataStr.img;
239
					}
240
					baImg = baseUrl + "/data/question"+ subs[0];
241
				}
242
                var hd = "";
243
                if (dataStr.replyCount > 0) {
244
                    hd = '<span>' + dataStr.replyCount + ' 回答</span>'
245
                }
246
                liStr.setAttribute("data-id", dataStr.id);
247
                liStr.className = "mui-table-view-cell";
248
                liStr.innerHTML = '<div class="flexCenter OflexCenter mui-clearfix">' +
249
                    '<div class="madiaHead qa-Head" style="background-image:url(' + baImg + ')"></div>' +
250
                    '<div class="madiaInfo OmadiaInfo">' +
251
                    '<p class="mui-ellipsis-2 h1Font">' + dataStr.title + '</p>' +
252
                    '<p class="show-item mui-ellipsis h2Font">' + hd + '<span class="attendCount"></span></p>' +
253
				'</div></div>'
254
				var $str = $(liStr);
255
				attendCount(dataStr.id, $str);
256
	        },
257
			attendCount=function(id, $str) {
258
				oAjaxGet("/ajax/watch/countProfessor", {
259
					id:id,
260
					type: 8
261
				}, "get", function(data) {
262
					if(data.success) {
263
						if(data.data > 0) {
264
							$str.find(".attendCount").html(data.data + "关注");
265
						}
266
					}
267
				})
268
			},
269
            answerModule = function (dataStr, liStr) {
270
                var hd = "";
271
                if (dataStr.agree > 0) {
272
                    hd = '<span>' + dataStr.agree + '赞</span>'
273
                }
274
                liStr.setAttribute("data-id", dataStr.id);
275
                liStr.className = "mui-table-view-cell";
276
                liStr.innerHTML = '<div class="madiaInfo">' +
277
                    '<p class="h1Font mui-ellipsis-2 qa-question"></p>' +
278
                    '<div class="flexCenter qa-owner"></div>' +
279
                    '<p class="qa-con mui-ellipsis-5">' + (dataStr.cnt).replace(/\n/g,"<br />") + '</p>' +
280
                    '<div class="showli mui-ellipsis">' +
281
                    '<span>' + commenTime(dataStr.createTime) + '</span>' + hd +'<span class="leaveMsgCount"></span>'+
282
                    '</div>' +
283
                    '</div>'
284
              	var $str = $(liStr);
285
                questioninfo(dataStr.qid, $str);
286
                proinfo(dataStr.uid, $str);
287
				leaveMsgCount(dataStr.id, $str);
288
            },
289
			leaveMsgCount=function(id, $str) {
290
				oAjaxGet("/ajax/leavemsg/count", {
291
					sid:id,
292
					stype: "4"
293
				}, "get", function(data) {
294
					if(data.success) {
295
						if(data.data > 0) {
296
							$str.find(".leaveMsgCount").html(data.data + "留言");
297
						}
298
					}
299
				})
300
			},
301
            insertAfter = function (newStr, targetE) {
302
                var parent = document.getElementById(targetE).parentNode;
303
                var kong = document.createElement("div");
304
                kong.className = "con-kong";
305
                kong.innerHTML = newStr;
306
                if (parent.firstChild.className == "con-kong") {
307
                    return
308
                } else {
309
                    parent.insertBefore(kong,parent.firstChild);
310
                }
311
312
            },
313
            removeAfter = function (targetE) {
314
                var parent = document.getElementById(targetE).parentNode;
315
                if (parent.firstChild.className == "con-kong") {
316
                    parent.removeChild(parent.firstChild);
317
                } else {
318
                    return
319
                }
320
            },
321
            proinfo = function (pid, $str) {
322
                oAjaxGet("/ajax/professor/baseInfo/" + pid, {}, "get", function (res) {
323
                    var dataStr = res.data
324
                    var baImg = "../images/default-photo.jpg";
325
                    if (dataStr.hasHeadImage == 1) {
326
                        baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg";
327
                    }
328
                    var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus);
329
                    var os = "";
330
                    if (dataStr.title) {
331
                        if (dataStr.orgName) {
332
                            os = dataStr.title + "," + dataStr.orgName;
333
                        } else {
334
                            os = dataStr.title;
335
                        }
336
                    } else {
337
                        if (dataStr.office) {
338
                            if (dataStr.orgName) {
339
                                os = dataStr.office + "," + dataStr.orgName;
340
                            } else {
341
                                os = dataStr.office;
342
                            }
343
                        } else {
344
                            if (dataStr.orgName) {
345
                                os = dataStr.orgName;
346
                            }
347
                        }
348
                    }
349
                    var str = '<div class="owner-head useHead" style="background-image:url(' + baImg + ')"></div>' +
350
                        '<div class="owner-info">' +
351
                        '<div class="owner-name"><span class="h1Font">' + dataStr.name + '</span><em class="authicon ' + userType.sty + '" title="' + userType.title + '"></em></div>' +
352
                        '<div class="owner-tit mui-ellipsis h2Font">' + os + '</div>' +
353
                        '</div>'
354
                    $str.find(".qa-owner").html(str)
355
                });
356
            },
357
            questioninfo = function (qid, $str) {
358
                oAjaxGet("/ajax/question/qo", {
359
                    "id": qid,
360
                }, "get", function (res) {
361
                    $str.find(".qa-question").html(res.data.title);
362
                });
363
364
            }
365
366
        var slideFun = function (index) {
367
            if (index == "0") {
368
                document.getElementById("myQ").innerHTML = "";
369
                oAjaxGet("/ajax/question/my", {
370
                    "uid": userid,
371
                    "rows": rows
372
                }, "get", oMyQ);
373
            } else if (index == "1") {
374
                document.getElementById("myA").innerHTML = "";
375
                oAjaxGet("/ajax/question/answer/bySelf", {
376
                    "uid": userid,
377
                    "rows": rows
378
                }, "get", oMyA);
379
            } else if (index == "2") {
380
                document.getElementById("watchPro").innerHTML = "";
381
                oAjaxGet("/ajax/watch/qaPro", {
382
                    "professorId": userid,
383
                    "watchType": 1,
384
                    "pageSize": pageSize,
385
                    "pageNo": pageNo
386
                }, "get", oWatchPro);
387
            } else if (index == "3") {
388
                document.getElementById("watchQ").innerHTML = "";
389
                oAjaxGet("/ajax/question/watch", {
390
                    "uid": userid,
391
                    "rows": rows
392
                }, "get", oWatchQ);
393
            } else if (index == "4") {
394
                document.getElementById("watchA").innerHTML = "";
395
                oAjaxGet("/ajax/question/answer/byWatch", {
396
                    "uid": userid,
397
                    "rows": rows
398
                }, "get", oWatchA);
399
            }
400
        }
401
402
		allAgreeNum() 
403
        oAjaxGet("/ajax/question/my", {
404
            "uid": userid,
405
            "rows":rows
406
        }, "get", oMyQ);
407
        //左滑及右滑
408
        document.querySelector('#slider').addEventListener('slide', function (event) {
409
            // currentSelf.endPullUpToRefresh(false);
410
            mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function ($_index, pullRefreshEl) {
411
                var id = pullRefreshEl.getAttribute("data-pullToRefresh");
412
                if(id) {
413
                    pullRefreshEl.removeAttribute("data-pullToRefresh");
414
                }
415
            });
416
            dataO = {time: "", id: ""};pageNo = 1;
417
            var $this = document.querySelector(".mui-scroll .mui-active");
418
            var $type = $this.getAttribute("data-type");
419
            slideFun($type);
420
        });
421
        //点击
422
        document.querySelector('#slider').addEventListener('tap', function (event) {
423
            // currentSelf.endPullUpToRefresh(false);
424
            mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function ($_index, pullRefreshEl) {
425
                var id = pullRefreshEl.getAttribute("data-pullToRefresh");
426
                if(id) {
427
                    pullRefreshEl.removeAttribute("data-pullToRefresh");
428
                }
429
            });
430
            dataO = {time: "", id: ""};pageNo = 1;
431
            var $this = document.querySelector(".mui-scroll .mui-active");
432
            var $type = $this.getAttribute("data-type");
433
            slideFun($type);
434
        });
435
        
436
        mui("#myQ,#watchQ").on("tap", "li", function() {
437
			var id = this.getAttribute("data-id");
438
			console.log(JSON.stringify(id))
439
			plus.nativeUI.showWaiting();
440
			plus.webview.create("../html/qa-question-show.html", 'qa-question-show.html', {}, {
441
				"quid": id
442
			});
443
		})
444
		mui("#myA,#watchA").on("tap", "li", function() {
445
			var id = this.getAttribute("data-id");
446
			plus.nativeUI.showWaiting();
447
			plus.webview.create("../html/qa-answer-show.html", 'qa-answer-show.html', {}, {
448
				"anid": id
449
			});
450
		})
451
		mui("#watchPro").on("tap", "li", function() {
452
			var id = this.getAttribute("data-id");
453
			plus.nativeUI.showWaiting();
454
			plus.webview.create("../html/userInforShow.html", 'userInforShow.html', {}, {
455
				"proid": id
456
			});
457
		})
458
    })
459
});

+ 0 - 1
app/js/qa-question-show.js

@ -9,7 +9,6 @@ mui.ready(function() {
9 9
		oanswer = document.getElementsByClassName("go-answer")[0],
10 10
		yaoanswer = document.getElementsByClassName("invite-answer")[0];
11 11
	var rows = 20,
12
		ifkong=1,
13 12
		ifAl=1,//是否是首次加载
14 13
		dataO = {
15 14
			time: "",