feedback-records.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var page1 = 0,
  3. page2 = 0,
  4. pagesize = 10,
  5. idcard;
  6. mui.init();
  7. (function($) {
  8. //阻尼系数
  9. var deceleration = mui.os.ios?0.003:0.0009;
  10. $('.mui-scroll-wrapper').scroll({
  11. bounce: false,
  12. indicators: true, //是否显示滚动条
  13. deceleration:deceleration
  14. });
  15. $.ready(function() {
  16. //循环初始化所有下拉刷新,上拉加载。
  17. $.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
  18. $(pullRefreshEl).pullRefresh({
  19. up: {
  20. callback: function() {
  21. var self = this;
  22. setTimeout(function() {
  23. if(index == 0){
  24. getAccountBackData(false);
  25. }else{
  26. getFeedbackData(false);
  27. }
  28. self.endPullupToRefresh();
  29. }, 1000);
  30. }
  31. }
  32. });
  33. });
  34. getPatientInfo();
  35. bindEvents();
  36. });
  37. })(mui)
  38. function getPatientInfo(){
  39. var url = "/patient/baseinfo";
  40. sendPost(url, {}, 'json', 'post', queryFailed, function(res){
  41. if(res.status == 200){
  42. idcard = res.data.idcardAll;
  43. getAccountBackData(true);
  44. }else{
  45. queryFailed(res);
  46. }
  47. });
  48. }
  49. function getAccountBackData(isInit){
  50. if(isInit){
  51. page1 = 0;
  52. }
  53. var url = "/patientFeedback/feedback/findByIdcard",
  54. params = {
  55. idcard: idcard,
  56. page: page1,
  57. pagesize: pagesize
  58. };
  59. d.show();
  60. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  61. if(res.status == 200){
  62. if(res.list.length == 0){
  63. if(isInit){
  64. $("#no_result_wrap1").show();
  65. $("#result_wraper1").hide();
  66. }else{
  67. mui('#result_wraper1').pullRefresh().disablePullupToRefresh();
  68. }
  69. }else{
  70. $("#no_result_wrap1").hide();
  71. $("#result_wraper1").show();
  72. var html = template("list_tmp", {list: res.list, type: 1});
  73. if(isInit){
  74. $("#listPanel1").empty().append(html);
  75. }else{
  76. $("#listPanel1").append(html);
  77. }
  78. if(res.list.length < pagesize){
  79. mui('#result_wraper1').pullRefresh().disablePullupToRefresh();
  80. }else{
  81. page1 ++;
  82. mui('#result_wraper1').pullRefresh().enablePullupToRefresh();
  83. }
  84. }
  85. d.close();
  86. }else{
  87. queryFailed(res);
  88. }
  89. })
  90. }
  91. function getFeedbackData(isInit){
  92. if(isInit){
  93. page2 = 0;
  94. }
  95. var url = "/patient/feedback/findByCreater",
  96. params = {
  97. page: page2,
  98. pagesize: pagesize
  99. };
  100. d.show();
  101. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  102. if(res.status == 200){
  103. if(res.list.length == 0){
  104. if(isInit){
  105. $("#no_result_wrap2").show();
  106. $("#result_wraper2").hide();
  107. }else{
  108. mui('#result_wraper2').pullRefresh().disablePullupToRefresh();
  109. }
  110. }else{
  111. $("#no_result_wrap2").hide();
  112. $("#result_wraper2").show();
  113. var html = template("list_tmp", {list: res.list, type: 2});
  114. if(isInit){
  115. $("#listPanel2").empty().append(html);
  116. }else{
  117. $("#listPanel2").append(html);
  118. }
  119. if(res.list.length < pagesize){
  120. mui('#result_wraper2').pullRefresh().disablePullupToRefresh();
  121. }else{
  122. page2 ++;
  123. mui('#result_wraper2').pullRefresh().enablePullupToRefresh();
  124. }
  125. }
  126. d.close();
  127. }else{
  128. queryFailed(res);
  129. }
  130. });
  131. }
  132. function bindEvents(){
  133. $(".mui-control-item").on('tap', function(){
  134. var $this = $(this);
  135. if($this.hasClass("mui-active")){
  136. return false;
  137. }
  138. var index = $this.data("index");
  139. if(index == 1){
  140. getAccountBackData(true);
  141. }else{
  142. getFeedbackData(true);
  143. }
  144. });
  145. $(".mui-scroll-wrapper").on('tap', '.list-item', function(){
  146. var $this = $(this),
  147. type = $this.data('type'), // 1-账号申诉,2-意见反馈
  148. code = $this.data('code');
  149. window.location.href = "feedback-detail.html?type="+type+"&fdCode="+code;
  150. });
  151. template.helper('formatDate', function(time){
  152. if(time){
  153. return time.substr(0,16);
  154. }
  155. return "";
  156. });
  157. template.helper('getTypeValue', function(type, fdType){
  158. if(fdType == 1){
  159. switch(type){
  160. case 1:
  161. return "手机号变更";
  162. break;
  163. case 2:
  164. return "重置密码";
  165. break;
  166. case 3:
  167. return "其他";
  168. break;
  169. default:
  170. return "";
  171. break;
  172. }
  173. }else{
  174. switch(type){
  175. case 1:
  176. return "优化建议";
  177. break;
  178. case 2:
  179. return "提交bug";
  180. break;
  181. case 3:
  182. return "新功能建议";
  183. break;
  184. case 4:
  185. return "其他";
  186. break;
  187. default:
  188. return "";
  189. break;
  190. }
  191. }
  192. });
  193. template.helper("getStatus", function(status){
  194. switch(status){
  195. case 0:
  196. return "未读";
  197. break;
  198. case 1:
  199. return "待处理";
  200. break;
  201. case 2:
  202. return "已处理";
  203. break;
  204. }
  205. })
  206. }
  207. function queryFailed(res){
  208. d.close();
  209. if (res && res.msg) {
  210. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  211. }else{
  212. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  213. }
  214. }