survey_list.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. var page = 1,
  2. pagesize = 15,
  3. hasMore = true;
  4. mui.init();
  5. mui.plusReady(function(){
  6. getList(true);
  7. initScroll();
  8. bindEvents();
  9. });
  10. function initScroll(){
  11. //阻尼系数
  12. var deceleration = mui.os.ios?0.003:0.0009;
  13. mui('.mui-scroll-wrapper').scroll({
  14. bounce: false,
  15. indicators: true, //是否显示滚动条
  16. deceleration:deceleration
  17. });
  18. mui('.mui-scroll-wrapper').pullRefresh({
  19. down: {
  20. callback: function() {
  21. setTimeout(function() {
  22. getList(true);
  23. mui('.mui-scroll-wrapper').pullRefresh().endPulldownToRefresh();
  24. }, 1000);
  25. }
  26. },
  27. up:{
  28. contentrefresh: '正在加载...',
  29. callback: function(){
  30. var self = this;
  31. setTimeout(function() {
  32. getList(false);
  33. mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(!hasMore);
  34. }, 1000);
  35. }
  36. }
  37. });
  38. }
  39. function getList(isInit){
  40. page = isInit ? 1 : page;
  41. plus.nativeUI.showWaiting();
  42. var url = "doctor/questionnaire/getQuestionnaireList",
  43. params = {pageNo: page, pageSize: pagesize};
  44. sendGet(url, params, null, function(res){
  45. if(res.status == 200){
  46. if(isInit && res.data.length == 0){
  47. $("#no_result_wrap").show();
  48. $(".mui-scroll-wrapper").hide();
  49. }else{
  50. page ++;
  51. $("#no_result_wrap").hide();
  52. $(".mui-scroll-wrapper").show();
  53. if(res.data.length < pagesize){
  54. hasMore = false;
  55. isInit && mui(".mui-scroll-wrapper").pullRefresh().endPullupToRefresh(!hasMore);
  56. }else{
  57. hasMore = true;
  58. }
  59. var html = template("list_tmp", {list: res.data});
  60. if(isInit){
  61. $("#survey_list").empty().append(html);
  62. }else{
  63. $("#survey_list").append(html);
  64. }
  65. }
  66. }else{
  67. mui.toast(res.msg);
  68. }
  69. plus.nativeUI.closeWaiting();
  70. }, true);
  71. }
  72. function bindEvents(){
  73. $(".header-link").on('tap', function(){
  74. var templateList = plus.webview.getWebviewById("template_list");
  75. if(templateList){
  76. mui.fire(templateList, "refresh");
  77. openWebview("template_list.html");
  78. }else{
  79. openWebview("template_list.html");
  80. }
  81. });
  82. $("body").on("tap", "li", function(){
  83. var surveyId = $(this).attr("data-code");
  84. openWebview("survey_info.html", {code : surveyId});
  85. });
  86. window.addEventListener('refresh', function(){
  87. getList(true);
  88. });
  89. }
  90. template.helper("setPhoto", function(p) {
  91. return getImgUrl(p);
  92. });