8c14abb6d8ead08a2bfc46cce804b2785355c0a5.svn-base 12 KB

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