question_result.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. var type,
  2. page = 1,
  3. pagesize = 15,
  4. hasMore = true;
  5. var surveyId, questionId, optionId;
  6. mui.init();
  7. mui.plusReady(function(){
  8. var self = plus.webview.currentWebview();
  9. type = self.type;
  10. surveyId = self.survey_id;
  11. questionId = self.question_id;
  12. optionId = self.option_id;
  13. var title = "";
  14. if(type == "question"){
  15. $("#op").hide();
  16. title = "填空题结果";
  17. }else{
  18. $("#op").show();
  19. title = "选项结果";
  20. }
  21. $(".demo-comtop").find("h1").text(title);
  22. getResponse(true);
  23. initScroll();
  24. });
  25. function initScroll(){
  26. //阻尼系数
  27. var deceleration = mui.os.ios?0.003:0.0009;
  28. mui('.mui-scroll-wrapper').scroll({
  29. bounce: false,
  30. indicators: true, //是否显示滚动条
  31. deceleration:deceleration
  32. });
  33. mui('.mui-scroll-wrapper').pullRefresh({
  34. up:{
  35. contentrefresh: '正在加载...',
  36. callback: function(){
  37. var self = this;
  38. setTimeout(function() {
  39. getResponse(false);
  40. mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(!hasMore);
  41. }, 1000);
  42. }
  43. }
  44. });
  45. }
  46. function getResponse(isInit){
  47. page = isInit ? 1 : page;
  48. var url = "/doctor/questionnaire/getOptionsComment",
  49. params = {id: surveyId, questionId: questionId, pageNo: page, pageSize: pagesize};
  50. if(type == "option"){
  51. params.optionId = optionId;
  52. }
  53. sendGet(url, params, null, function(res){
  54. if(res.status == 200){
  55. if(isInit){
  56. $("#q_title").text(res.data.title);
  57. $("#count").text(res.data.amount+"人");
  58. if(type == "option"){
  59. $("#op_name").text(res.data.option);
  60. }
  61. }
  62. var html = template("response_temp", {list: res.data.content});
  63. $("#result_list").append(html);
  64. if(res.data.content.length < pagesize){
  65. hasMore = false;
  66. isInit && mui('.mui-scroll-wrapper').pullRefresh().endPullupToRefresh(!hasMore);
  67. }
  68. }else{
  69. mui.toast(res.msg);
  70. }
  71. }, true);
  72. }
  73. template.helper("setIndex", function(k){
  74. return (page - 1)*pagesize + k +1;
  75. });