juming-list.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. (function() {
  2. Vue.component('juming-list', {
  3. template: '<div class="div-juming-list">\
  4. <div class="div-juming-btn" v-show="isShowJumingBtn" @click="seeInfo"></div>\
  5. <div class="div-juming-bg" v-show="isShowJumingContent">\
  6. <div class="div-header-name fl">居民列表</div>\
  7. <div class="div-shousuo-btn" @click="shouSuoBtn"></div>\
  8. <div class="sk-spinner sk-spinner-chasing-dots" v-show="isShow" style="top: 50%;left:50%;margin-left:-0.1rem;margin-top: -0.1rem;position:absolute;">\
  9. <div class="sk-dot1"></div>\
  10. <div class="sk-dot2"></div>\
  11. </div>\
  12. <div id="wrapper1" style="overflow: hidden;" v-show="hasJumingList">\
  13. <div id="scroller1">\
  14. <div id="pullDown1" style="display:none;">\
  15. <div class="pullDownLabel"></div>\
  16. </div>\
  17. <div class="pulldown-tips">下拉刷新</div>\
  18. <div class="div-juming-content">\
  19. <div class="mt32" v-for="(juming,index) in jumingData" @click="personnalInfoDialog(juming.code)">\
  20. <div class="c-f20 c-B5E1FC">{{juming.name}}&ensp;({{juming.age}}&ensp;{{juming.sexName}}) &emsp;签约医生:{{juming.doctorName}}</div>\
  21. <div class="c-f20 c-B5E1FC mt8 height-20" v-if="juming.address == null">地址:暂无</div>\
  22. <div class="c-f20 c-B5E1FC mt8 height-20" v-else>{{juming.address}}</div>\
  23. </div>\
  24. </div>\
  25. <div id="pullUp1">\
  26. <div class="pullUpLabel">加载更多</div>\
  27. </div>\
  28. </div>\
  29. </div>\
  30. <div v-show="!hasJumingList" class="no-result-panel">\
  31. <div class="no-result-img">\
  32. <img src="../images/wushuju_icon.png">\
  33. </div>\
  34. <div class="no-result-text">查无数据</div>\
  35. </div>\
  36. </div>\
  37. </div>',
  38. props: [],
  39. data: function() {
  40. return {
  41. jumingData: [],
  42. isShowJumingBtn: false,
  43. isShowJumingContent: false,
  44. hasJumingList:true,
  45. keyword: null,
  46. page: 1,
  47. pageSize: 15,
  48. juMingScroll: null,
  49. isEnd: false,
  50. loadingStep: 0,
  51. isShow:false
  52. }
  53. },
  54. methods: {
  55. shouSuoBtn: function() {
  56. this.isShowJumingBtn = true;
  57. this.isShowJumingContent = false;
  58. },
  59. seeInfo: function() {
  60. this.isShowJumingBtn = true;
  61. this.isShowJumingContent = true;
  62. },
  63. personnalInfoDialog: function(patientCode) {
  64. var height = (0.42 * window.screen.width) + 'px';
  65. parent.layer.open({
  66. type: 2,
  67. title: false,
  68. shadeClose: true,
  69. shade: 0.5,
  70. area: ['60%', height],
  71. content: '../../../page/intelligentDevice/html/patient-info.html?patient='+patientCode
  72. });
  73. }
  74. },
  75. mounted: function() {
  76. var _self = this;
  77. var pullDown = $("#pullDown1"),
  78. pullUp = $("#pullUp1"),
  79. pullDownLabel = $("#pullDown1 .pullDownLabel"),
  80. pullUpLabel = $("#pullUp1 .pullUpLabel");
  81. //查询居民
  82. EventBus.$on('search-patient-info', function(arg) {
  83. var keyword = arg.keyword;
  84. _self.keyword = keyword;
  85. _self.isShowJumingBtn = true;
  86. _self.isShowJumingContent = true;
  87. _self.isShow = true;
  88. _self.isEnd = false;
  89. _self.page == 1
  90. getRequestData();
  91. });
  92. //更新居民信息
  93. EventBus.$on('update-patient-info', function(arg) {
  94. var patientData = JSON.parse(arg.patientData);
  95. patientData = _.map(patientData, function(data, index) {
  96. if(data.sex == 1) {
  97. data.sexName = "男";
  98. } else if(data.sex == 2) {
  99. data.sexName = "女";
  100. }
  101. return data;
  102. });
  103. _self.page = 1;
  104. _self.jumingData = patientData;
  105. _self.isShowJumingBtn = true;
  106. _self.isShowJumingContent = true;
  107. _self.isShow = false;
  108. _self.isEnd = true;
  109. setTimeout(function() {
  110. _self.juMingScroll.refresh();
  111. }, 300)
  112. });
  113. _self.juMingScroll = new IScroll("#wrapper1", {
  114. scrollbars: "custom",
  115. mouseWheel: true,
  116. interactiveScrollbars: true,
  117. shrinkScrollbars: false,
  118. fadeScrollbars: false,
  119. scrollY: true,
  120. probeType: 2,
  121. resizeScrollbars: false
  122. //bindToWrapper:true
  123. });
  124. _self.juMingScroll.on("scroll", function() {
  125. if(this.y > 40) { //下拉刷新操作
  126. $(".pulldown-tips").hide();
  127. pullDown.addClass("refresh").show();
  128. pullDownLabel.text("松手刷新数据");
  129. _self.loadingStep = 1;
  130. pullDownAction();
  131. } else if(this.y <= this.maxScrollY && !_self.isEnd) { //上拉加载更多
  132. pullUp.addClass("refresh").show();
  133. pullUpLabel.text("正在载入");
  134. _self.loadingStep = 1;
  135. pullUpAction();
  136. }
  137. });
  138. _self.juMingScroll.on("scrollEnd", function() {
  139. if(_self.loadingStep == 1) {
  140. if(pullDown.hasClass("refresh")) { //下拉刷新操作
  141. pullDown.removeClass("refresh").addClass("loading");
  142. pullDownLabel.text("正在刷新");
  143. _self.loadingStep = 2;
  144. pullDownAction();
  145. }
  146. }
  147. });
  148. document.addEventListener('touchmove', function(e) {
  149. e.preventDefault();
  150. }, false);
  151. //下拉刷新
  152. function pullDownAction() {
  153. setTimeout(function() {
  154. pullDown.hide();
  155. _self.isEnd = false;
  156. _self.page = 1;
  157. getRequestData();
  158. loadingStep = 0;
  159. $(".pulldown-tips").show();
  160. _self.juMingScroll.refresh();
  161. }, 400);
  162. }
  163. //上拉加载
  164. function pullUpAction() {
  165. if(!_self.isEnd) {
  166. setTimeout(function() {
  167. pullUp.hide();
  168. _self.page++;
  169. getRequestData(_self);
  170. _self.juMingScroll.refresh();
  171. loadingStep = 0;
  172. }, 400);
  173. }
  174. }
  175. function getRequestData() {
  176. //居民 医生搜索信息
  177. intelligentAPI.searchPatient({
  178. name: _self.keyword,
  179. page: _self.page,
  180. pageSize: _self.pageSize
  181. }).then(function(res) {
  182. if(res.status == 200) {
  183. var reqData = res.data;
  184. if(reqData.length > 0){
  185. _self.hasJumingList = true;
  186. }else{
  187. _self.hasJumingList = false;
  188. }
  189. reqData = _.map(reqData, function(data, index) {
  190. if(data.sex == 1) {
  191. data.sexName = "男";
  192. } else if(data.sex == 2) {
  193. data.sexName = "女";
  194. }
  195. return data;
  196. });
  197. if(_self.page == 1) {
  198. _self.jumingData = reqData;
  199. } else {
  200. var dataArr = _.map(reqData, function(data) {
  201. _self.jumingData.push(data);
  202. return data;
  203. })
  204. }
  205. if(reqData.length < _self.pageSize) {
  206. _self.isEnd = true;
  207. pullUpLabel.text("没有更多数据了...");
  208. }else{
  209. pullUpLabel.text("加载更多");
  210. }
  211. pullUpLabel.show();
  212. if(reqData.length==0){
  213. pullUpLabel.hide();
  214. }
  215. setTimeout(function() {
  216. _self.juMingScroll.refresh();
  217. }, 500)
  218. _self.isShow = false;
  219. } else {
  220. toastr.error(res.msg)
  221. }
  222. })
  223. }
  224. }
  225. })
  226. })()