123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- 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";
- }
- })
|