my-activities.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. var pagetype=54;
  2. var useAgent=JSON.parse(window.localStorage.getItem(agentName));
  3. var accountId=window.localStorage.getItem("accountId");
  4. var page=1;
  5. var loadMoreNumber=15;
  6. var __that;
  7. var __index=-1;
  8. window.localStorage.removeItem('activeteCode');
  9. !function(){
  10. mui.init({
  11. pullRefresh : {
  12. container:"#refreshContainer",//下拉刷新容器标识,querySelector能定位的css选择器均可,比如:id、.class等
  13. down : {
  14. style:'circle',//必选,下拉刷新样式,目前支持原生5+ ‘circle’ 样式
  15. color:'#2BD009', //可选,默认“#2BD009” 下拉刷新控件颜色
  16. height:'50px',//可选,默认50px.下拉刷新控件的高度,
  17. range:'100px', //可选 默认100px,控件可下拉拖拽的范围
  18. offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
  19. height:50,//可选,默认50.触发下拉刷新拖动距离,
  20. contentdown : "下拉可以刷新",//可选,在下拉可刷新状态时,下拉刷新控件上显示的标题内容
  21. contentover : "释放立即刷新",//可选,在释放可刷新状态时,下拉刷新控件上显示的标题内容
  22. contentrefresh : "正在刷新...",//可选,正在刷新状态时,下拉刷新控件上显示的标题内容
  23. callback :function(){
  24. getMoreList.call(this,false) //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务
  25. }
  26. },
  27. up : {
  28. height:50,//可选.默认50.触发上拉加载拖动距离
  29. auto:true,//可选,默认false.自动上拉加载一次
  30. contentrefresh : "正在加载...",//可选,正在加载状态时,上拉加载控件上显示的标题内容
  31. contentnomore:'没有更多数据了',//可选,请求完毕若没有更多数据时显示的提醒内容;
  32. callback :function(){
  33. __that=this;
  34. getMoreList.call(this,true) //必选,刷新函数,根据具体业务来编写,比如通过ajax从服务器获取新数据;
  35. }
  36. }
  37. }
  38. });
  39. }()
  40. function togglemenu(obj,id){
  41. if(obj!==undefined){
  42. if(__index==obj) return $('.i-dropdown-menu').toggleClass('i-dropdown-menu-open');
  43. __index=obj;
  44. page=1;
  45. var current=$((event || window.event).target);
  46. current.addClass('activity-active').siblings().removeClass('activity-active');
  47. $('#pageTitle').html(obj>=0?current.html():'选择活动')
  48. if(obj>=0){
  49. $('.activity-nav').removeClass('is-show-nav');
  50. window.localStorage.setItem('activeteCode',id)
  51. }else{
  52. $('.activity-nav').addClass('is-show-nav');
  53. window.localStorage.removeItem('activeteCode')
  54. }
  55. getMoreList.call(__that,false);
  56. }
  57. $('.i-dropdown-menu').toggleClass('i-dropdown-menu-open');
  58. }
  59. function getMoreList(isLoadMore) {
  60. var self=this;
  61. var __page=page=isLoadMore?page:1;
  62. var _url,params;
  63. var code=window.localStorage.getItem('activeteCode');
  64. $('.div-no-info').addClass('c-hide');
  65. if(code){
  66. $('.mui-pull-bottom-pocket').addClass('mui-block mui-visibility')
  67. _url='patient/healthBank/selectByActivity';
  68. params={
  69. creditsLogDo : JSON.stringify({"accountId":accountId}),
  70. page : __page,
  71. activityId:code,
  72. patientId:useAgent.uid,
  73. size : loadMoreNumber
  74. };
  75. }else{
  76. params={
  77. creditsLogDo : JSON.stringify({"accountId":accountId}),
  78. page : __page,
  79. size : loadMoreNumber
  80. };
  81. }
  82. sendPost((_url || 'patient/healthBank/selectDetails'), params, 'json', 'post',function(){
  83. if(isLoadMore){
  84. self.endPullupToRefresh();
  85. }else{
  86. self.endPulldownToRefresh();
  87. }
  88. },function(res){
  89. html = template('li_tmpl',{list: res.data.detailModelList});
  90. var ul=self.element.querySelector('.integral-list');
  91. var length=res.data.detailModelList.length || 0;
  92. !length && $('.div-no-info').removeClass('c-hide') && (__page==1 && $('.mui-pull-bottom-pocket').removeClass('mui-block mui-visibility'));
  93. if(isLoadMore){//是否是上拉加载
  94. //加载完新数据后,必须执行如下代码,true表示没有更多数据了:
  95. var noData=(length<loadMoreNumber);
  96. ul.innerHTML+=html;
  97. self.endPullupToRefresh(noData);
  98. }else{
  99. ul.innerHTML=html;
  100. self.endPulldownToRefresh();
  101. }
  102. })
  103. }
  104. function pullfresh() {
  105. var that=this;
  106. setTimeout(function(){
  107. //没有更多内容了,endPulldown 传入true, 不再执行下拉刷新
  108. that.endPulldownToRefresh();
  109. },1000)
  110. }
  111. // 活动列表
  112. !function(){
  113. var params={
  114. page:1,
  115. size:10,
  116. task:JSON.stringify({}),
  117. }
  118. sendPost('patient/healthBank/selectTask', params, 'json', 'post',function(){
  119. airDialog("系统繁忙,请稍后再试!")
  120. },function(res){
  121. if(res.status==200){
  122. var _data = res.data && res.data.detailModelList || [];
  123. $(".dropdown-list").append(template('activity_list_tmpl',{list: _data}));
  124. }else{
  125. $('.activity-swiper').find('.div-no-info').removeClass('c-hide');
  126. }
  127. })
  128. }()