search-xufang-order.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. mui.init();
  2. var $searchbarInput = $('#searchPut'),
  3. $searchSuggest = $('#search_suggest_text'),// 搜索框下面悬浮的搜索提示
  4. search_keyword = "",//记录搜索框的内容
  5. $noResultWrap = $('#no_result_wrap'),
  6. $searchResult = $('#search_result');
  7. $searchbarInput.focus();
  8. var page = 1,
  9. pageSize =10;
  10. mui.plusReady(function(){
  11. initScroller();
  12. bindEvents();
  13. });
  14. function getList(isInit){
  15. if(isInit){
  16. page = 1;
  17. $searchSuggest.text('');
  18. $searchSuggest.hide();
  19. }
  20. var url = "/doctor/prescriptionInfo/getPrescriptionByKeyWord",
  21. keyword = $.trim($("#searchPut").val()),
  22. params = {
  23. keyWord: keyword,
  24. pageNo: page,
  25. pageSize: pageSize
  26. };
  27. plus.nativeUI.showWaiting();
  28. sendGet(url, params, null, function(res){
  29. if(res.status == 200){
  30. if(isInit){
  31. mui('.mui-scroll-wrapper').scroll().scrollTo(0,0);
  32. if(res.data.length == 0){
  33. $("#iScroll").hide();
  34. $("#no_result_wrap").show();
  35. }else{
  36. $("#iScroll").show();
  37. $("#no_result_wrap").hide();
  38. var html = template("list-tmp", {list: res.data.list, keyword: keyword});
  39. $("#listPanel").empty().append(html);
  40. if(res.data.length < pageSize){
  41. mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true);
  42. }else{
  43. mui('.mui-scroll-wrapper').pullRefresh().refresh(true);
  44. page ++;
  45. }
  46. }
  47. }else{
  48. var html = template("list-tmp", {list: res.data.list, keyword: keyword});
  49. $("#listPanel").append(html);
  50. if(res.data.length < pageSize){
  51. mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(true);
  52. }else{
  53. mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh();
  54. page ++;
  55. }
  56. }
  57. }else{
  58. mui.toast(res.msg);
  59. }
  60. plus.nativeUI.closeWaiting();
  61. }, true);
  62. }
  63. function initScroller(){
  64. //阻尼系数
  65. var deceleration = mui.os.ios?0.003:0.0009;
  66. mui('.mui-scroll-wrapper').scroll({
  67. bounce: false,
  68. indicators: true, //是否显示滚动条
  69. deceleration:deceleration
  70. });
  71. mui(".mui-scroll-wrapper").pullRefresh({
  72. up: {
  73. callback: function(){
  74. var self = this;
  75. setTimeout(function(){
  76. getList(false);
  77. // self.endPullupToRefresh();
  78. }, 500);
  79. }
  80. }
  81. })
  82. }
  83. function bindEvents(){
  84. //监视输入
  85. $searchbarInput.on('input', function() {
  86. var text = $(this).val().trim();
  87. $searchResult.hide();
  88. $noResultWrap.hide();
  89. showSearchSuggest(text);
  90. }).on('keydown',function(e) {
  91. if (e.which === 13) {
  92. getList(true)
  93. }
  94. });
  95. $searchSuggest.on('click',function() {
  96. getList(true)
  97. });
  98. //取消
  99. $('.searchbar-cancel').on('click',function() {
  100. mui.back();
  101. });
  102. $("#listPanel").on('tap', ".order", function(){
  103. var code = $(this).attr("data-code");
  104. openWebview("xufangxiangqing2.html", {prescriptionCode: code});
  105. });
  106. template.helper("getStatusName", function(status){
  107. status = parseInt(status);
  108. if(status == 100){
  109. return "已完成";
  110. }else if(status == -2){
  111. return "居民取消";
  112. }else if(status == -1){
  113. return "审核不通过";
  114. }else if(status <= -3){
  115. return "其他原因取消";
  116. }else if(status >=0 && status<100){
  117. return "进行中";
  118. }
  119. });
  120. template.helper("hightlightKeyword", function(str, kw){
  121. var reg = new RegExp(kw+"(?!>)","gi");
  122. return str.replace(reg,'<em>'+kw+'</em>');
  123. });
  124. template.helper("getExpressName", function(type){
  125. switch(type){
  126. case 1:
  127. return '自取';
  128. break;
  129. case 3:
  130. return "健管师配送";
  131. break;
  132. case 2:
  133. return "快递配送";
  134. break;
  135. default:
  136. return "";
  137. break;
  138. }
  139. });
  140. template.helper("formatDate", function(str){
  141. if(!str){
  142. return "";
  143. }
  144. var timeStm = parseInt(str),
  145. d = new Date(timeStm);
  146. return d.format("yyyy-MM-dd hh:mm")
  147. })
  148. }
  149. // 控制搜索关键字悬浮提示的显示
  150. function showSearchSuggest(text) {
  151. var suggestText = '搜索“'+text+'”';
  152. // 如果text不为空,则显示;否则隐藏
  153. if(text&&text.trim().length) {
  154. $searchSuggest.text(suggestText);
  155. $searchSuggest.show();
  156. } else {
  157. $searchSuggest.text('');
  158. $searchSuggest.hide();
  159. }
  160. }