Ei kuvausta

attentions.js 11KB

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