No Description

attentions.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. //我的关注
  2. var allPages = 1, // 总页数;
  3. pageSize = 0,
  4. pageNo = 1;
  5. checkedindex = 0
  6. var table = document.body.querySelector('.list');
  7. var table1 = document.body.querySelector('.list2');
  8. //mui('.mui-scroll-wrapper').scroll({});
  9. mui.init({
  10. pullRefresh: {
  11. container: '#pullrefresh',
  12. up: {
  13. contentrefresh: '正在加载...',
  14. callback: pullupRefresh,
  15. //auto:true
  16. }
  17. }
  18. });
  19. function pullupRefresh() {
  20. pageNo = ++pageNo;
  21. console.log(pageNo)
  22. setTimeout(function() {
  23. expert2(pageNo, 10)
  24. }, 1000);
  25. }
  26. if(mui.os.plus) {
  27. mui.plusReady(function() {
  28. setTimeout(function() {
  29. mui('#pullrefresh').pullRefresh().pulldownLoading();
  30. }, 500);
  31. });
  32. } else {
  33. mui.ready(function() {
  34. mui('#pullrefresh').pullRefresh().pulldownLoading();
  35. });
  36. }
  37. /*菜单tab切换*/
  38. mui("#fixbtn").on("tap", "li", function() {
  39. window.scrollTo(0, 0);
  40. checkedindex = this.getAttribute("index");
  41. var checkedcontent_arr = document.getElementsByClassName("childlist");
  42. var libtn_arr = document.getElementById("fixbtn").getElementsByTagName("li");
  43. if(checkedindex == 0) {
  44. libtn_arr[0].classList.add("liactive");
  45. libtn_arr[1].classList.remove("liactive");
  46. checkedcontent_arr[1].style.display = 'none';
  47. checkedcontent_arr[0].style.display = 'block';
  48. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  49. } else {
  50. libtn_arr[1].classList.add("liactive");
  51. libtn_arr[0].classList.remove("liactive");
  52. checkedcontent_arr[0].style.display = 'none';
  53. checkedcontent_arr[1].style.display = 'block';
  54. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  55. }
  56. })
  57. getOneExpert(1, 10);
  58. getOneResources(1, 10);
  59. mui.plusReady(function(){
  60. mui('.list').on('tap','a',function(){
  61. var id=this.getAttribute("data-id");
  62. plus.nativeUI.showWaiting();
  63. plus.webview.create("../html/proinforbrow.html",'proinforbrow.html',{},{proid:id});
  64. console.log(id)
  65. })
  66. mui('.list2').on('tap','a',function(){
  67. var id=this.getAttribute("data-id");
  68. plus.nativeUI.showWaiting();
  69. plus.webview.create("../html/resinforbrow.html",'resinforbrow.html',{},{resourceId:id});
  70. })
  71. })
  72. /*获取第一页专家数据*/
  73. function getOneExpert(pageNo, pageSize) {
  74. mui.plusReady(function() {
  75. var userId = plus.storage.getItem('userid');
  76. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  77. data: {
  78. "professorId": userId,
  79. "watchType": 1,
  80. "pageNo": pageNo,
  81. "pageSize": pageSize
  82. },
  83. dataType: 'json', //数据格式类型
  84. type: 'GET', //http请求类型
  85. //timeout: 10000,
  86. success: function(data) {
  87. if(data.success && data.data.data != "") {
  88. var datalist = data.data.data;
  89. datalistEach(datalist);
  90. }
  91. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  92. },
  93. error: function() {
  94. plus.nativeUI.toast("服务器链接超时", toastStyle);
  95. }
  96. });
  97. });
  98. }
  99. /*获取第一页资源数据*/
  100. function getOneResources(pageNo, pageSize) {
  101. mui.plusReady(function() {
  102. var userId = plus.storage.getItem('userid');
  103. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  104. data: {
  105. "professorId": userId,
  106. "watchType": 2,
  107. "pageNo": pageNo,
  108. "pageSize": pageSize
  109. },
  110. dataType: 'json', //数据格式类型
  111. type: 'GET', //http请求类型
  112. //timeout: 10000,
  113. success: function(data) {
  114. plus.nativeUI.closeWaiting();
  115. plus.webview.currentWebview().show("slide-in-right", 150);
  116. if(data.success && data.data.data != "") {
  117. var datalistd = data.data.data;
  118. resourcesEach2(datalistd);
  119. }
  120. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  121. },
  122. error: function() {
  123. plus.nativeUI.toast("服务器链接超时", toastStyle);
  124. }
  125. });
  126. });
  127. }
  128. /*上拉刷新数据*/
  129. function expert2(pageNo, pageSize) {
  130. if(checkedindex == 0) {
  131. mui.plusReady(function() {
  132. var userId = plus.storage.getItem('userid');
  133. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  134. data: {
  135. "professorId": userId,
  136. "watchType": 1,
  137. "pageNo": pageNo,
  138. "pageSize": pageSize
  139. },
  140. dataType: 'json', //数据格式类型
  141. type: 'GET', //http请求类型
  142. timeout: 10000,
  143. success: function(data) {
  144. console.log(data.success)
  145. if(data.success && data.data.data != "") {
  146. plus.nativeUI.closeWaiting();
  147. mui('#pullrefresh').pullRefresh().enablePullupToRefresh(); //启用上拉刷新
  148. var dice1 = data.data.total; //总条数
  149. var dice2 = data.data.pageSize; //每页条数
  150. allPages = Math.ceil(dice1 / dice2);
  151. if(allPages == 1) { //下拉刷新需要先清空数据
  152. table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
  153. }
  154. var datalist = data.data.data;
  155. datalistEach(datalist);
  156. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  157. if(pageNo < allPages) {
  158. mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
  159. } else {
  160. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
  161. }
  162. }
  163. },
  164. error: function() {
  165. plus.nativeUI.toast("服务器链接超时", toastStyle);
  166. }
  167. });
  168. });
  169. } else {
  170. mui.plusReady(function() {
  171. var userId = plus.storage.getItem('userid');
  172. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  173. data: {
  174. "professorId": userId,
  175. "watchType": 2,
  176. "pageNo": pageNo,
  177. "pageSize": pageSize
  178. },
  179. dataType: 'json', //数据格式类型
  180. type: 'GET', //http请求类型
  181. timeout: 10000,
  182. success: function(data) {
  183. console.log(data.success)
  184. if(data.success && data.data.data != "") {
  185. plus.nativeUI.closeWaiting();
  186. mui('#pullrefresh').pullRefresh().enablePullupToRefresh(); //启用上拉刷新
  187. var dice1 = data.data.total; //总条数
  188. var dice2 = data.data.pageSize; //每页条数
  189. allPages = Math.ceil(dice1 / dice2);
  190. if(allPages == 1) { //下拉刷新需要先清空数据
  191. table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
  192. }
  193. var datalist = data.data.data;
  194. resourcesEach2(datalist);
  195. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  196. if(pageNo < allPages) {
  197. mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
  198. } else {
  199. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
  200. }
  201. }
  202. },
  203. error: function() {
  204. plus.nativeUI.toast("服务器链接超时", toastStyle);
  205. }
  206. });
  207. });
  208. }
  209. }
  210. /*专家数据遍历*/
  211. function datalistEach(datalist) {
  212. mui.each(datalist, function(index, item) {
  213. /*获取头像*/
  214. if(item.professor.hasHeadImage == 1) {
  215. var img = baseUrl + "/images/head/" + item.professor.id + "_m.jpg";
  216. } else {
  217. var img = "../images/default-photo.jpg";
  218. }
  219. /*获取研究方向信息*/
  220. var researchAreas = item.professor.researchAreas;
  221. //console.log(JSON.stringify(item.professor.researchAreas))
  222. var rlist = '';
  223. for(var n = 0; n < researchAreas.length; n++) {
  224. //console.log(researchAreas[n].caption);
  225. rlist = '<span>' + researchAreas[n].caption + '</span>、';
  226. }
  227. /*判断用户是否认证*/
  228. var icon = '';
  229. if(item.professor.authentication == true) {
  230. icon = '<em class="mui-icon iconfont icon-vip authicon"></em>';
  231. } else {
  232. icon = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
  233. }
  234. /*获取资源信息*/
  235. var resources = item.professor.resources;
  236. var zlist = '';
  237. for(var m = 0; m < resources.length; m++) {
  238. //console.log(resources[m].caption);
  239. zlist = '<span>' + resources[m].resourceName + '</span>、';
  240. }
  241. var title = item.professor.title || "";
  242. var office = item.professor.office || "";
  243. var orgName = item.professor.orgName || "";
  244. var address = item.professor.address || "";
  245. if(title != "") {
  246. title = title + " , ";
  247. }
  248. if(office != "") {
  249. office = office + " , ";
  250. }
  251. if(orgName != "") {
  252. orgName = orgName;
  253. }
  254. if(address != "") {
  255. address = " | " + address;
  256. }
  257. var li = document.createElement('li');
  258. li.className = 'mui-table-view-cell mui-media';
  259. li.innerHTML = '<a class="proinfor" data-id="' + item.professor.id + '"' +
  260. '<p><img class="mui-media-object mui-pull-left headimg" src="' + img + '"></p>' +
  261. '<div class="mui-media-body">' +
  262. '<span class="listtit">' + item.professor.name + icon + '</span>' +
  263. '<p class="listtit2"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  264. '<p class="mui-ellipsis listtit3">' + rlist + '</p>' +
  265. '<p class="mui-ellipsis listtit3">' + zlist + '</p>' +
  266. '</div></a></li>';
  267. table.appendChild(li, table.firstChild);
  268. });
  269. }
  270. /*资源数据遍历*/
  271. function resourcesEach2(datalistd) {
  272. mui.each(datalistd, function(index, item) {
  273. /*获取头像*/
  274. if(item.resource.images.length) {
  275. var img = baseUrl + "/images/resource/" + item.resource.resourceId + ".jpg";
  276. } else {
  277. var img = "../images/default-resource.jpg";
  278. }
  279. /*判断用户是否认证*/
  280. var icont = '';
  281. if(item.resource.professor.authentication == true) {
  282. icont = '<em class="mui-icon iconfont icon-vip authicon"></em>';
  283. } else {
  284. icont = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
  285. }
  286. var title = item.resource.professor.title || "";
  287. var office = item.resource.professor.office || "";
  288. var orgName = item.resource.professor.orgName || "";
  289. var address = item.resource.professor.address || "";
  290. if(title != "") {
  291. title = title + " , ";
  292. }
  293. if(office != "") {
  294. office = office + " , ";
  295. }
  296. if(orgName != "") {
  297. orgName = orgName;
  298. }
  299. if(address != "") {
  300. address = " | " + address;
  301. }
  302. var li = document.createElement('li');
  303. li.className = 'mui-table-view-cell mui-media';
  304. li.innerHTML = '<a class="proinfor" data-id="' + item.resource.resourceId + '"' +
  305. '<p><img class="mui-media-object mui-pull-left resimg" src="' + img + '" ></p>' +
  306. '<div class="mui-media-body">' +
  307. '<span class="listtit">' + item.resource.resourceName + '</span>' +
  308. '<p class="mui-ellipsis listtit2">' + item.resource.supportedServices + '</p>' +
  309. '<span class="listtit">' + item.resource.professor.name + icont + '</span>' +
  310. '<p class="listtit3"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  311. '</div></a></li>';
  312. table1.appendChild(li, table1.firstChild);
  313. });
  314. }