//阻尼系数 var deceleration = mui.os.ios ? 0.003 : 0.0009; mui('.mui-scroll-wrapper').scroll({ bounce: false, indicators: true, //是否显示滚动条 deceleration: deceleration }); var key1 = [], key2 = [1, 1, 1, 1, 1], ifkong=[1, 1, 1, 1, 1], rows=2, pageSize=2, pageNo=1; mui.ready(function() { mui.plusReady(function() { var userid = plus.storage.getItem('userid'); var search = { oAjaxGet: function(url, obj, oType, oFun) { var urlStr = baseUrl + url; mui.plusReady(function() { mui.ajax(urlStr, { data: obj, dataType: 'json', type: oType, traditional: true, async: false, success: function(res) { if(res.success) { console.log(JSON.stringify(res)) oFun(res); } } }); }) }, dataO:{time:"",id:""}, listData: [{ type:1, aimid:"myQ", url:"/ajax/question/my", notip:"您还没有提过问题", }, { type:2, aimid:"myA", url:"/ajax/question/answer/bySelf", notip:"您还没有回答问题", }, { type:3, aimid:"watchPro", url:"/ajax/watch/qaPro", notip:"您还没有关注的人", }, { type:4, aimid:"watchQ", url:"/ajax/question/watch", notip:"您还没有关注的问题", }, { type:5, aimid:"watchA", url:"/ajax/question/answer/byWatch", notip:"您还没有收藏的回答", }, ], comPull:function(dataStr,$_index,reStr){ var that=search, type=that.listData[$_index].type, url=that.listData[$_index].url, aimId=that.listData[$_index].aimid, newStr=that.listData[$_index].notip; if(dataStr.length>0){ that.dataO.time = dataStr[dataStr.length-1].createTime; that.dataO.id = dataStr[dataStr.length-1].id; if(!ifkong[$_index]){ that.removeAfter(aimId) } for(var i = 0; i < dataStr.length; i++) { var liStr = document.createElement("li"); document.getElementById(aimId).appendChild(liStr); if(type==1 || type==4){ that.questionModule(dataStr[i], liStr); }else if(type==2 || type==5){ that.answerModule(dataStr[i], liStr); }else if(type==3){ that.proModule(dataStr[i], liStr); } } if(type==3){ if(pageNo < Math.ceil(reStr.total / reStr.pageSize)) { key1[$_index].endPullUpToRefresh(false); } else { key1[$_index].endPullUpToRefresh(true); } }else{ if(dataStr.length' + '
' + '

' + dataStr.name + '

' + '

' + os + '

' + '

' + oSub + '

' + '
' }, questionModule: function(dataStr, liStr) { var baImg = "../images/default-q&a.jpg"; if(dataStr.img) { baImg = baseUrl + dataStr.img; } var hd = ""; if(dataStr.replyCount > 0) { hd = '' + dataStr.replyCount + ' 回答' } liStr.setAttribute("data-id", dataStr.id); liStr.className = "mui-table-view-cell"; liStr.innerHTML = '
' + '
' + '
' + '

' + dataStr.title + '

' + '

' + hd + 'N 关注

' + '
' }, answerModule: function(dataStr, liStr) { var baImg = "../images/default-photo.jpg"; var userType = autho(dataStr.authType, dataStr.orgAuth, dataStr.authStatus); var os = ""; if(dataStr.title) { if(dataStr.orgName) { os = dataStr.title + "," + dataStr.orgName; } else { os = dataStr.title; } } else { if(dataStr.office) { if(dataStr.orgName) { os = dataStr.office + "," + dataStr.orgName; } else { os = dataStr.office; } } else { if(dataStr.orgName) { os = dataStr.orgName; } } } var baImg = "../images/default-photo.jpg"; if(dataStr.hasHeadImage == 1) { baImg = baseUrl + "/images/head/" + dataStr.id + "_l.jpg"; } var hd = ""; if(dataStr.replyCount > 0) { hd = '' + dataStr.replyCount + ' 回答' } liStr.setAttribute("data-id", dataStr.id); liStr.className = "mui-table-view-cell"; liStr.innerHTML = '
'+ '

