index.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. var d = dialog({contentType:'load', skin:'bk-popup'});
  2. var pagetype=51;
  3. var regionalRestrictions="350205";//地区限制,开放所有就改为空字符串
  4. (function(){
  5. var swiperLength=$(".fuwu-swiper .swiper-wrapper").children().length;
  6. if(swiperLength>1){
  7. var swiper = new Swiper('.fuwu-swiper', {
  8. pagination: '.swiper-pagination',
  9. paginationClickable: true,
  10. spaceBetween: 10,
  11. centeredSlides: true,
  12. autoplay: 500,
  13. autoplayDisableOnInteraction: false
  14. });
  15. }
  16. if(!$(".health-shop").parents(".i-panel").hasClass("c-hide")){
  17. var inifateLeft = (function(){//水平滚动代码
  18. var scrollDiv=$('.new-news-scroll');
  19. var speend=40
  20. var obj=$(".new-news-list")
  21. var html=obj.html();
  22. obj.html(html+html);
  23. var maxLeft=obj.width();
  24. var left=0;
  25. return function(){
  26. setTimeout(function(){
  27. left++;
  28. if(left==maxLeft/2) left=0;
  29. scrollDiv.scrollLeft(left)
  30. inifateLeft();
  31. },speend)
  32. }
  33. })()
  34. inifateLeft()
  35. var mySwiper = new Swiper ('.health-shop', {
  36. direction: 'horizontal',
  37. loop: true,
  38. slidesPerView: 1.5,
  39. centeredSlides:true,
  40. spaceBetween: 15,
  41. })
  42. }
  43. })();
  44. (function(){
  45. checkUserAgent();
  46. var request=GetRequest();
  47. if(('acquisition' in request)&&(location.hash.indexOf("acquisitionFlag")===-1)){//判断是推送消息过来的,并且防止用户刷新页面
  48. dialog({quickClose: true,skin:'bk-transparent', content:'<div style="position: relative;background:#fff url(../images/icon_jifen.png) no-repeat -10px 0;border-radius: 5px;background-size: 65% auto;height: 136px;">'+
  49. '<p style="position: absolute;right: 26px;top: 0;line-height: 136px;font-size: 25px;color: #ffa53e;">+'+request.acquisition+' 积分</p>'+
  50. '</div>'}).width(255).show();
  51. location.hash+="acquisitionFlag"
  52. }
  53. var useAgent=JSON.parse(window.localStorage.getItem(agentName));
  54. var accountId=window.localStorage.getItem("accountId");
  55. getTemplateHelper();
  56. // 获取用户积分
  57. !function(){
  58. var params={
  59. creditsDetail:JSON.stringify({patientId:useAgent.uid,tradeDirection:-1}),
  60. };
  61. sendPost('patient/healthBank/selectAccount', params, 'json', 'post',function(){
  62. airDialog("系统繁忙,请稍后再试!");
  63. $('body').addClass('opened');
  64. },function(res){
  65. var hospital=res.data&&res.data.obj&&res.data.obj.hospital || '';
  66. var isOpen=!regionalRestrictions || regionalRestrictions.indexOf(hospital)!==-1;
  67. // if(isOpen)
  68. $('body').addClass('opened');
  69. // else location.replace("./unopened.html");//替换当前页面
  70. if(res.status==200){
  71. var accountId=res.data&&res.data.obj&&res.data.obj.id || "";
  72. if(accountId){
  73. window.localStorage.setItem("accountId",accountId);
  74. }else{
  75. airDialog("获取用户账户信息失败")
  76. }
  77. $("#total").text(res.data&&res.data.obj&&res.data.obj.total||0);
  78. $("#useTotal").text(res.data&&res.data.obj&&res.data.obj.usedTotal||0);
  79. }else if(res.status==-1){
  80. //商城未开放 先注释
  81. // location.replace("./unopened.html");
  82. }
  83. else{
  84. airDialog(res.msg)
  85. }
  86. })
  87. }()
  88. // 获得积分列表
  89. !function(){
  90. var params={
  91. task:JSON.stringify({"taskCode":["BP_BIND","GLU_BIND","BP_MEASURE","GLU_MEASURE"],"patientId":useAgent.uid}),
  92. page:1,
  93. size:10
  94. };
  95. sendPost('patient/healthBank/selectTasks', params, 'json', 'post',function(){
  96. airDialog("系统繁忙,请稍后再试!")
  97. },function(res){
  98. if((res.status==200)&&res.data){
  99. html = template('action_tmpl',{data: res.data.detailModelList||[]});
  100. $(".get-integral-act-list").html(html);
  101. }else{
  102. $('.get-integral').find('.div-no-info').removeClass('c-hide');
  103. }
  104. })
  105. }()
  106. // 活动列表
  107. !function(){
  108. var params={
  109. page:1,
  110. size:3, //默认初始只显示3个活动
  111. task:JSON.stringify({}),
  112. }
  113. sendPost('patient/healthBank/selectTask', params, 'json', 'post',function(){
  114. airDialog("系统繁忙,请稍后再试!")
  115. },function(res){
  116. if(res.status==200){
  117. var _data = res.data && res.data.detailModelList || [];
  118. for(var i=0,len=_data.length;i<len;i++){
  119. _data[i].endTime=_data[i].endTime.substr(0,10).replace(/-/g,'.');
  120. _data[i].startTime=_data[i].startTime.substr(0,10).replace(/-/g,'.');
  121. }
  122. $("#activity_list").html(template('activity_tmpl',{data: _data}));
  123. if(_data.length>1){
  124. // setTimeout(function(){
  125. var swiper = new Swiper('.activity-swiper', {
  126. pagination: '.swiper-pagination',
  127. paginationClickable: true,
  128. spaceBetween: 10,
  129. centeredSlides: true,
  130. autoplayDisableOnInteraction: false,
  131. autoplay: 2500
  132. });
  133. // },100)
  134. }
  135. }else{
  136. $('.activity-swiper').find('.div-no-info').removeClass('c-hide');
  137. }
  138. })
  139. }()
  140. $("#activity_list").on('click','.ckxq',function(){
  141. var code=$(this).data('code');
  142. location.href="./activity-detail.html?activity_id="+code;
  143. })
  144. })()
  145. function airDialog(content){
  146. dialog({contentType:'tipsbox',top:true, skin:'bk-popup' , content:content}).show();
  147. }
  148. function goUrl(url){
  149. location.href=url
  150. }
  151. function getTemplateHelper(){
  152. template.helper("getImageUrl", function(str){
  153. if(str){
  154. return getImgUrl(str);
  155. }else{
  156. return "../images/morenhuodong_banner01_img.png";
  157. }
  158. })
  159. }