detail.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (function(){
  2. //点赞
  3. $("body").on("click", ".dianzan .like", function(){
  4. if($(this).hasClass("hasDian")){
  5. CAIMEI.Alert("您已经给该信息点过赞!",'确定');
  6. }else{
  7. var infoId = $(this).attr("data-id");
  8. $.get("/article/like", {id: infoId}, function(res){
  9. if(res.code === 0){
  10. console.log("点赞成功!");
  11. $(".like").text( parseInt($(".like").attr("data-count"))+1).addClass("hasDian");
  12. } else {
  13. CAIMEI.Alert(res.msg,'确定');
  14. }
  15. });
  16. }
  17. });
  18. }());
  19. //相关阅读
  20. var articleRelated = new Vue({
  21. el: "#articleRelated",
  22. mixins: [cmSysVitaMixins],
  23. data: {
  24. infoId: $("#articleId").val()?$("#articleId").val()*1:0,
  25. articleLabels: $("#articleLabels").val()?$("#articleLabels").val():"",
  26. related: {}
  27. },
  28. methods: {
  29. // getRelatedList: function () {
  30. // var _self = this;
  31. // if(this.infoId ===0){return;}
  32. // $.getJSON("/article/related",{
  33. // id: this.infoId,
  34. // labels: this.articleLabels
  35. // }).done(function (r) {
  36. // if (r.code === 0 && r.data) {
  37. // _self.related = r.data;
  38. // }
  39. // });
  40. // },
  41. },
  42. created: function () {
  43. const pageLabelArray = []
  44. $('.dea-tag-li').each(function(){
  45. pageLabelArray.push($(this).find('a').text());
  46. })
  47. this.cmSysParams.pageType = 11;
  48. this.cmSysParams.pageLabel = pageLabelArray.join('/');
  49. this.infoId = $("#articleId").val() ? $("#articleId").val()*1 : 0;
  50. this.articleLabels = $("#articleLabels").val()?$("#articleLabels").val():"";
  51. // 获取相关阅读
  52. // this.getRelatedList();
  53. },
  54. mounted: function () {
  55. var _self = this;
  56. var thisUri = window.location.href;
  57. $('#qrcode').qrcode({
  58. "render": "canvas",
  59. "width": '120',
  60. "height": '120',
  61. "color": "#3a3",
  62. "text": thisUri
  63. });
  64. // 文章浏览量+1
  65. $.get("/article/pv", {id: this.infoId}, function(res){
  66. if(res.code === 0){
  67. // 更新文章索引
  68. $.post(coreServer + "/commodity/search/index/update/article", {articleId: _self.infoId}, function(res){
  69. console.log(res.msg);
  70. });
  71. }
  72. });
  73. }
  74. });