account-back-list.js 3.7 KB

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