Нет описания

attentions.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. //async:false,
  87. success: function(data) {
  88. console.log("1");
  89. if(data.success && data.data.data != "") {
  90. var datalist = data.data.data;
  91. datalistEach(datalist);
  92. }
  93. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  94. },
  95. error: function() {
  96. plus.nativeUI.toast("服务器链接超时", toastStyle);
  97. }
  98. });
  99. });
  100. }
  101. /*获取第一页资源数据*/
  102. function getOneResources(pageNo, pageSize) {
  103. mui.plusReady(function() {
  104. var userId = plus.storage.getItem('userid');
  105. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  106. data: {
  107. "professorId": userId,
  108. "watchType": 2,
  109. "pageNo": pageNo,
  110. "pageSize": pageSize
  111. },
  112. dataType: 'json', //数据格式类型
  113. type: 'GET', //http请求类型
  114. //timeout: 10000,
  115. //async:false,
  116. success: function(data) {
  117. console.log("2");
  118. if(data.success && data.data.data != "") {
  119. var datalistd = data.data.data;
  120. resourcesEach2(datalistd);
  121. }
  122. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  123. },
  124. error: function() {
  125. plus.nativeUI.toast("服务器链接超时", toastStyle);
  126. }
  127. });
  128. });
  129. }
  130. /*上拉刷新数据*/
  131. function expert2(pageNo, pageSize) {
  132. if(checkedindex == 0) {
  133. mui.plusReady(function() {
  134. var userId = plus.storage.getItem('userid');
  135. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  136. data: {
  137. "professorId": userId,
  138. "watchType": 1,
  139. "pageNo": pageNo,
  140. "pageSize": pageSize
  141. },
  142. dataType: 'json', //数据格式类型
  143. type: 'GET', //http请求类型
  144. timeout: 10000,
  145. //async:false,
  146. success: function(data) {
  147. console.log(data.success)
  148. if(data.success && data.data.data != "") {
  149. plus.nativeUI.closeWaiting();
  150. mui('#pullrefresh').pullRefresh().enablePullupToRefresh(); //启用上拉刷新
  151. var dice1 = data.data.total; //总条数
  152. var dice2 = data.data.pageSize; //每页条数
  153. allPages = Math.ceil(dice1 / dice2);
  154. if(allPages == 1) { //下拉刷新需要先清空数据
  155. table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
  156. }
  157. var datalist = data.data.data;
  158. datalistEach(datalist);
  159. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  160. if(pageNo < allPages) {
  161. mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
  162. } else {
  163. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
  164. }
  165. }
  166. },
  167. error: function() {
  168. plus.nativeUI.toast("服务器链接超时", toastStyle);
  169. }
  170. });
  171. });
  172. } else {
  173. mui.plusReady(function() {
  174. var userId = plus.storage.getItem('userid');
  175. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  176. data: {
  177. "professorId": userId,
  178. "watchType": 2,
  179. "pageNo": pageNo,
  180. "pageSize": pageSize
  181. },
  182. dataType: 'json', //数据格式类型
  183. type: 'GET', //http请求类型
  184. timeout: 10000,
  185. //async:false,
  186. success: function(data) {
  187. console.log(data.success)
  188. if(data.success && data.data.data != "") {
  189. plus.nativeUI.closeWaiting();
  190. mui('#pullrefresh').pullRefresh().enablePullupToRefresh(); //启用上拉刷新
  191. var dice1 = data.data.total; //总条数
  192. var dice2 = data.data.pageSize; //每页条数
  193. allPages = Math.ceil(dice1 / dice2);
  194. if(allPages == 1) { //下拉刷新需要先清空数据
  195. table.innerHTML = ''; // 在这里清空可以防止刷新时白屏
  196. }
  197. var datalist = data.data.data;
  198. resourcesEach2(datalist);
  199. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  200. if(pageNo < allPages) {
  201. mui('#pullrefresh').pullRefresh().endPullupToRefresh(false); //能上拉
  202. } else {
  203. mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); //不能上拉
  204. }
  205. }
  206. },
  207. error: function() {
  208. plus.nativeUI.toast("服务器链接超时", toastStyle);
  209. }
  210. });
  211. });
  212. }
  213. }
  214. /*专家数据遍历*/
  215. function datalistEach(datalist) {
  216. mui.each(datalist, function(index, item) {
  217. /*获取头像*/
  218. if(item.professor.hasHeadImage == 1) {
  219. var img = baseUrl + "/images/head/" + item.professor.id + "_m.jpg";
  220. } else {
  221. var img = "../images/default-photo.jpg";
  222. }
  223. /*获取研究方向信息*/
  224. var researchAreas = item.professor.researchAreas;
  225. //console.log(JSON.stringify(item.professor.researchAreas))
  226. var rlist = '';
  227. for(var n = 0; n < researchAreas.length; n++) {
  228. //console.log(researchAreas[n].caption);
  229. rlist = '<span>' + researchAreas[n].caption + '</span>、';
  230. }
  231. /*判断用户是否认证*/
  232. var icon = '';
  233. if(item.professor.authentication == true) {
  234. icon = '<em class="mui-icon iconfont icon-vip authicon"></em>';
  235. } else {
  236. icon = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
  237. }
  238. /*获取资源信息*/
  239. var resources = item.professor.resources;
  240. var zlist = '';
  241. for(var m = 0; m < resources.length; m++) {
  242. //console.log(resources[m].caption);
  243. zlist = '<span>' + resources[m].resourceName + '</span>、';
  244. }
  245. var title = item.professor.title || "";
  246. var office = item.professor.office || "";
  247. var orgName = item.professor.orgName || "";
  248. var address = item.professor.address || "";
  249. if(title != "") {
  250. title = title + " , ";
  251. }
  252. if(office != "") {
  253. office = office + " , ";
  254. }
  255. if(orgName != "") {
  256. orgName = orgName;
  257. }
  258. if(address != "") {
  259. address = " | " + address;
  260. }
  261. var li = document.createElement('li');
  262. li.className = 'mui-table-view-cell mui-media';
  263. li.innerHTML = '<a class="proinfor" data-id="' + item.professor.id + '"' +
  264. '<p><img class="mui-media-object mui-pull-left headimg headRadius" src="' + img + '"></p>' +
  265. '<div class="mui-media-body">' +
  266. '<span class="listtit">' + item.professor.name + icon + '</span>' +
  267. '<p class="listtit2"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  268. '<p class="mui-ellipsis listtit3">' + rlist + '</p>' +
  269. '<p class="mui-ellipsis listtit3">' + zlist + '</p>' +
  270. '</div></a></li>';
  271. table.appendChild(li, table.firstChild);
  272. });
  273. }
  274. /*资源数据遍历*/
  275. function resourcesEach2(datalistd) {
  276. mui.each(datalistd, function(index, item) {
  277. /*获取头像*/
  278. if(item.resource.images.length) {
  279. var img = baseUrl + "/images/resource/" + item.resource.resourceId + ".jpg";
  280. } else {
  281. var img = "../images/default-resource.jpg";
  282. }
  283. /*判断用户是否认证*/
  284. var icont = '';
  285. if(item.resource.professor.authentication == true) {
  286. icont = '<em class="mui-icon iconfont icon-vip authicon"></em>';
  287. } else {
  288. icont = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
  289. }
  290. var title = item.resource.professor.title || "";
  291. var office = item.resource.professor.office || "";
  292. var orgName = item.resource.professor.orgName || "";
  293. var address = item.resource.professor.address || "";
  294. if(title != "") {
  295. title = title + " , ";
  296. }
  297. if(office != "") {
  298. office = office + " , ";
  299. }
  300. if(orgName != "") {
  301. orgName = orgName;
  302. }
  303. if(address != "") {
  304. address = " | " + address;
  305. }
  306. var li = document.createElement('li');
  307. li.className = 'mui-table-view-cell mui-media';
  308. li.innerHTML = '<a class="proinfor" data-id="' + item.resource.resourceId + '"' +
  309. '<p><img class="mui-media-object mui-pull-left resimg" src="' + img + '" ></p>' +
  310. '<div class="mui-media-body">' +
  311. '<span class="listtit">' + item.resource.resourceName + '</span>' +
  312. '<p class="mui-ellipsis listtit2">' + item.resource.supportedServices + '</p>' +
  313. '<span class="listtit">' + item.resource.professor.name + icont + '</span>' +
  314. '<p class="listtit3"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  315. '</div></a></li>';
  316. table1.appendChild(li, table1.firstChild);
  317. plus.nativeUI.closeWaiting();
  318. plus.webview.currentWebview().show("slide-in-right", 150);
  319. });
  320. }