article-store.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. mui.init();
  2. var isAdmin,
  3. patient = null, //从居民页面或IM页面跳转过来的时候,需要传递居民信息
  4. patientName ="",
  5. teamCode = "",
  6. pCodes, //从慢病管理页面中跳转过来的多个居民的code
  7. referrer;
  8. var subPages = ["article-list.html", "article-sent.html"];
  9. var subStyles = {
  10. top: "45px",
  11. bottom: "40px",
  12. scorllIndicator: "none",
  13. bounceBackground: "#17b3ec"
  14. };
  15. var selectedTab = 0;
  16. mui.plusReady(function(){
  17. var self = plus.webview.currentWebview();
  18. isAdmin = self.isAdmin;
  19. patient = self.patient;
  20. patientName = self.patientName;
  21. teamCode = self.teamCode;
  22. pCodes = self.pCodes;
  23. referrer = self.referrer;
  24. getFirstLevelCategory();
  25. bindEvents();
  26. });
  27. function getFirstLevelCategory(){
  28. var url = "/third/jkEdu/Article/getCategoryList",
  29. params = {categoryLevel: 1};
  30. sendGet(url, params, null, function(res){
  31. if(res.status == 200){
  32. var list = res.data.reverse();
  33. var html = template("cat-tmp", {list: list});
  34. $("footer").empty().append(html);
  35. var wv = mui.openWindow({
  36. url: subPages[0],
  37. id: subPages[0]+selectedTab,
  38. styles:subStyles,
  39. waiting:{
  40. autoShow:true,//自动显示等待框,默认为true
  41. title:'正在加载...'//等待对话框上显示的提示内容
  42. },
  43. extras:{
  44. firstLevelId: list[0].categoryid,
  45. isAdmin: isAdmin,
  46. patient: patient,
  47. patientName: patientName,
  48. teamCode: teamCode,
  49. pCodes: pCodes,
  50. referrer: referrer
  51. }
  52. });
  53. var self = plus.webview.currentWebview();
  54. self.append(wv);
  55. }else{
  56. mui.toast(res.msg);
  57. }
  58. }, true)
  59. }
  60. function bindEvents(){
  61. $(".header-link").on("click",'.shoucang-btn',function(){
  62. openWebview("my-store2.html", {
  63. isAdmin: isAdmin,
  64. patient: patient,
  65. patientName: patientName,
  66. pCodes: pCodes,
  67. referrer: referrer
  68. });
  69. }).on("click",'.search-btn',function(){
  70. var $tab = $(".cat-level-1.active"),
  71. categoryId = $tab.attr("data-id"),
  72. isSent = false;
  73. if(categoryId == 'sent'){
  74. isSent = true;
  75. }
  76. openWebviewExtras("search_article.html",{
  77. type:0,
  78. isAdmin: isAdmin,
  79. patient: patient,
  80. patientName: patientName,
  81. isSent: isSent,
  82. firstCatId: categoryId,
  83. pCodes: pCodes,
  84. referrer: referrer
  85. });
  86. });
  87. $("footer").on('click', '.cat-level-1', function(){
  88. if($(this).hasClass("active")){
  89. return false;
  90. }
  91. selectedTab = $(this).index();
  92. $(".cat-level-1").removeClass("active");
  93. $(this).addClass("active");
  94. var categoryId = $(this).attr("data-id");
  95. if(categoryId == "sent"){
  96. var wv1 = plus.webview.getWebviewById(subPages[1]);
  97. if(wv1){
  98. wv1.show();
  99. }else{
  100. var wv = mui.openWindow({
  101. url: subPages[1],
  102. id: subPages[1],
  103. styles:subStyles,
  104. waiting:{
  105. autoShow:true,//自动显示等待框,默认为true
  106. title:'正在加载...'//等待对话框上显示的提示内容
  107. },
  108. extras:{
  109. isAdmin: isAdmin,
  110. patient: patient,
  111. patientName: patientName,
  112. pCodes: pCodes,
  113. referrer: referrer
  114. }
  115. });
  116. var self = plus.webview.currentWebview();
  117. self.append(wv);
  118. }
  119. }else{
  120. var wv2 = plus.webview.getWebviewById(subPages[0]+selectedTab);
  121. if(wv2){
  122. wv2.show();
  123. }else{
  124. var wv = mui.openWindow({
  125. url: subPages[0],
  126. id: subPages[0]+selectedTab,
  127. styles:subStyles,
  128. waiting:{
  129. autoShow:true,//自动显示等待框,默认为true
  130. title:'正在加载...'//等待对话框上显示的提示内容
  131. },
  132. extras:{
  133. firstLevelId: categoryId,
  134. isAdmin: isAdmin,
  135. patient: patient,
  136. patientName: patientName,
  137. pCodes: pCodes,
  138. referrer: referrer
  139. }
  140. });
  141. var self = plus.webview.currentWebview();
  142. self.append(wv);
  143. }
  144. }
  145. });
  146. window.addEventListener('reload', function(){
  147. var $activeWv = $(".cat-level-1.active"),
  148. categoryId = $activeWv.attr("data-id"),
  149. selectedTab = $activeWv.index();
  150. if(categoryId == "sent"){
  151. var wv1 = plus.webview.getWebviewById(subPages[1]);
  152. mui.fire(wv1, 'reload');
  153. }else{
  154. var wv2 = plus.webview.getWebviewById(subPages[0] + selectedTab);
  155. mui.fire(wv2, 'reload');
  156. }
  157. })
  158. }