article-sent.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. mui.init();
  2. var page = 0,
  3. pageSize = 10,
  4. patient,
  5. patientName,
  6. isAdmin,
  7. pCodes, //从慢病管理页面中跳转过来的多个居民的code
  8. referrer;
  9. mui.plusReady(function(){
  10. var self = plus.webview.currentWebview();
  11. isAdmin = self.isAdmin;
  12. patient = self.patient;
  13. patientName = self.patientName;
  14. pCodes = self.pCodes;
  15. referrer = self.referrer;
  16. initScroller();
  17. getArticleList(true);
  18. bindEvents();
  19. })
  20. function getArticleList(isInit){
  21. if(isInit){
  22. page = 0;
  23. }
  24. var docInfo = JSON.parse(plus.storage.getItem("docInfo"));
  25. var url = "doctor/jkEdu/article/PC/pushArticleList",
  26. params = {
  27. sendType: isAdmin? 2 : 1, //1医生 2卫计委(管理员)
  28. iDisplayStart: page * pageSize,
  29. iDisplayLength: pageSize,
  30. currentRoleCode: docInfo.hospital,
  31. currentRoleLevel: 4
  32. };
  33. if(isAdmin){
  34. var selectedRole = JSON.parse(plus.storage.getItem("selectedRole"));
  35. params.currentRoleCode = selectedRole.code;
  36. params.currentRoleLevel = selectedRole.level;
  37. }
  38. sendGet(url, params, null, function(res){
  39. if(res.status > 0){
  40. var list = res.data.aaData;
  41. if(isInit){
  42. if(list.length == 0){
  43. $(".mui-table-view").hide();
  44. $(".no-result").show();
  45. }else{
  46. var html = template("articleimgLi", {list: list});
  47. $(".mui-table-view").empty().append(html);
  48. }
  49. }else{
  50. var html = template("articleimgLi", {list: list});
  51. $(".mui-table-view").append(html);
  52. }
  53. if(list.length < pageSize){
  54. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(true);
  55. }else{
  56. page ++;
  57. mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(false);
  58. }
  59. }else{
  60. mui.toast(res.message);
  61. }
  62. }, true);
  63. }
  64. function bindEvents(){
  65. $("body").on('tap', ".article-info", function(){
  66. var code = $(this).attr("data-article-code");
  67. var title = $(this).attr('data-title');
  68. if(isAdmin){
  69. openWebviewExtras("../../home/html/jianjiaotuisong-xiangqing.html",{articleId:code});
  70. }else{
  71. openWebview("article-info.html", {
  72. articleId: code,
  73. patient: patient,
  74. patientName: patientName,
  75. showHandleBar: true,
  76. pCodes: self.pCodes,
  77. referrer: self.referrer
  78. });
  79. }
  80. return false;
  81. });
  82. template.helper("setContent", function(str){
  83. if(str){
  84. var reg=/<[^<>]+>/g;
  85. str = str.replace(reg, '');
  86. return str;
  87. }else{
  88. return "";
  89. }
  90. });
  91. template.helper("getArticleImage", function(str){
  92. if(str){
  93. if(str.indexOf("../") > -1){
  94. return ""; //原福州代码中返回的相对路径
  95. }
  96. var url = getImgUrl(str);
  97. return "<img src='"+url+"'>";
  98. }
  99. return "";
  100. });
  101. window.addEventListener('reload', function(){
  102. getArticleList(true);
  103. })
  104. }
  105. function initScroller(){
  106. //阻尼系数
  107. var deceleration = mui.os.ios?0.003:0.0009;
  108. mui('.mui-scroll-wrapper').scroll({
  109. bounce: false,
  110. indicators: true, //是否显示滚动条
  111. deceleration:deceleration
  112. });
  113. mui(".mui-scroll-wrapper").pullRefresh({
  114. down: {
  115. callback: function(){
  116. getArticleList(true);
  117. this.endPulldownToRefresh();
  118. }
  119. },
  120. up: {
  121. callback: function(){
  122. var self = this;
  123. setTimeout(function(){
  124. getArticleList(false);
  125. }, 500);
  126. }
  127. }
  128. })
  129. }