No Description

attentions.js 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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. plus.nativeUI.closeWaiting();
  119. plus.webview.currentWebview().show("slide-in-right", 150);
  120. if(data.success && data.data.data != "") {
  121. var datalistd = data.data.data;
  122. resourcesEach2(datalistd);
  123. }
  124. mui('#pullrefresh').pullRefresh().refresh(true); //重置上拉加载
  125. },
  126. error: function() {
  127. plus.nativeUI.toast("服务器链接超时", toastStyle);
  128. }
  129. });
  130. });
  131. }
  132. /*上拉刷新数据*/
  133. function expert2(pageNo, pageSize) {
  134. if(checkedindex == 0) {
  135. mui.plusReady(function() {
  136. var userId = plus.storage.getItem('userid');
  137. mui.ajax(baseUrl + '/ajax/watch/qaPro', {
  138. data: {
  139. "professorId": userId,
  140. "watchType": 1,
  141. "pageNo": pageNo,
  142. "pageSize": pageSize
  143. },
  144. dataType: 'json', //数据格式类型
  145. type: 'GET', //http请求类型
  146. timeout: 10000,
  147. //async:false,
  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. //async:false,
  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. console.log(JSON.stringify(item));
  221. if(item.professor.hasHeadImage == 1) {
  222. var img = baseUrl + "/images/head/" + item.professor.id + "_m.jpg";
  223. } else {
  224. var img = "../images/default-photo.jpg";
  225. }
  226. /*获取研究方向信息*/
  227. var researchAreas = item.professor.researchAreas;
  228. //console.log(JSON.stringify(item.professor.researchAreas))
  229. var rlist = '';
  230. for(var n = 0; n < researchAreas.length; n++) {
  231. //console.log(researchAreas[n].caption);
  232. rlist = '<span>' + researchAreas[n].caption + '</span>';
  233. }
  234. /*判断用户是否认证*/
  235. var icon = '';
  236. console.log(item.professor.authType)
  237. if(item.professor.authType) {
  238. icon = '<em class="mui-icon iconfont icon-vip authicon-cu"></em>';
  239. } else {
  240. if(item.professor.authStatus){
  241. if(item.professor.authentication==1){
  242. icon = '<em class="mui-icon iconfont icon-renzheng authicon-mana"><span>科研</span></em>';
  243. }else if(item.professor.authentication==2){
  244. icon = '<em class="mui-icon iconfont icon-renzheng authicon-staff"><span>企业</span></em>';
  245. }else{
  246. icon = '<em class="mui-icon iconfont icon-renzheng authicon-stu"><span>学生</span></em>';
  247. }
  248. }
  249. }
  250. // if(item.professor.authentication == 1) {
  251. // icon = '<em class="mui-icon iconfont icon-vip authicon"></em>';
  252. // } else {
  253. // icon = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
  254. // }
  255. /*获取资源信息*/
  256. var resources = item.professor.resources;
  257. var zlist = '';
  258. for(var m = 0; m < resources.length; m++) {
  259. //console.log(resources[m].caption);
  260. zlist = '<span>' + resources[m].resourceName + '</span>';
  261. }
  262. var title = item.professor.title || "";
  263. var office = item.professor.office || "";
  264. var orgName = item.professor.orgName || "";
  265. var address = item.professor.address || "";
  266. if(title != "") {
  267. title = title + " , ";
  268. }
  269. if(office != "") {
  270. office = office + " , ";
  271. }
  272. if(orgName != "") {
  273. orgName = orgName;
  274. }
  275. if(address != "") {
  276. address = " | " + address;
  277. }
  278. var li = document.createElement('li');
  279. li.className = 'mui-table-view-cell mui-media';
  280. li.innerHTML = '<a class="proinfor" data-id="' + item.professor.id + '"' +
  281. '<p><img class="mui-media-object mui-pull-left headimg headRadius" src="' + img + '"></p>' +
  282. '<div class="mui-media-body">' +
  283. '<span class="listtit">' + item.professor.name + icon + '</span>' +
  284. '<p class="listtit2"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  285. '<p class="mui-ellipsis listtit3">' + rlist + '</p>' +
  286. '<p class="mui-ellipsis listtit3">' + zlist + '</p>' +
  287. '</div></a></li>';
  288. table.appendChild(li, table.firstChild);
  289. });
  290. }
  291. /*资源数据遍历*/
  292. function resourcesEach2(datalistd) {
  293. mui.each(datalistd, function(index, item) {
  294. /*获取头像*/
  295. if(item.resource.images.length) {
  296. var img = baseUrl + "/images/resource/" + item.resource.resourceId + ".jpg";
  297. } else {
  298. var img = "../images/default-resource.jpg";
  299. }
  300. /*判断用户是否认证*/
  301. var icont = '';
  302. if(item.resource.professor.authentication == 1) {
  303. icont = '<em class="mui-icon iconfont icon-vip authicon"></em>';
  304. } else {
  305. icont = '<em class="mui-icon iconfont icon-vip unauthicon"></em>';
  306. }
  307. var title = item.resource.professor.title || "";
  308. var office = item.resource.professor.office || "";
  309. var orgName = item.resource.professor.orgName || "";
  310. var address = item.resource.professor.address || "";
  311. if(title != "") {
  312. title = title + " , ";
  313. }
  314. if(office != "") {
  315. office = office + " , ";
  316. }
  317. if(orgName != "") {
  318. orgName = orgName;
  319. }
  320. if(address != "") {
  321. address = " | " + address;
  322. }
  323. var li = document.createElement('li');
  324. li.className = 'mui-table-view-cell mui-media';
  325. li.innerHTML = '<a class="proinfor" data-id="' + item.resource.resourceId + '"' +
  326. '<p><img class="mui-media-object mui-pull-left resimg" src="' + img + '" ></p>' +
  327. '<div class="mui-media-body">' +
  328. '<span class="listtit">' + item.resource.resourceName + '</span>' +
  329. '<p class="mui-ellipsis listtit2">' + item.resource.supportedServices + '</p>' +
  330. '<span class="listtit">' + item.resource.professor.name + icont + '</span>' +
  331. '<p class="listtit3"><span>' + title + '</span><span>' + office + '</span><span>' + orgName + '</span><span>' + address + '</span></p>' +
  332. '</div></a></li>';
  333. table1.appendChild(li, table1.firstChild);
  334. });
  335. }