説明なし

attentions.js 11KB

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