feedback-records.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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. getFeedbackData(true);
  45. }else{
  46. queryFailed(res);
  47. }
  48. });
  49. }
  50. function getAccountBackData(isInit){
  51. if(isInit){
  52. page1 = 0;
  53. }
  54. var url = "/patientFeedback/feedback/findByIdcard",
  55. params = {
  56. idcard: idcard,
  57. page: page1,
  58. pagesize: pagesize
  59. };
  60. d.show();
  61. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  62. if(res.status == 200){
  63. if(res.list.length == 0){
  64. if(isInit){
  65. $("#no_result_wrap1").show();
  66. $("#result_wraper1").hide();
  67. }else{
  68. mui('#result_wraper1').pullRefresh().disablePullupToRefresh();
  69. }
  70. }else{
  71. $("#no_result_wrap1").hide();
  72. $("#result_wraper1").show();
  73. var html = template("list_tmp", {list: res.list, type: 1});
  74. if(isInit){
  75. $("#listPanel1").empty().append(html);
  76. }else{
  77. $("#listPanel1").append(html);
  78. }
  79. if(res.list.length < pagesize){
  80. mui('#result_wraper1').pullRefresh().disablePullupToRefresh();
  81. }else{
  82. page1 ++;
  83. mui('#result_wraper1').pullRefresh().enablePullupToRefresh();
  84. }
  85. }
  86. d.close();
  87. }else{
  88. queryFailed(res);
  89. }
  90. })
  91. }
  92. function getFeedbackData(isInit){
  93. if(isInit){
  94. page2 = 0;
  95. }
  96. var url = "/patient/feedback/findByCreater",
  97. params = {
  98. page: page2,
  99. pagesize: pagesize
  100. };
  101. d.show();
  102. sendPost(url, params, 'json', 'get', queryFailed, function(res){
  103. if(res.status == 200){
  104. if(res.list.length == 0){
  105. if(isInit){
  106. $("#no_result_wrap2").show();
  107. $("#result_wraper2").hide();
  108. }else{
  109. mui('#result_wraper2').pullRefresh().disablePullupToRefresh();
  110. }
  111. }else{
  112. $("#no_result_wrap2").hide();
  113. $("#result_wraper2").show();
  114. var html = template("list_tmp", {list: res.list, type: 2});
  115. if(isInit){
  116. $("#listPanel2").empty().append(html);
  117. }else{
  118. $("#listPanel2").append(html);
  119. }
  120. if(res.list.length < pagesize){
  121. mui('#result_wraper2').pullRefresh().disablePullupToRefresh();
  122. }else{
  123. page2 ++;
  124. mui('#result_wraper2').pullRefresh().enablePullupToRefresh();
  125. }
  126. }
  127. d.close();
  128. }else{
  129. queryFailed(res);
  130. }
  131. });
  132. }
  133. function bindEvents(){
  134. $(".mui-control-item").on('tap', function(){
  135. var $this = $(this);
  136. if($this.hasClass("mui-active")){
  137. return false;
  138. }
  139. var index = $this.data("index");
  140. if(index == 1){
  141. getAccountBackData(true);
  142. }else{
  143. getFeedbackData(true);
  144. }
  145. });
  146. $(".mui-scroll-wrapper").on('tap', '.list-item', function(){
  147. var $this = $(this),
  148. type = $this.data('type'), // 1-账号申诉,2-意见反馈
  149. code = $this.data('code');
  150. window.location.href = "feedback-detail.html?type="+type+"&fdCode="+code;
  151. });
  152. template.helper('formatDate', function(time){
  153. if(time){
  154. return time.substr(0,16);
  155. }
  156. return "";
  157. });
  158. template.helper('getTypeValue', function(type, fdType){
  159. if(fdType == 1){
  160. switch(type){
  161. case 1:
  162. return "手机号变更";
  163. break;
  164. case 2:
  165. return "重置密码";
  166. break;
  167. case 3:
  168. return "其他";
  169. break;
  170. default:
  171. return "";
  172. break;
  173. }
  174. }else{
  175. switch(type){
  176. case 1:
  177. return "优化建议";
  178. break;
  179. case 2:
  180. return "提交bug";
  181. break;
  182. case 3:
  183. return "新功能建议";
  184. break;
  185. case 4:
  186. return "其他";
  187. break;
  188. default:
  189. return "";
  190. break;
  191. }
  192. }
  193. });
  194. template.helper("getStatus", function(status){
  195. switch(status){
  196. case 0:
  197. return "未读";
  198. break;
  199. case 1:
  200. return "待处理";
  201. break;
  202. case 2:
  203. return "已处理";
  204. break;
  205. }
  206. })
  207. }
  208. function queryFailed(res){
  209. d.close();
  210. if (res && res.msg) {
  211. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  212. }else{
  213. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  214. }
  215. }