feedback-records.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. document.querySelector('.mui-slider').addEventListener('slide', function(event) {
  134. var index = event.detail.slideNumber;
  135. if(index == 0){
  136. getAccountBackData(true);
  137. }else{
  138. getFeedbackData(true);
  139. }
  140. })
  141. $(".mui-control-item").on('tap', function(){
  142. var $this = $(this);
  143. if($this.hasClass("mui-active")){
  144. return false;
  145. }
  146. var index = $this.data("index");
  147. if(index == 1){
  148. getAccountBackData(true);
  149. }else{
  150. getFeedbackData(true);
  151. }
  152. });
  153. $(".mui-scroll-wrapper").on('tap', '.list-item', function(){
  154. var $this = $(this),
  155. type = $this.data('type'), // 1-账号申诉,2-意见反馈
  156. code = $this.data('code');
  157. window.location.href = "feedback-detail.html?type="+type+"&fdCode="+code;
  158. });
  159. template.helper('formatDate', function(time){
  160. if(time){
  161. return time.substr(0,16);
  162. }
  163. return "";
  164. });
  165. template.helper('getTypeValue', function(type, fdType){
  166. if(fdType == 1){
  167. switch(type){
  168. case 1:
  169. return "手机号变更";
  170. break;
  171. case 2:
  172. return "重置密码";
  173. break;
  174. case 3:
  175. return "其他";
  176. break;
  177. default:
  178. return "";
  179. break;
  180. }
  181. }else{
  182. switch(type){
  183. case 1:
  184. return "优化建议";
  185. break;
  186. case 2:
  187. return "提交bug";
  188. break;
  189. case 3:
  190. return "新功能建议";
  191. break;
  192. case 4:
  193. return "其他";
  194. break;
  195. default:
  196. return "";
  197. break;
  198. }
  199. }
  200. });
  201. template.helper("getStatus", function(status){
  202. switch(status){
  203. case 0:
  204. return "未读";
  205. break;
  206. case 1:
  207. return "待处理";
  208. break;
  209. case 2:
  210. return "已处理";
  211. break;
  212. }
  213. })
  214. }
  215. function queryFailed(res){
  216. d.close();
  217. if (res && res.msg) {
  218. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:res.msg}).show();
  219. }else{
  220. dialog({contentType:'tipsbox',bottom:true, skin:'bk-popup' , content:'请求失败'}).show();
  221. }
  222. }