57fbcd681b481e17026639ab1c5ac076b1b6c7c3.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. var userId;
  2. if(isNull(userId)){
  3. userId=eval('(' + getUserInfo() + ')').uid;
  4. }
  5. var behavior=$.urlParam("behavior");
  6. var articleId=$.urlParam("articleId");
  7. var signaturdata={};
  8. var articledata={};
  9. $(function(){
  10. myLayer.load("加载中,请稍后");
  11. initSignatur();//获取署名配置
  12. initArticleORCode();//获取二维码
  13. saveBehavior(userId,behavior,articleId);//保存用户行为记录
  14. initArticleDetial(articleId,userId);
  15. initArticleEvaluate(articleId);
  16. myLayer.clear();
  17. $('.share-btn-close').click(function(){
  18. $(this).parent().addClass('c-hide');
  19. })
  20. // 文章按钮
  21. $(".article-btn-list").on('click','li',function(){
  22. var num = $(this).index();
  23. switch(parseInt(num)) {
  24. case 0 :
  25. if($(this).hasClass('curr')) {
  26. cancelDz();
  27. }else{
  28. saveDz();
  29. }
  30. break;
  31. case 1 :
  32. if($(this).hasClass('curr')) {
  33. cancelSc();
  34. }else {
  35. saveSc();
  36. }
  37. break;
  38. case 2 :
  39. $('.share-mask').removeClass('c-hide');
  40. break;
  41. }
  42. })
  43. // 评论点赞
  44. $('.comment-row').off().on('click','span.fr',function(){
  45. var num = $(this).find('em').text();
  46. num++;
  47. $(this).find('em').text(num);
  48. })
  49. })
  50. function initArticleORCode(){
  51. var url= jkzl.common.path+"/config/getArticleORCode";
  52. var param={};
  53. $.post(url,param,function(result){
  54. if(result.Code==10000){
  55. var res=result.Result;
  56. if(res[0]){
  57. if(res[0].position == 1 && !isNull(res[0].imgUrl)){
  58. $("#top_zcode").attr("src",res[0].imgUrl);
  59. $("#article_top_code").removeClass("c-hide");
  60. }else if(res[0].position == 2 && !isNull(res[0].imgUrl)){
  61. $("#floor_code").attr("src",res[0].imgUrl);
  62. $("#article_floor_code").removeClass("c-hide");
  63. }
  64. }
  65. }else{
  66. myLayer.clear();
  67. myLayer.alert(result.Message);
  68. return;
  69. }
  70. });
  71. }
  72. function initSignatur(){
  73. var url= jkzl.common.path+"/config/getSignatur";
  74. var param={};
  75. $.post(url,param,function(result){
  76. myLayer.clear();
  77. if(result.Code==10000){
  78. var res=result.Result;
  79. signaturdata=res[0];
  80. }else{
  81. myLayer.alert(result.Message);
  82. }
  83. });
  84. }
  85. function saveBehavior(uid,uaction,aid){//用户的行为记录
  86. var url= jkzl.common.path+"/behavior/saveBehavior";
  87. var param={};
  88. param.articleId=aid;
  89. param.userId=uid;
  90. param.behaviorAction=uaction;
  91. $.post(url,param,function(res){
  92. return res;
  93. });
  94. }
  95. function initArticleDetial(aid,uid){//获取文章详情
  96. var url= jkzl.common.path+"/article/getArticalById";
  97. var param={};
  98. param.articleId=aid;
  99. param.userId=uid;
  100. sendPost(url,param, "json", "post", initArticleDetialFailed, initArticleDetialSuccess);
  101. }
  102. function initArticleDetialFailed(res){
  103. myLayer.clear();
  104. if (res && res.Message) {
  105. myLayer.alert(res.Message);
  106. } else {
  107. myLayer.alert("请求失败,请重新刷新页面");
  108. }
  109. }
  110. function initArticleDetialSuccess(res){
  111. if (res.Code == 10000) {
  112. if(res.Result){
  113. var result=res.Result;
  114. articledata=result[0];
  115. $("#article_title").html(result[0].articleTitle);
  116. $("#article_name").html(result[0].operatorName);
  117. $("#article_inserttime").html(result[0].insertTime.substring(0,result[0].insertTime.length-2));
  118. if(result[0].isAuthentication){
  119. if(result[0].isAuthentication ==1){
  120. $("#article_auth").removeClass("c-hide");
  121. }
  122. }
  123. if(signaturdata){
  124. if(signaturdata.state == 1){
  125. if(signaturdata.position==1 || signaturdata.position==3){
  126. $("#doctor_top_img").attr("src",result[0].operatorImg);
  127. $("#doctor_top_content").html("<span class='mr5 c-f18 c-333'>"+result[0].operatorName+"</span>"+result[0].titleLevel);
  128. $("#doctor_top_dept").html(result[0].deptName);
  129. $("#doctor_top_hos").html(result[0].orgName);
  130. $("#doctor_top_detail").removeClass("c-hide");
  131. }else if(signaturdata.position == 2 || signaturdata.position == 3){
  132. $("#doctor_floor_img").attr("src",result[0].operatorImg);//还没头像
  133. $("#doctor_floor_content").html("<span class='mr5 c-f18 c-333'>"+result[0].operatorName+"</span>"+result[0].titleLevel);
  134. $("#doctor_floor_dept").html(result[0].deptName);
  135. $("#doctor_floor_hos").html(result[0].orgName);
  136. $("#doctor_floor_detail").removeClass("c-hide");
  137. }
  138. }
  139. }
  140. if(result[0].articleContent){
  141. $("#article_content").html(result[0].articleContent);
  142. }
  143. if(result[0].pointNumberCount>0){
  144. $("#article_dz_title").html("已点赞");
  145. $("#article_dz_li").addClass("curr");
  146. }else{
  147. $("#article_dz_title").html("点个赞");
  148. }
  149. if(result[0].collectionNumberCount>0){
  150. $("#article_sc_title").html("已收藏");
  151. $("#article_sc_li").addClass("curr");
  152. }else{
  153. $("#article_sc_title").html("收藏");
  154. }
  155. $("#article_dz").html(result[0].pointNumber);
  156. $("#article_sc").html(result[0].collectionNumber);
  157. }
  158. myLayer.clear();
  159. } else {
  160. initArticleDetialFailed(res);
  161. }
  162. }
  163. function saveDz(){//点赞
  164. myLayer.load("执行中,请稍后");
  165. var uaction="1";
  166. var url= jkzl.common.path+"/behavior/saveBehavior";
  167. var param={};
  168. param.articleId=articleId;
  169. param.userId=userId;
  170. param.behaviorAction=uaction;
  171. $.post(url,param,function(res){
  172. myLayer.clear();
  173. if(res.Code== 10000){
  174. myLayer.alert('<i class="iconfont icon-zan c-f22 c-fff ml15 mr5 c-vam"></i>' + '<span class="c-f15 c-vam mr15">点赞成功</span>','2000');
  175. $("#article_dz_title").html("已点赞");
  176. $("#article_dz_li").addClass("curr");
  177. var tipNum = $("#article_dz_li").find('.tips').text();
  178. $("#article_dz").html(add(tipNum));
  179. }else{
  180. myLayer.alert(res.Message);
  181. return;
  182. }
  183. });
  184. }
  185. function cancelDz(){//取消点赞
  186. myLayer.load("执行中,请稍后");
  187. var url= jkzl.common.path+"/behavior/cancelBehavior";
  188. var param={};
  189. param.articleId=articleId;
  190. param.userId=userId;
  191. sendPost(url,param, "json", "post",cancelDzFailed, cancelDzSuccess);
  192. }
  193. function cancelDzFailed(res){//失败
  194. myLayer.clear();
  195. if (res && res.Message) {
  196. myLayer.alert(res.Message);
  197. } else {
  198. myLayer.alert("请求失败,请重新刷新页面");
  199. }
  200. }
  201. function cancelDzSuccess(res){//成功
  202. if(res.Code == 10000){
  203. myLayer.clear();
  204. myLayer.alert('<i class="iconfont icon-shoucang c-f22 c-fff ml15 mr5 c-vam"></i>' + '<span class="c-f15 c-vam mr15">取消点赞</span>','2000');
  205. $("#article_dz_title").html("点个赞");
  206. $("#article_dz_li").removeClass("curr");
  207. var tipNum = $("#article_dz_li").find('.tips').text();
  208. $("#article_dz").html(reduce(tipNum));
  209. }else{
  210. cancelDzFailed(res);
  211. }
  212. }
  213. function cancelSc(){//取消收藏
  214. myLayer.load("执行中,请稍后");
  215. var url= jkzl.common.path+"/behavior/cancelArticle";
  216. var param={};
  217. param.articleId=articleId;
  218. param.userId=userId;
  219. sendPost(url,param, "json", "post", cancelScFailed, cancelScSuccess);
  220. }
  221. function cancelScFailed(res){//失败
  222. myLayer.clear();
  223. if (res && res.Message) {
  224. myLayer.alert(res.Message);
  225. } else {
  226. myLayer.alert("请求失败,请重新刷新页面");
  227. }
  228. }
  229. function cancelScSuccess(res){//成功
  230. if(res.Code == 10000){
  231. myLayer.clear();
  232. myLayer.alert('<i class="iconfont icon-shoucang c-f22 c-fff ml15 mr5 c-vam"></i>' + '<span class="c-f15 c-vam mr15">取消收藏</span>','2000');
  233. $("#article_sc_title").html("收藏");
  234. $("#article_sc_li").removeClass("curr");
  235. var tipNum = $("#article_sc_li").find('.tips').text();
  236. $("#article_sc").html(reduce(tipNum));
  237. }else{
  238. cancelScFailed(res);
  239. }
  240. }
  241. function saveSc(){//收藏
  242. myLayer.load("执行中,请稍后");
  243. var url= jkzl.common.path+"/behavior/saveArticleCollection";
  244. var param={};
  245. param.articleId=articleId;
  246. param.userId=userId;
  247. if(isNull(articledata.secondLevelCategoryId)){
  248. param.articleCategoryId=articledata.firstLevelCategoryId;
  249. param.articleCategoryName=articledata.firstLevelCategoryName;
  250. }else{
  251. param.articleCategoryId=articledata.secondLevelCategoryId;
  252. param.articleCategoryName=articledata.secondLevelCategoryName;
  253. }
  254. sendPost(url,param, "json", "post", saveScFailed, saveScSuccess);
  255. }
  256. function saveScFailed(res){//失败
  257. myLayer.clear();
  258. if (res && res.Message) {
  259. myLayer.alert(res.Message);
  260. } else {
  261. myLayer.alert("请求失败,请重新刷新页面");
  262. }
  263. }
  264. function saveScSuccess(res){//成功
  265. if(res.Code == 10000){
  266. myLayer.clear();
  267. myLayer.alert('<i class="iconfont icon-shoucang c-f22 c-fff ml15 mr5 c-vam"></i>' + '<span class="c-f15 c-vam mr15">已收藏</span>','2000');
  268. $("#article_sc_title").html("已收藏");
  269. $("#article_sc_li").addClass("curr");
  270. var tipNum =$("#article_sc_li").find('.tips').text();
  271. $("#article_sc").html(add(tipNum));
  272. }else{
  273. saveScFailed(res);
  274. }
  275. }
  276. function add(num){
  277. var nresult=0;
  278. if(isNull(num)){
  279. nresult=1;
  280. }else{
  281. nresult=parseInt(num)+1;
  282. }
  283. return nresult;
  284. }
  285. function reduce(num){
  286. var nresult=0;
  287. if(isNull(num)){
  288. nresult=0;
  289. }else{
  290. nresult=parseInt(num)-1;
  291. }
  292. return nresult;
  293. }
  294. function initArticleEvaluate(){
  295. var url= jkzl.common.path+"/behavior/getArticleCommentList";
  296. var param={};
  297. param.articleId=articleId;
  298. param.pageSize="100";
  299. param.pageIndex="0";
  300. sendPost(url,param, "json", "post", initArticleEvaluateFailed, initArticleEvaluateSuccess);
  301. }
  302. function initArticleEvaluateFailed(res){//失败
  303. myLayer.clear();
  304. if (res && res.Message) {
  305. myLayer.alert(res.Message);
  306. } else {
  307. myLayer.alert("请求失败,请重新刷新页面");
  308. }
  309. }
  310. function initArticleEvaluateSuccess(res){//成功
  311. if(res.Code == 10000){
  312. var result=res.Result;
  313. var htmlstr ="";
  314. $("#article_pj").html('');
  315. for(var i=0;i<result.length;i++){
  316. htmlstr +=" <div class='comment-row plr15 ptb10 clearfix'>";
  317. if(!isNull(result[i].userImg)){
  318. htmlstr +="<img src="+result[i].userImg+">";
  319. }
  320. htmlstr +="<div class='row-con'><p class='row-con-title c-f12 c-007cd9'>";
  321. htmlstr +="<span>"+result[i].cName+"</span>";
  322. htmlstr +="</p><p class='c-f13 c-666 mb5'>"+result[i].commentContent+"</p>";
  323. htmlstr +=" <span class='c-f11 c-999'>"+result[i].dateTime+"</span></div></div>";
  324. }
  325. $("#article_pj").html(htmlstr);
  326. }else{
  327. initArticleEvaluateFailed(res);
  328. }
  329. }
  330. function sendEvaluate(){
  331. myLayer.confirm({
  332. title:'提示',
  333. con:'确定要发送该评论吗?',
  334. cancel: function(){},
  335. cancelValue:'取消',
  336. ok: function(){
  337. var url= jkzl.common.path+"/behavior/saveArticleComment";
  338. var param={};
  339. param.articleId=articleId;
  340. param.commentContent=$("#user_evaluate").val();
  341. param.userId=userId;
  342. if(param.commentContent.length ==0){
  343. myLayer.alert("评价内容不能为空!");
  344. }
  345. myLayer.load("执行中,请稍后");
  346. $.post(url,param,function(result){
  347. myLayer.clear();
  348. if(result.Code==10000){
  349. myLayer.alert("评价成功!");
  350. $("#user_evaluate").val("");
  351. initArticleEvaluate(articleId);
  352. }else{
  353. myLayer.alert(result.Message);
  354. }
  355. });
  356. },
  357. okValue:'确定'
  358. });
  359. }