detail.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. data: {
  23. infoId: $("#articleId").val()?$("#articleId").val()*1:0,
  24. articleLabels: $("#articleLabels").val()?$("#articleLabels").val():"",
  25. related: {}
  26. },
  27. methods: {
  28. // getRelatedList: function () {
  29. // var _self = this;
  30. // if(this.infoId ===0){return;}
  31. // $.getJSON("/article/related",{
  32. // id: this.infoId,
  33. // labels: this.articleLabels
  34. // }).done(function (r) {
  35. // if (r.code === 0 && r.data) {
  36. // _self.related = r.data;
  37. // }
  38. // });
  39. // },
  40. },
  41. created: function () {
  42. this.infoId = $("#articleId").val() ? $("#articleId").val()*1 : 0;
  43. this.articleLabels = $("#articleLabels").val()?$("#articleLabels").val():"";
  44. // 获取相关阅读
  45. // this.getRelatedList();
  46. },
  47. mounted: function () {
  48. var _self = this;
  49. var thisUri = window.location.href;
  50. $('#qrcode').qrcode({
  51. "render": "canvas",
  52. "width": '120',
  53. "height": '120',
  54. "color": "#3a3",
  55. "text": thisUri
  56. });
  57. // 文章浏览量+1
  58. $.get("/article/pv", {id: this.infoId}, function(res){
  59. if(res.code === 0){
  60. // 更新文章索引
  61. $.post(coreServer + "/commodity/search/index/update/article", {articleId: _self.infoId}, function(res){
  62. console.log(res.msg);
  63. });
  64. }
  65. });
  66. }
  67. });