'+dataStr.title+'

'+ '
'+ '
'+ '
'+ '
张某某
'+ '
职称/职位,所在机构职称/职位,所在机构职称/职位,所在机构
'+ '
'+ '
'+ '

'+dataStr.cnt+'

'+ '
'+ '5月8日 18:00N 赞N 留言'+ '
'+ '
' }, insertAfter:function(newStr, targetE){ var parent = document.getElementById(targetE).parentNode; var kong = document.createElement("div"); kong.className="con-kong"; kong.innerHTML=newStr; if(parent.lastChild.className == "con-kong"){ return }else{ parent.insertBefore( kong, document.getElementById(targetE).nextSibling ); } }, removeAfter:function(targetE){ var parent = document.getElementById(targetE).parentNode; if(parent.lastChild.className == "con-kong"){ parent.removeChild(parent.querySelector(".con-kong")); }else{ return } }, slideFun:function($type){ if($type == "1") { document.getElementById("myQ").innerHTML=""; search.oAjaxGet("/ajax/question/my", { "uid": userid, "rows":rows, }, "get", search.oMyQ); } else if($type == "2") { document.getElementById("myA").innerHTML=""; search.oAjaxGet("/ajax/question/answer/bySelf", { "uid": userid, "rows":rows, }, "get", search.oMyA); } else if($type == "3") { document.getElementById("watchPro").innerHTML=""; pageNo=1 search.oAjaxGet("/ajax/watch/qaPro", { "professorId": userid, "watchType":1, "pageSize":pageSize, "pageNo":pageNo }, "get", search.oWatchPro); } else if($type == "4") { document.getElementById("watchQ").innerHTML=""; search.oAjaxGet("/ajax/question/watch", { "uid": userid, "rows":rows, }, "get", search.oWatchQ); } else if($type == "5") { document.getElementById("watchA").innerHTML=""; search.oAjaxGet("/ajax/question/answer/byWatch", { "uid": userid, "rows":rows, }, "get", search.oWatchA); } }, allAgreeNum:function(){ mui.ajax(baseUrl+"/ajax/question/answer/my/agree/count",{ data: {"id":userid }, dataType: 'json', type: "get", success: function(res) { if(res.success) { document.getElementById("allAgreeNum").innerHTML=res.data } } }) }, } search.allAgreeNum();//总赞同数 search.oAjaxGet("/ajax/question/my", { "uid": userid, "rows":rows, }, "get", search.oMyQ); //左滑及右滑 document.querySelector('#slider').addEventListener('slide', function(event) { var $this = document.querySelector(".mui-scroll .mui-active"); var $type = $this.getAttribute("data-type") search.slideFun($type); }); //点击 document.querySelector('#slider').addEventListener('tap', function(event) { var $this = document.querySelector(".mui-scroll .mui-active"); var $type = $this.getAttribute("data-type") search.slideFun($type); }); mui("#myQ,#watchQ").on("tap", "li", function() { var id = this.getAttribute("data-id"); console.log(JSON.stringify(id)) plus.nativeUI.showWaiting(); plus.webview.create("../html/qa-question-show.html", 'qa-question-show.html', {}, { "quid": id }); }) mui("#myA,#watchA").on("tap", "li", function() { var id = this.getAttribute("data-id"); plus.nativeUI.showWaiting(); plus.webview.create("../html/qa-answer-show.html", 'qa-answer-show.html', {}, { "anid": id }); }) mui("#watchPro").on("tap", "li", function() { var id = this.getAttribute("data-id"); plus.nativeUI.showWaiting(); plus.webview.create("../html/userInforShow.html", 'userInforShow.html', {}, { "proid": id }); }) }) });