var d = dialog({contentType:'load', skin:'bk-popup'}); var pagetype=56; var unionId, taskCode; var actObj = {}; var activityId, taskId; (function(){ var swiperLength=$(".hdjl-swiper .swiper-wrapper").children().length; if(swiperLength>=3){ var swiper = new Swiper('.hdjl-swiper', { pagination: '.swiper-pagination', paginationClickable: true, spaceBetween: 15, slidesPerView:3 }); } })(); (function(){ checkUserAgent(); var useAgent=JSON.parse(window.localStorage.getItem(agentName)); var request=GetRequest(); var activity_id=request['activity_id']||''; var userData=[]; initPage(); getUnionId(); function initPage(){ var params={ page:1, size:1, task:JSON.stringify({"id":activity_id}), } sendPost('patient/healthBank/selectTask', params, 'json', 'post',function(){ airDialog("系统繁忙,请稍后再试!") },function(res){ if(res.status==200){ actObj = res.data && res.data.detailModelList && res.data.detailModelList[0] || []; taskCode = actObj.taskDOS && actObj.taskDOS[0] && actObj.taskDOS[0].taskCode || ""; activityId = actObj.taskPatientDetailDOS && actObj.taskPatientDetailDOS[0] && actObj.taskPatientDetailDOS[0].activityId || ""; taskId = actObj.taskPatientDetailDOS && actObj.taskPatientDetailDOS[0] && actObj.taskPatientDetailDOS[0].taskId || ""; var html =template('page_tmpl',{activity:actObj}) $('.activity-detail').html(html); var swiperLength=$(".hdjl-swiper .swiper-wrapper").children().length; if(swiperLength>=3){ var swiper = new Swiper('.hdjl-swiper', { pagination: '.swiper-pagination', paginationClickable: true, spaceBetween: 15, slidesPerView:3 }); } // getUserList() actObj && (!actObj.taskPatientDetailDOS.length) && getUserList(); }else{ $('.activity-swiper').find('.div-no-info').removeClass('c-hide'); } }) } function getUserList(){ sendPost('patient/healthBank/selectByOpenId', {}, 'json', 'post',function(){ airDialog("系统繁忙,请稍后再试!"); },function(res){ if(res.status==200){ userData = res.data && res.data.patientList || []; $('.user-select').append(template('user_option_tmpl',{data:userData})) var item=userData[0]; $('.select-user-info').html(template('user_info_tmpl',{item:item})) }else{ airDialog(res.msg||"获取报名列表失败") } }) } $('.user-select').on('change',function(){ $('.select-user-info').html(template('user_info_tmpl',{item:userData[$(event.target).children('option:selected').index()]})) }); // 报名 $('.activity-detail').on('click','.join',function(){ showModel(); }); // 活动入口 $('.activity-detail').on('click','.act-into',function(){ var nowTimes = new Date().getTime(); var times = Date.parse(new Date(actObj.startTime.replace(/-/g, "/"))); if(nowTimes < times) { airDialog("本活动将于 " + actObj.startTime + " 时间开放,请按时参加~") } else { // 小程序jssdk参数配置 var appid = "wx0e663ce069b5170c", secret = "02de788ffea28f2aa3b9bf10312ab05e"; $jssdk = new JSSDK(appid, secret); console.log($jssdk) $signPackage = $jssdk.GetSignPackage(); // 尝试跳转 var programUrl = "pages/index/index?activityId=" + activityId + "&taskId=" + taskId; wx.miniProgram.navigateTo({url: programUrl}) // airDialog("恭喜您!活动入口消息已发送至公众号,请关闭健康银行前去参加~") } }); $('.i-modal-close, .i-modal-layer').on('click',function(){ hideModel(); }); // 阻止滑动 $(".i-modal").on("touchmove", function(e) { e.preventDefault(); }); $('.comfirm-btn').on('click',function(){ hideModel(); var select=$('.user-select').children('option:selected') var patientId=select.data('code'); var patientIdcard=select.data('card'); var params={ taskPatientDetail:JSON.stringify({ "saasId":"dev", "patientId":patientId, "patientIdcard":patientIdcard, "doctorId":"", "activityId":activity_id, "unionId": unionId, "taskCode": taskCode }) } sendPost('patient/healthBank/attendTask', params, 'json', 'post',function(){ airDialog("系统繁忙,请稍后再试!"); },function(res){ airDialog(res.data && res.data.message || res.msg); if(!res.data.message) initPage(); }) }) function hideModel(){ $(".comfirm-info").fadeOut(); $('body').removeClass("i-modal-open"); } function showModel(){ $(".comfirm-info").fadeIn(); $('body').addClass("i-modal-open");//禁止屏幕滚动 } })(); function getUnionId(){ var openid = JSON.parse(window.localStorage.getItem("OpenidAgent")).openid; var url = "weixin/getUnionidByOpenid", params = { openid: openid }; sendPost(url, params, 'json', 'GET', function(res){ airDialog(res.msg); }, function(res){ if(res.status == 200){ unionId = res.unionid; }else{ airDialog(res.msg); } }) } function airDialog(content){ dialog({contentType:'tipsbox',top:true, skin:'bk-popup' , content:content}).show(); } template.helper("getBigImage", function(str){ if(str){ return getImgUrl(str); }else{ return "../images/morenhuodong_banner02_img.png"; } })