1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- (function(){
- //点赞
- $("body").on("click", ".dianzan .like", function(){
- if($(this).hasClass("hasDian")){
- CAIMEI.Alert("您已经给该信息点过赞!",'确定');
- }else{
- var infoId = $(this).attr("data-id");
- $.get("/article/like", {id: infoId}, function(res){
- if(res.code === 0){
- console.log("点赞成功!");
- $(".like").text( parseInt($(".like").attr("data-count"))+1).addClass("hasDian");
- } else {
- CAIMEI.Alert(res.msg,'确定');
- }
- });
- }
- });
- }());
- //相关阅读
- var articleRelated = new Vue({
- el: "#articleRelated",
- data: {
- infoId: $("#articleId").val()?$("#articleId").val()*1:0,
- articleLabels: $("#articleLabels").val()?$("#articleLabels").val():"",
- related: {}
- },
- methods: {
- // getRelatedList: function () {
- // var _self = this;
- // if(this.infoId ===0){return;}
- // $.getJSON("/article/related",{
- // id: this.infoId,
- // labels: this.articleLabels
- // }).done(function (r) {
- // if (r.code === 0 && r.data) {
- // _self.related = r.data;
- // }
- // });
- // },
- },
- created: function () {
- this.infoId = $("#articleId").val() ? $("#articleId").val()*1 : 0;
- this.articleLabels = $("#articleLabels").val()?$("#articleLabels").val():"";
- // 获取相关阅读
- // this.getRelatedList();
- },
- mounted: function () {
- var _self = this;
- var thisUri = window.location.href;
- $('#qrcode').qrcode({
- "render": "canvas",
- "width": '120',
- "height": '120',
- "color": "#3a3",
- "text": thisUri
- });
- // 文章浏览量+1
- $.get("/article/pv", {id: this.infoId}, function(res){
- if(res.code === 0){
- // 更新文章索引
- $.post(coreServer + "/commodity/search/index/update/article", {articleId: _self.infoId}, function(res){
- console.log(res.msg);
- });
- }
- });
- }
- });
|