activity-square.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. mui.init();
  2. var d = dialog({contentType:'load', skin:'bk-popup'});
  3. var pagetype=55;
  4. (function(mui) {
  5. checkUserAgent();
  6. var unUserPage=userPage=1;//初始化页数
  7. var loadMoreNumber=15;//一次加载几条
  8. var useAgent=JSON.parse(window.localStorage.getItem(agentName));
  9. getTemplateHelper();
  10. !function(){
  11. var deceleration = mui.os.ios?0.003:0.0009;
  12. mui('.mui-scroll-wrapper').scroll({
  13. bounce: false,
  14. indicators: false, //是否显示滚动条
  15. deceleration:deceleration
  16. });
  17. mui.each(document.querySelectorAll('.mui-slider-group .mui-scroll-wrapper'), function(index, pullRefreshEl) {
  18. mui(pullRefreshEl).pullRefresh({
  19. down: {
  20. callback: function() {
  21. getIntegralList.call(this,index, false)
  22. }
  23. },
  24. up: {
  25. auto:true,
  26. callback : function() {
  27. getIntegralList.call(this,index,true)
  28. }
  29. }
  30. });
  31. });
  32. var request=GetRequest();
  33. if('selectIndex'in request){
  34. var selectIndex=request['selectIndex']|0
  35. if($('.integral-type').find('a').length<=selectIndex) return ;
  36. $('.integral-type').find('a').eq(selectIndex).addClass('mui-active').siblings('a').removeClass('mui-active');
  37. $('.mui-slider-item').eq(selectIndex).addClass('mui-active').siblings('div').removeClass('mui-active');
  38. $('.mui-slider-group').css({'transform': ('translate3d(-'+($('.mui-scroll').width()*selectIndex)+'px, 0px, 0px) translateZ(0px)'),'transition-duration': '0ms'});
  39. }
  40. }()
  41. function getIntegralList(index, isLoadMore){
  42. var self= this;
  43. var tradeDirection,__page,templateName,_url;
  44. var useAgent=JSON.parse(window.localStorage.getItem(agentName));
  45. var accountId=window.localStorage.getItem("accountId");
  46. var params;
  47. if(index===0){
  48. tradeDirection=1;
  49. unUserPage=__page=isLoadMore?unUserPage:1;
  50. templateName='li_tmpl';
  51. _url='patient/healthBank/selectTask';
  52. params={
  53. page:__page,
  54. size:loadMoreNumber,
  55. task:JSON.stringify({})
  56. }
  57. }else{
  58. tradeDirection=-1;
  59. userPage=__page=isLoadMore?userPage:1;
  60. templateName='li_tmpl_cy';
  61. _url='patient/healthBank/selectByPatient';
  62. params={
  63. page:__page,
  64. size:loadMoreNumber
  65. }
  66. }
  67. sendPost(_url, params, 'json', 'post',function(){
  68. if(isLoadMore){
  69. self.endPullupToRefresh();
  70. }else{
  71. self.endPulldownToRefresh();
  72. }
  73. airDialog('服务器繁忙,请稍后再试!')
  74. },function(res){
  75. var _data = res.data && res.data.detailModelList || [];
  76. for(var i=0,len=_data.length;i<len;i++){
  77. _data[i].endTime=_data[i].endTime.substr(5,5).replace(/-/g,'.');
  78. _data[i].startTime=_data[i].startTime.substr(0,10).replace(/-/g,'.');
  79. }
  80. html = template(templateName,{list: _data});
  81. var ul=self.element.querySelector('.activity-list');
  82. var length=res.data && res.data.detailModelList && res.data.detailModelList.length || 0;
  83. if(isLoadMore){//是否是上拉加载
  84. ul.innerHTML+=html;
  85. //加载完新数据后,必须执行如下代码,true表示没有更多数据了:
  86. if(length==0&&unUserPage==1){
  87. $('.mui-pull-caption-refresh').hide();
  88. $(ul).hide();
  89. $(ul).parents(".mui-slider-item").find('.div-no-info').removeClass("c-hide");
  90. }else{
  91. if(index===0) unUserPage++;
  92. else userPage++;
  93. }
  94. //
  95. self.endPullupToRefresh(length<loadMoreNumber);
  96. }else{
  97. ul.innerHTML=html;
  98. self.endPulldownToRefresh();
  99. }
  100. })
  101. }
  102. $(".activity-list").on('tap','.activity-list-item',function(){
  103. var code=$(this).data('code');
  104. location.href="./activity-detail.html?activity_id="+code;
  105. })
  106. })(mui);
  107. function airDialog(content){
  108. dialog({contentType:'tipsbox',top:true, skin:'bk-popup' , content:content}).show();
  109. }
  110. function goUrl(url){
  111. if(url) location.href=url;
  112. else airDialog('功能开发中,敬请期待!')
  113. }
  114. function getTemplateHelper(){
  115. template.helper("getImage", function(str){
  116. if(str){
  117. return getImgUrl(str);
  118. }else{
  119. return "../images/morenhuodong_banner01_img.png";
  120. }
  121. });
  122. template.helper("getStatusClass", function(status){
  123. if(status == "-1"){
  124. return "i-btn-gray disabled";
  125. }else{
  126. return "i-btn-success";
  127. }
  128. });
  129. template.helper("getStatusName", function(status){
  130. switch(parseInt(status)){
  131. case -1:
  132. return "已结束";
  133. break;
  134. case 0:
  135. return "进行中";
  136. break;
  137. case 1:
  138. return "报名中";
  139. break;
  140. }
  141. })
  142. }