No Description

index.js 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. //首页
  2. var pageIndex = 1; // 页数
  3. var allPages = 1; // 总页数
  4. var table = document.body.querySelector('.list');
  5. var search = document.getElementById("search");
  6. mui.plusReady(function(){
  7. plus.nativeUI.showWaiting();
  8. })
  9. mui('.list').on('tap','a',function(){
  10. var id=this.getAttribute("data-id");
  11. console.log(id);
  12. plus.nativeUI.showWaiting();//显示原生等待框
  13. webviewShow = plus.webview.create("../html/proinforbrow.html",'proinforbrow.html',{},{proid:id});//后台创建webview并打开show.html
  14. })
  15. /*点击搜索按钮*/
  16. search.addEventListener('tap', function() {
  17. var nwaiting = plus.nativeUI.showWaiting();//显示原生等待框
  18. webviewShow = plus.webview.create("../html/search-home.html","../html/search-home.html");//后台创建webview并打开show.html
  19. webviewShow.addEventListener("loaded", function() {
  20. nwaiting.close(); //新webview的载入完毕后关闭等待框
  21. webviewShow.show("slide-in-right",150); //把新webview窗体显示出来,显示动画效果为速度150毫秒的右侧移入动画
  22. }, false);
  23. });
  24. /*点击热门领域*/
  25. mui('.gridbg').on('tap','li',function(){
  26. var subject = this.getAttribute("data-title");
  27. plus.nativeUI.showWaiting();//显示原生等待框
  28. webviewShow = plus.webview.create("../html/search.html",'search.html',{},{subject:subject,bigClass:1});//后台创建webview并打开show.html
  29. })
  30. /*页面数据初始化*/
  31. getOnePase();
  32. mui.init({
  33. pullRefresh: {
  34. container: '#pullrefresh',
  35. up: {
  36. contentrefresh: '正在加载...',
  37. auto:true,
  38. callback: pullupRefresh
  39. }
  40. }
  41. });
  42. function pullupRefresh() {
  43. pageIndex = ++pageIndex;
  44. setTimeout(function() {
  45. getaData()
  46. }, 1000);
  47. }
  48. if(mui.os.plus) {
  49. mui.plusReady(function() {
  50. setTimeout(function() {
  51. mui('#pullrefresh').pullRefresh().pulldownLoading();
  52. }, 500);
  53. });
  54. } else {
  55. mui.ready(function() {
  56. mui('#pullrefresh').pullRefresh().pulldownLoading();
  57. });
  58. }
  59. /*获取上拉加载更多数据*/
  60. function getaData() {
  61. mui.plusReady(function() {
  62. mui.ajax(baseUrl + '/ajax/professor/pqHot', {
  63. data: {
  64. "pageNo": pageIndex,
  65. "pageSize": 10,
  66. },
  67. dataType: 'json', //数据格式类型
  68. type: 'GET', //http请求类型
  69. timeout: 10000,
  70. async:false,
  71. success: function(data) {
  72. if(data.success) {
  73. //console.log("成功");
  74. var dice1 = data.data.total; //总条数
  75. var dice2 = data.data.pageSize; //每页条数
  76. var result = '';
  77. if(pageIndex == 1) { //下拉刷新需要先清空数据
  78. table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
  79. }
  80. allPages = dice1 / dice2;
  81. var datalist = data.data.data;
  82. datalistEach(datalist);
  83. if(pageIndex < allPages) {
  84. mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); /*能上拉*/
  85. } else {
  86. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); /*不能上拉*/
  87. }
  88. }
  89. },
  90. error: function() {
  91. plus.nativeUI.toast("服务器链接超时", toastStyle);
  92. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
  93. }
  94. });
  95. });
  96. }
  97. /*获取第一页数据*/
  98. function getOnePase() {
  99. mui.plusReady(function() {
  100. mui.ajax(baseUrl + '/ajax/professor/pqHot', {
  101. data: {
  102. "pageNo": 1,
  103. "pageSize": 10,
  104. },
  105. dataType: 'json', //数据格式类型
  106. type: 'GET', //http请求类型
  107. timeout: 10000,
  108. async:false,
  109. success: function(data) {
  110. if(data.success) {
  111. plus.nativeUI.closeWaiting();
  112. var datalist = data.data.data;
  113. datalistEach(datalist);
  114. }
  115. },
  116. error: function() {
  117. plus.nativeUI.toast("服务器链接超时", toastStyle);
  118. }
  119. });
  120. });
  121. }
  122. /*数据遍历*/
  123. function datalistEach(datalist) {
  124. mui.each(datalist, function(index, item) {
  125. /*获取头像*/
  126. if(item.hasHeadImage == 1) {
  127. var img = baseUrl + "/images/head/" + item.id + "_l.jpg";
  128. } else {
  129. var img = "../images/default-photo.jpg";
  130. }
  131. /*获取研究方向信息*/
  132. var researchAreas = item.researchAreas;
  133. var rlist = ''
  134. for(var n = 0; n < researchAreas.length; n++) {
  135. //console.log(researchAreas[n].caption);
  136. rlist = '<span>' + researchAreas[n].caption + '</span>';
  137. }
  138. /*获取资源信息*/
  139. var resources = item.resources;
  140. var zlist = ''
  141. for(var m = 0; m < resources.length; m++) {
  142. //console.log(resources[m].caption);
  143. zlist = '<span>' + resources[m].resourceName + '</span>';
  144. }
  145. var title = item.title || "";
  146. var office = item.office || "";
  147. var orgName = item.orgName || "";
  148. var address = item.address || "";
  149. if(title != "") {
  150. title = title + " , ";
  151. }
  152. if(office != "") {
  153. office = office + " , ";
  154. }
  155. if(orgName != "") {
  156. orgName = orgName;
  157. }
  158. if(address != "") {
  159. address = " | " + address;
  160. }
  161. var typeTname = '';
  162. if(item.authType) {
  163. typeTname='<em class="mui-icon iconfont icon-vip authicon-cu"> </em>';
  164. } else {
  165. if(item.authStatus) {
  166. if(item.authentication == 1) {
  167. typeTname='<em class="mui-icon iconfont icon-renzheng authicon-mana"><span>科研</span></em>';
  168. } else if(item.authentication == 2) {
  169. typeTname='<em class="mui-icon iconfont icon-renzheng authicon-staff"><span>企业</span></em>';
  170. } else {
  171. typeTname='<em class="mui-icon iconfont icon-renzheng authicon-stu"><span>学生</span></em>';
  172. }
  173. }
  174. }
  175. var li = document.createElement('li');
  176. li.className = 'mui-table-view-cell mui-media';
  177. li.innerHTML = '<a class="proinfor" data-id="'+item.id+'"' +
  178. '<p><img class="mui-media-object mui-pull-left headimg headRadius" src="' + img + '"></p>' +
  179. '<div class="mui-media-body">' +
  180. '<span class="listtit">' + item.name + typeTname +'</span>' +
  181. '<p class="listtit2"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  182. '<p class="mui-ellipsis listtit3">' + rlist + '</p>' +
  183. '<p class="mui-ellipsis listtit3">' + zlist + '</p>' +
  184. '</div></a></li>';
  185. table.appendChild(li, table.firstChild);
  186. });
  187. }