my-medicine-code.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. var page = 1,
  2. pageSize = 10;
  3. var d = dialog({contentType:'load', skin:'bk-popup'});
  4. var scroller,
  5. $mainContent = $('#mainContent'),
  6. $noData = $('.div-no-info');
  7. var userAgent = window.localStorage.getItem(agentName);
  8. var pagetype = 45;
  9. $(function(){
  10. checkUserAgent();
  11. scroller = new IScrollPullUpDown('wrapper',{
  12. probeType:2,
  13. bounceTime: 250,
  14. bounceEasing: 'quadratic',
  15. mouseWheel:false,
  16. scrollbars:true,
  17. click:true,
  18. fadeScrollbars:true,
  19. interactiveScrollbars:false
  20. },pullDownAction,pullUpAction);
  21. //下拉刷新
  22. function pullDownAction(theScrollerTemp) {
  23. d.show();
  24. setTimeout(function () {
  25. page=1;
  26. queryInit();
  27. }, 100)
  28. }
  29. //上拉加载数据
  30. function pullUpAction(theScrollerTemp) {
  31. d.show();
  32. setTimeout(function () {
  33. page++;
  34. queryMoreData();
  35. }, 100)
  36. }
  37. template.helper('toStatus', function(v){
  38. if(v==60){return 'waiting'}
  39. if(v==65 || v==61 || v==62 || v==69){return 'transport'}
  40. if(v==100){return 'finish'}
  41. })
  42. function queryMoreData(){
  43. var data = {
  44. page:page,
  45. pagesize:pageSize
  46. };
  47. d.show();
  48. sendPost("patient/prescription/dispensaryCode/list", data, "json", "get", function(res){ queryFailed(res)}, function(res){
  49. if(res.status == 200){
  50. d.close();
  51. if(res.result.length >0){
  52. var html = template('list_tmp',{data:res.result});
  53. $('#j-card-list').append(html);
  54. scroller.myScroll.refresh();
  55. }else{
  56. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'无更多数据'}).show();
  57. }
  58. }else{
  59. queryFailed(res)
  60. }
  61. })
  62. }
  63. $('#j-card-list').on('click','li',function(){
  64. var code=$(this).data('id');
  65. window.location.href ="code-detail.html?prescriptionCode="+code;
  66. })
  67. })
  68. function queryInit(){
  69. var data = {
  70. page:page,
  71. pagesize:pageSize
  72. };
  73. d.show();
  74. sendPost("patient/prescription/dispensaryCode/list", data, "json", "get", function(res){ queryFailed(res)}, function(res){
  75. if(res.status == 200){
  76. d.close();
  77. if(res.result.length >0){
  78. var html = template('list_tmp',{data:res.result});
  79. $('#j-card-list').html(html);
  80. $mainContent.show();
  81. }else{
  82. $noData.show();
  83. }
  84. scroller.myScroll.refresh();
  85. }else{
  86. queryFailed(res)
  87. }
  88. })
  89. }
  90. //失败提示
  91. function queryFailed(res){
  92. d.close();
  93. if (res && res.msg) {
  94. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  95. } else {
  96. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'加载失败'}).show();
  97. }
  98. }