account-back-list.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var page = 0,
  3. pagesize = 10;
  4. mui.init();
  5. (function($) {
  6. //阻尼系数
  7. var deceleration = mui.os.ios?0.003:0.0009;
  8. $('.mui-scroll-wrapper').scroll({
  9. bounce: false,
  10. indicators: true, //是否显示滚动条
  11. deceleration:deceleration
  12. });
  13. $('.mui-scroll-wrapper').pullRefresh({
  14. up: {
  15. callback: function() {
  16. var self = this;
  17. setTimeout(function() {
  18. getList(false);
  19. self.endPullupToRefresh();
  20. }, 1000);
  21. }
  22. }
  23. });
  24. bindEvents();
  25. })(mui);
  26. function getList(isInit){
  27. var idcard = $.trim($(".search-bar input").val());
  28. var url = "/patientFeedback/feedback/findByIdcard",
  29. params = {
  30. idcard: idcard,
  31. page: page,
  32. pagesize: pagesize
  33. };
  34. d.show();
  35. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  36. if(res.status == 200){
  37. if(res.list.length == 0){
  38. if(isInit){
  39. $("#no_result_wrap").show();
  40. $(".mui-scroll-wrapper").hide();
  41. }else{
  42. mui('.mui-scroll-wrapper').pullRefresh().disablePullupToRefresh();
  43. }
  44. }else{
  45. $("#no_result_wrap").hide();
  46. $(".mui-scroll-wrapper").show();
  47. var html = template("item_temp", {list: res.list});
  48. if(isInit){
  49. $("#result_wrap").empty().append(html);
  50. }else{
  51. $("#result_wrap").append(html);
  52. }
  53. if(res.list.length < pagesize){
  54. mui('.mui-scroll-wrapper').pullRefresh().disablePullupToRefresh();
  55. }else{
  56. mui('.mui-scroll-wrapper').pullRefresh().enablePullupToRefresh();
  57. page ++;
  58. }
  59. }
  60. d.close();
  61. }else{
  62. queryFailed(res);
  63. }
  64. });
  65. }
  66. function bindEvents(){
  67. $("#search").on('tap', function(){
  68. var idcard = $(".search-bar input").val();
  69. if(idcard.length == 0){
  70. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请输入身份证号'}).show();
  71. return false;
  72. }
  73. if (!/^[1-9][0-9]{5}(19[0-9]{2}|200[0-9]|2010)(0[1-9]|1[0-2])(0[1-9]|[12][0-9]|3[01])[0-9]{3}[0-9xX]$/i.test(idcard)) {
  74. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'身份证号格式错误'}).show();
  75. return false;
  76. }
  77. getList(true);
  78. });
  79. $("body").on("tap", ".list-item", function(){
  80. var $this = $(this),
  81. code = $this.data("code");
  82. window.location.href = "feedback-detail.html?type=1&fdCode="+code;
  83. });
  84. template.helper('formatDate', function(time){
  85. if(time){
  86. return time.substr(0,16);
  87. }
  88. return "";
  89. });
  90. template.helper('getTypeValue', function(type){
  91. switch(type){
  92. case 1:
  93. return "手机号变更";
  94. break;
  95. case 2:
  96. return "重置密码";
  97. break;
  98. case 3:
  99. return "其他";
  100. break;
  101. default:
  102. return "";
  103. break;
  104. }
  105. });
  106. template.helper("getStatus", function(status){
  107. switch(status){
  108. case 0:
  109. return "未读";
  110. break;
  111. case 1:
  112. return "待处理";
  113. break;
  114. case 2:
  115. return "已处理";
  116. break;
  117. }
  118. })
  119. }
  120. function queryFailed(res){
  121. d.close();
  122. if (res && res.msg) {
  123. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  124. }else{
  125. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  126. }
  127. }