var userId=$.urlParam("userId"); var cname=$.urlParam("cName"); var behavior=$.urlParam("behavior"); var articleId=$.urlParam("articleId"); var userType=$.urlParam("userType"); var articleCategoryId=$.urlParam("articleCategoryId"); var articleCategoryName=$.urlParam("articleCategoryName"); var signaturdata={}; var articledata={}; $(function(){ myLayer.load("加载中,请稍后"); initSignatur();//获取署名配置 initArticleORCode();//获取二维码 saveBehavior(userId,cname,behavior,articleId);//保存用户行为记录 initArticleDetial(articleId,userId); initArticleEvaluate(articleId); myLayer.clear(); $('.share-btn-close').click(function(){ $(this).parent().addClass('c-hide'); }) // 文章按钮 $(".article-btn-list").on('click','li',function(){ var num = $(this).index(); switch(parseInt(num)) { case 0 : if($(this).hasClass('curr')) { cancelDz(); }else{ saveDz(); } break; case 1 : if($(this).hasClass('curr')) { cancelSc(); }else { saveSc(); } break; case 2 : $('.share-mask').removeClass('c-hide'); break; } }) // 评论点赞 $('.comment-row').off().on('click','span.fr',function(){ var num = $(this).find('em').text(); num++; $(this).find('em').text(num); }) }) function initArticleORCode(){ var url= jkzl.common.path+"/config/getArticleORCode"; var param={}; $.post(url,param,function(result){ if(result.Code==10000){ var res=result.Result; if(res[0]){ if(res[0].position == 1 && !isNull(res[0].imgUrl)){ $("#top_zcode").attr("src",res[0].imgUrl); $("#article_top_code").removeClass("c-hide"); }else if(res[0].position == 2 && !isNull(res[0].imgUrl)){ $("#floor_code").attr("src",res[0].imgUrl); $("#article_floor_code").removeClass("c-hide"); } } }else{ myLayer.clear(); myLayer.alert(result.Message); return; } }); } function initSignatur(){ var url= jkzl.common.path+"/config/getSignatur"; var param={}; $.post(url,param,function(result){ if(result.Code==10000){ var res=result.Result; signaturdata=res[0]; }else{ myLayer.clear(); myLayer.alert(result.Message); return; } }); } function saveBehavior(uid,uname,uaction,aid){//用户的行为记录 var url= jkzl.common.path+"/behavior/saveBehavior"; var param={}; param.articleId=aid; param.userId=uid; param.cName=uname; param.behaviorAction=uaction; $.post(url,param,function(res){ return res; }); } function initArticleDetial(aid,uid){//获取文章详情 var url= jkzl.common.path+"/article/getArticalById"; var param={}; param.articleId=aid; param.userId=uid; sendPost(url,param, "json", "post", initArticleDetialFailed, initArticleDetialSuccess); } function initArticleDetialFailed(res){ myLayer.clear(); if (res && res.Message) { myLayer.alert(res.Message); return; } else { myLayer.alert("请求失败,请重新刷新页面"); return; } } function initArticleDetialSuccess(res){ if (res.Code == 10000) { if(res.Result){ var result=res.Result; articledata=result[0]; $("#article_title").html(result[0].articleTitle); $("#article_name").html(result[0].operatorName); $("#article_inserttime").html(result[0].insertTime.substring(0,result[0].insertTime.length-2)); if(result[0].isAuthentication){ if(result[0].isAuthentication ==1){ $("#article_auth").removeClass("c-hide"); } } if(signaturdata){ if(signaturdata.state == 1){ if(signaturdata.position==1 || signaturdata.position==3){ $("#doctor_top_img").attr("src",result[0].operatorImg); $("#doctor_top_content").html(""+result[0].operatorName+""+result[0].titleLevel); $("#doctor_top_dept").html(result[0].deptName); $("#doctor_top_hos").html(result[0].orgName); $("#doctor_top_detail").removeClass("c-hide"); }else if(signaturdata.position == 2 || signaturdata.position == 3){ $("#doctor_floor_img").attr("src",result[0].operatorImg);//还没头像 $("#doctor_floor_content").html(""+result[0].operatorName+""+result[0].titleLevel); $("#doctor_floor_dept").html(result[0].deptName); $("#doctor_floor_hos").html(result[0].orgName); $("#doctor_floor_detail").removeClass("c-hide"); } } } if(result[0].articleContent){ $("#article_content").html(result[0].articleContent); } if(result[0].collectionNumberCount>0){ $("#article_sc_title").html("已收藏"); $("#article_sc_li").addClass("curr"); }else{ $("#article_sc_title").html("收藏"); } $("#article_dz").html(result[0].pointNumber); $("#article_sc").html(result[0].collectionNumber); } myLayer.clear(); } else { initArticleDetialFailed(res); } } function saveDz(){//点赞 myLayer.load("执行中,请稍后"); var uaction="1"; var url= jkzl.common.path+"/behavior/saveBehavior"; var param={}; param.articleId=articleId; param.userId=userId; param.cName=cname; param.behaviorAction=uaction; $.post(url,param,function(res){ myLayer.clear(); if(res.Code== 10000){ myLayer.alert('' + '点赞成功','2000'); $("#article_dz_li").addClass("curr"); var tipNum = $("#article_dz_li").find('.tips').text(); $("#article_dz").html(add(tipNum)); }else{ myLayer.alert(res.Message); return; } }); } function cancelDz(){//取消点赞 myLayer.load("执行中,请稍后"); var url= jkzl.common.path+"/behavior/cancelBehavior"; var param={}; param.articleId=articleId; param.userType=userType; param.userId=userId; sendPost(url,param, "json", "post",cancelDzFailed, cancelDzSuccess); } function cancelDzFailed(res){//失败 myLayer.clear(); if (res && res.Message) { myLayer.alert(res.Message); return; } else { myLayer.alert("请求失败,请重新刷新页面"); return; } } function cancelDzSuccess(res){//成功 if(res.Code == 10000){ myLayer.clear(); myLayer.alert('' + '取消点赞','2000'); $("#article_dz_li").removeClass("curr"); var tipNum = $("#article_dz_li").find('.tips').text(); $("#article_dz").html(reduce(tipNum)); }else{ cancelDzFailed(res); } } function cancelSc(){//取消收藏 myLayer.load("执行中,请稍后"); var url= jkzl.common.path+"/behavior/cancelArticle"; var param={}; param.articleId=articleId; param.userType=userType; param.userId=userId; sendPost(url,param, "json", "post", cancelScFailed, cancelScSuccess); } function cancelScFailed(res){//失败 myLayer.clear(); if (res && res.Message) { myLayer.alert(res.Message); return; } else { myLayer.alert("请求失败,请重新刷新页面"); return; } } function cancelScSuccess(res){//成功 if(res.Code == 10000){ myLayer.clear(); myLayer.alert('' + '取消收藏','2000'); $("#article_sc_title").html("收藏"); $("#article_sc_li").removeClass("curr"); var tipNum = $("#article_sc_li").find('.tips').text(); $("#article_sc").html(reduce(tipNum)); }else{ cancelScFailed(res); } } function saveSc(){//收藏 myLayer.load("执行中,请稍后"); var url= jkzl.common.path+"/behavior/saveArticleCollection"; var param={}; param.articleId=articleId; param.userType=userType; param.userId=userId; param.cName=cname; if(isNull(articledata.secondLevelCategoryId)){ param.articleCategoryId=articledata.firstLevelCategoryId; param.articleCategoryName=articledata.firstLevelCategoryName; }else{ param.articleCategoryId=articledata.secondLevelCategoryId; param.articleCategoryName=articledata.secondLevelCategoryName; } sendPost(url,param, "json", "post", saveScFailed, saveScSuccess); } function saveScFailed(res){//失败 myLayer.clear(); if (res && res.Message) { myLayer.alert(res.Message); return; } else { myLayer.alert("请求失败,请重新刷新页面"); return; } } function saveScSuccess(res){//成功 if(res.Code == 10000){ myLayer.clear(); myLayer.alert('' + '已收藏','2000'); $("#article_sc_title").html("已收藏"); $("#article_sc_li").addClass("curr"); var tipNum =$("#article_sc_li").find('.tips').text(); $("#article_sc").html(add(tipNum)); }else{ saveScFailed(res); } } function add(num){ var nresult=0; if(isNull(num)){ nresult=1; }else{ nresult=parseInt(num)+1; } return nresult; } function reduce(num){ var nresult=0; if(isNull(num)){ nresult=0; }else{ nresult=parseInt(num)-1; } return nresult; } function initArticleEvaluate(){ var url= jkzl.common.path+"/behavior/getArticleCommentList"; var param={}; param.articleId=articleId; param.pageSize="100"; param.pageIndex="0"; sendPost(url,param, "json", "post", initArticleEvaluateFailed, initArticleEvaluateSuccess); } function initArticleEvaluateFailed(res){//失败 myLayer.clear(); if (res && res.Message) { myLayer.alert(res.Message); return; } else { myLayer.alert("请求失败,请重新刷新页面"); return; } } function initArticleEvaluateSuccess(res){//成功 if(res.Code == 10000){ var result=res.Result; var htmlstr =""; $("#article_pj").html(''); for(var i=result.length-1;i>=0;i--){ htmlstr +="
"; htmlstr +=""+result[i].cName+""; htmlstr +="
"+result[i].commentContent+"
"; htmlstr +=" "+result[i].dateTime+"