detail.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. relatedLabels:''
  28. },
  29. methods: {
  30. // getRelatedList: function () {
  31. // var _self = this;
  32. // if(this.infoId ===0){return;}
  33. // $.getJSON("/article/related",{
  34. // id: this.infoId,
  35. // labels: this.articleLabels
  36. // }).done(function (r) {
  37. // if (r.code === 0 && r.data) {
  38. // _self.related = r.data;
  39. // }
  40. // });
  41. // },
  42. },
  43. created: function () {
  44. const pageLabelArray = []
  45. this.cmSysParams.pageType = 11;
  46. this.infoId = this.handlearticleId = $("#articleId").val() ? $("#articleId").val()*1 : 0;
  47. this.articleLabels = $("#articleLabels").val()?$("#articleLabels").val():"";
  48. this.relatedLabels = $("#relatedLabels").val()?$("#relatedLabels").val():"";
  49. if(this.relatedLabels){
  50. this.cmSysParams.pageLabel = this.relatedLabels
  51. }else{
  52. $('.dea-tag-li').each(function(){
  53. pageLabelArray.push($(this).find('a').text());
  54. })
  55. this.cmSysParams.pageLabel = pageLabelArray.join('/');
  56. }
  57. // 获取相关阅读
  58. // this.getRelatedList();
  59. },
  60. mounted: function () {
  61. var _self = this;
  62. var thisUri = window.location.href;
  63. // 文章浏览量+1
  64. $.get("/article/pv", {id: this.infoId}, function(res){
  65. if(res.code === 0){
  66. console.log('浏览量+1')
  67. // 更新文章索引
  68. $.post(coreServer + "/commodity/search/index/update/article", {articleId: _self.infoId}, function(res){
  69. console.log(res.msg);
  70. });
  71. }
  72. });
  73. $('#qrcode').qrcode({
  74. "render": "canvas",
  75. "width": '120',
  76. "height": '120',
  77. "color": "#3a3",
  78. "text": thisUri
  79. });
  80. }
  81. });